当前位置: 首页>>代码示例>>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;未经允许,请勿转载。