當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeAuthenticationRepository.RefreshToken方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/api/fakes.FakeAuthenticationRepository.RefreshToken方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeAuthenticationRepository.RefreshToken方法的具體用法?Golang FakeAuthenticationRepository.RefreshToken怎麽用?Golang FakeAuthenticationRepository.RefreshToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/cli/cf/api/fakes.FakeAuthenticationRepository的用法示例。


在下文中一共展示了FakeAuthenticationRepository.RefreshToken方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

	})

	Describe("When logged in", func() {
		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
		})

		It("fails if oauth refresh fails", func() {
			authRepo.RefreshTokenError = errors.New("Could not refresh")
			runCommand()

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"FAILED"},
				[]string{"Could not refresh"},
			))
		})

		It("returns to the user the oauth token after a refresh", func() {
			authRepo.RefreshToken = "1234567890"
			runCommand()

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Getting OAuth token..."},
				[]string{"OK"},
				[]string{"1234567890"},
			))
		})
	})

})
開發者ID:tools-alexuser01,項目名稱:cli,代碼行數:30,代碼來源:oauth_token_test.go

示例2:

					authRepo.RefreshTokenError = errors.New("no token for you!")

					runCommand()
					Ω(authRepo.RefreshTokenCalled).To(BeTrue())
					Ω(ui.Outputs).To(ContainSubstrings(
						[]string{"Error refreshing oauth token", "no token for you"},
					))
				})
			})
		})

		Context("setting up http client to request one time code", func() {
			var fakeUAA *ghttp.Server

			BeforeEach(func() {
				authRepo.RefreshToken = "bearer client-bearer-token"
				configRepo.SetSSLDisabled(true)
				configRepo.SetSSHOAuthClient("ssh-oauth-client-id")

				fakeUAA = ghttp.NewTLSServer()
				configRepo.SetUaaEndpoint(fakeUAA.URL())

				fakeUAA.RouteToHandler("GET", "/oauth/authorize", ghttp.CombineHandlers(
					ghttp.VerifyRequest("GET", "/oauth/authorize"),
					ghttp.VerifyFormKV("response_type", "code"),
					ghttp.VerifyFormKV("client_id", "ssh-oauth-client-id"),
					ghttp.VerifyFormKV("grant_type", "authorization_code"),
					ghttp.VerifyHeaderKV("authorization", "bearer client-bearer-token"),
					ghttp.RespondWith(http.StatusFound, "", http.Header{
						"Location": []string{"https://uaa.example.com/login?code=abc123"},
					}),
開發者ID:vframbach,項目名稱:cli,代碼行數:31,代碼來源:ssh_code_test.go

示例3:

		BeforeEach(func() {
			requirementsFactory.LoginSuccess = true
		})

		It("fails if oauth refresh fails", func() {
			authRepo.RefreshTokenError = errors.New("Could not refresh")
			runCommand()

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"FAILED"},
				[]string{"Could not refresh"},
			))
		})

		It("returns to the user the oauth token after a refresh", func() {
			authRepo.RefreshToken = "1234567890"
			runCommand()

			Expect(ui.Outputs).To(ContainSubstrings(
				[]string{"Getting OAuth token..."},
				[]string{"OK"},
				[]string{"1234567890"},
			))
		})

		Context("when invoked by a plugin", func() {
			var (
				pluginModel plugin_models.GetOauthToken_Model
			)

			BeforeEach(func() {
開發者ID:vframbach,項目名稱:cli,代碼行數:31,代碼來源:oauth_token_test.go

示例4:

			BeforeEach(func() {
				orgRepo.FindByNameReturns(models.Organization{
					OrganizationFields: models.OrganizationFields{
						Name: "new-org",
						Guid: "new-org-guid",
					},
				}, nil)

				space1 := models.Space{}
				space1.Guid = "new-space-guid"
				space1.Name = "new-space-name"
				spaceRepo.ListSpacesStub = listSpacesStub([]models.Space{space1})
				spaceRepo.FindByNameReturns(space1, nil)

				authRepo.AccessToken = "new_access_token"
				authRepo.RefreshToken = "new_refresh_token"

				Flags = []string{"-u", "[email protected]", "-p", "password", "-o", "new-org", "-s", "new-space"}

				Config.SetApiEndpoint("api.the-old-endpoint.com")
				Config.SetSSLDisabled(true)
			})

			ItSucceeds()
			ItShowsTheTarget()

			It("does not update the api endpoint or SSL setting", func() {
				Expect(Config.ApiEndpoint()).To(Equal("api.the-old-endpoint.com"))
				Expect(Config.IsSSLDisabled()).To(BeTrue())
			})
開發者ID:vframbach,項目名稱:cli,代碼行數:30,代碼來源:login_test.go

示例5:

					pingCli(rpcService.Port())
				})

				It("refreshes the token", func() {
					client, err = rpc.Dial("tcp", "127.0.0.1:"+rpcService.Port())
					Expect(err).ToNot(HaveOccurred())

					var result string
					err = client.Call("CliRpcCmd.AccessToken", "", &result)
					Expect(err).ToNot(HaveOccurred())

					Expect(fakeAuthenticator.RefreshTokenCalled).To(BeTrue())
				})

				It("returns the access token", func() {
					fakeAuthenticator.RefreshToken = "fake-access-token"

					client, err = rpc.Dial("tcp", "127.0.0.1:"+rpcService.Port())
					Expect(err).ToNot(HaveOccurred())

					var result string
					err = client.Call("CliRpcCmd.AccessToken", "", &result)
					Expect(err).ToNot(HaveOccurred())
					Expect(result).To(Equal("fake-access-token"))
				})

				It("returns the error from refreshing the access token", func() {
					fakeAuthenticator.RefreshTokenError = errors.New("refresh error")

					client, err = rpc.Dial("tcp", "127.0.0.1:"+rpcService.Port())
					Expect(err).ToNot(HaveOccurred())
開發者ID:vframbach,項目名稱:cli,代碼行數:31,代碼來源:cli_rpc_server_test.go


注:本文中的github.com/cloudfoundry/cli/cf/api/fakes.FakeAuthenticationRepository.RefreshToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。