当前位置: 首页>>代码示例>>Golang>>正文


Golang FakeAuthenticationRepository.RefreshTokenError方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/api/fakes.FakeAuthenticationRepository.RefreshTokenError方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeAuthenticationRepository.RefreshTokenError方法的具体用法?Golang FakeAuthenticationRepository.RefreshTokenError怎么用?Golang FakeAuthenticationRepository.RefreshTokenError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/cli/cf/api/fakes.FakeAuthenticationRepository的用法示例。


在下文中一共展示了FakeAuthenticationRepository.RefreshTokenError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

		})

		Context("when the default route for the app does not exist", func() {
			BeforeEach(func() {
				routeRepo.FindByHostAndDomainReturns.Error = errors.NewModelNotFoundError("Org", "couldn't find it")
			})

			It("refreshes the auth token (so fresh)", func() { // so clean
				callPush("fresh-prince")

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

			Context("when refreshing the auth token fails", func() {
				BeforeEach(func() {
					authRepo.RefreshTokenError = errors.New("I accidentally the UAA")
				})

				It("it displays an error", func() {
					callPush("of-bel-air")

					Expect(ui.Outputs).To(ContainSubstrings(
						[]string{"FAILED"},
						[]string{"accidentally the UAA"},
					))
				})
			})

			It("creates an app", func() {
				callPush("-t", "111", "my-new-app")
				Expect(ui.Outputs).ToNot(ContainSubstrings([]string{"FAILED"}))
开发者ID:matanzit,项目名称:cli,代码行数:31,代码来源:push_test.go

示例2:

		return testcmd.RunCommand(cmd, []string{}, requirementsFactory)
	}

	Describe("requirments", func() {
		It("fails when the user is not logged in", func() {
			Expect(runCommand()).ToNot(HavePassedRequirements())
		})
	})

	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"},
开发者ID:tools-alexuser01,项目名称:cli,代码行数:31,代码来源:oauth_token_test.go

示例3:

			actor.FilterBrokersReturns([]models.ServiceBroker{
				serviceBroker1,
				serviceBroker2,
			},
				nil,
			)
		})

		It("refreshes the auth token", func() {
			runCommand()
			Expect(tokenRefresher.RefreshTokenCalled).To(BeTrue())
		})

		Context("when refreshing the auth token fails", func() {
			It("fails and returns the error", func() {
				tokenRefresher.RefreshTokenError = errors.New("Refreshing went wrong")
				runCommand()

				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Refreshing went wrong"},
					[]string{"FAILED"},
				))
			})
		})

		Context("When no flags are provided", func() {
			It("tells the user it is obtaining the service access", func() {
				runCommand()
				Expect(ui.Outputs).To(ContainSubstrings(
					[]string{"Getting service access as", "my-user"},
				))
开发者ID:tools-alexuser01,项目名称:cli,代码行数:31,代码来源:service_access_test.go

示例4:

				Ω(endpointRepo.CallCount).To(Equal(1))
				Ω(ui.Outputs).To(ContainSubstrings(
					[]string{"Error getting info", "endpoint error"},
				))
			})
		})

		Context("refresh oauth-token to make sure it is not stale", func() {
			It("refreshes the oauth token to make sure it is not stale", func() {
				runCommand()
				Ω(authRepo.RefreshTokenCalled).To(BeTrue())
			})

			Context("when refreshing fails", func() {
				It("refreshes the oauth token to make sure it is not stale", func() {
					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"
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:ssh_code_test.go

示例5:

				})

				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())

					var result string
					err = client.Call("CliRpcCmd.AccessToken", "", &result)
					Expect(err.Error()).To(Equal("refresh error"))
				})
			})

		})

		Context("fail", func() {
			BeforeEach(func() {
				outputCapture := terminal.NewTeePrinter()
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:cli_rpc_server_test.go


注:本文中的github.com/cloudfoundry/cli/cf/api/fakes.FakeAuthenticationRepository.RefreshTokenError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。