當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。