Ejemplo n.º 1
0
				{
					"username": "******",
					"password": "******",
				},
			}))
		})

		It("gets the UAA endpoint and saves it to the config file", func() {
			requirementsFactory.ApiEndpointSuccess = true
			testcmd.RunCommand(cmd, testcmd.NewContext("auth", []string{"*****@*****.**", "password"}), requirementsFactory)
			Expect(repo.GetLoginPromptsWasCalled).To(BeTrue())
		})

		Describe("when authentication fails", func() {
			BeforeEach(func() {
				repo.AuthError = true
				testcmd.RunCommand(cmd, testcmd.NewContext("auth", []string{"username", "password"}), requirementsFactory)
			})

			It("does not prompt the user when provided username and password", func() {
				testassert.SliceContains(ui.Outputs, testassert.Lines{
					{config.ApiEndpoint()},
					{"Authenticating..."},
					{"FAILED"},
					{"Error authenticating"},
				})
			})

			It("clears the user's session", func() {
				Expect(config.AccessToken()).To(BeEmpty())
				Expect(config.RefreshToken()).To(BeEmpty())
Ejemplo n.º 2
0
				testassert.SliceDoesNotContain(ui.PasswordPrompts, testassert.Lines{
					{"Your Password>"},
				})

				Expect(authRepo.AuthenticateArgs.Credentials).To(Equal([]map[string]string{
					{
						"account_number":    "the-account-number",
						"department_number": "the-department-number",
						"pin":               "the-pin",
						"password":          "******",
					},
				}))
			})

			It("tries 3 times for the password-type prompts", func() {
				authRepo.AuthError = true
				ui.Inputs = []string{"api.example.com", "the-account-number", "the-department-number",
					"the-pin-1", "the-password-1",
					"the-pin-2", "the-password-2",
					"the-pin-3", "the-password-3"}

				l := NewLogin(ui, Config, authRepo, endpointRepo, orgRepo, spaceRepo)
				testcmd.RunCommand(l, testcmd.NewContext("login", Flags), nil)

				Expect(authRepo.AuthenticateArgs.Credentials).To(Equal([]map[string]string{
					{
						"account_number":    "the-account-number",
						"department_number": "the-department-number",
						"pin":               "the-pin-1",
						"password":          "******",
					},