Exemple #1
0
			config.SetMinCLIVersion("5.0.0")
			config.SetMinRecommendedCLIVersion("5.5.0")
			cf.Version = "4.5.0"

			testcmd.RunCLICommand("auth", []string{"*****@*****.**", "password"}, requirementsFactory, updateCommandDependency, false, ui)

			Expect(ui.Outputs()).To(ContainSubstrings(
				[]string{"To upgrade your CLI"},
				[]string{"5.0.0"},
			))
		})

		It("gets the UAA endpoint and saves it to the config file", func() {
			requirementsFactory.NewAPIEndpointRequirementReturns(requirements.Passing{})
			testcmd.RunCLICommand("auth", []string{"*****@*****.**", "password"}, requirementsFactory, updateCommandDependency, false, ui)
			Expect(authRepo.GetLoginPromptsAndSaveUAAServerURLCallCount()).To(Equal(1))
		})

		Describe("when authentication fails", func() {
			BeforeEach(func() {
				authRepo.AuthenticateReturns(errors.New("Error authenticating."))
				testcmd.RunCLICommand("auth", []string{"username", "password"}, requirementsFactory, updateCommandDependency, false, ui)
			})

			It("does not prompt the user when provided username and password", func() {
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{config.APIEndpoint()},
					[]string{"Authenticating..."},
					[]string{"FAILED"},
					[]string{"Error authenticating"},
				))