Пример #1
0
		})

		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"}))
Пример #2
0
		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"},
Пример #3
0
			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"},
				))
Пример #4
0
				Ω(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"
Пример #5
0
				})

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