Exemple #1
0
				Flags = []string{"-p", "the-password"}
				ui.Inputs = []string{"api.example.com", "the-username", "the-account-number", "the-pin"}

				testcmd.RunCLICommand("login", Flags, nil, updateCommandDependency, false, ui)

				Expect(ui.PasswordPrompts).ToNot(ContainSubstrings([]string{"Your Password"}))
				Expect(authRepo.AuthenticateCallCount()).To(Equal(1))
				Expect(authRepo.AuthenticateArgsForCall(0)).To(Equal(map[string]string{
					"account_number": "the-account-number",
					"username":       "******",
					"password":       "******",
				}))
			})

			It("tries 3 times for the password-type prompts", func() {
				authRepo.AuthenticateReturns(errors.New("Error authenticating."))
				ui.Inputs = []string{"api.example.com", "the-username", "the-account-number",
					"the-password-1", "the-password-2", "the-password-3"}

				testcmd.RunCLICommand("login", Flags, nil, updateCommandDependency, false, ui)

				Expect(authRepo.AuthenticateCallCount()).To(Equal(3))
				Expect(authRepo.AuthenticateArgsForCall(0)).To(Equal(map[string]string{
					"username":       "******",
					"account_number": "the-account-number",
					"password":       "******",
				}))
				Expect(authRepo.AuthenticateArgsForCall(1)).To(Equal(map[string]string{
					"username":       "******",
					"account_number": "the-account-number",
					"password":       "******",