diff --git a/command/v7/auth_command.go b/command/v7/auth_command.go index b2fd9e12c89..c64d604a072 100644 --- a/command/v7/auth_command.go +++ b/command/v7/auth_command.go @@ -118,11 +118,18 @@ func (cmd AuthCommand) getUsernamePassword() (string, string, error) { if password == "" { if envPassword := cmd.Config.CFPassword(); envPassword != "" { password = envPassword - } else if !cmd.Config.IsCFOnK8s() { + } else { passwordMissing = true } } + if cmd.Config.IsCFOnK8s() { + if !passwordMissing { + cmd.UI.DisplayWarning("Warning: password is ignored when authenticating against Kubernetes.") + } + passwordMissing = false + } + if userMissing || passwordMissing { return "", "", translatableerror.MissingCredentialsError{ MissingUsername: userMissing, diff --git a/command/v7/auth_command_test.go b/command/v7/auth_command_test.go index 7b7d595fc03..c30ac594a48 100644 --- a/command/v7/auth_command_test.go +++ b/command/v7/auth_command_test.go @@ -124,6 +124,24 @@ var _ = Describe("auth Command", func() { }) }) }) + + When("the password is given", func() { + BeforeEach(func() { + cmd.RequiredArgs.Username = "myuser" + cmd.RequiredArgs.Password = "mypassword" + }) + + When("authenticating against korifi", func() { + BeforeEach(func() { + fakeConfig.IsCFOnK8sReturns(true) + }) + + It("succeeds but warns", func() { + Expect(err).NotTo(HaveOccurred()) + Expect(testUI.Err).To(Say("Warning: password is ignored when authenticating against Kubernetes.")) + }) + }) + }) }) When("there is an auth error", func() {