diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9b52c46503..08f840ea26 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -28,6 +28,8 @@ Fixed * Update ``st2-pack-install`` and ``st2 pack install`` command so it works with local git repos (``file://``) which are in a detached head state (e.g. specific revision is checked out). (improvement) #4366 +* st2 login now exits with non zero exit code when login fails due to invalid credentials. + (improvement) #4338 2.9.0 - September 16, 2018 -------------------------- diff --git a/st2client/st2client/commands/auth.py b/st2client/st2client/commands/auth.py index 7c4489e545..438ed0296b 100644 --- a/st2client/st2client/commands/auth.py +++ b/st2client/st2client/commands/auth.py @@ -152,11 +152,10 @@ def run_and_print(self, args, **kwargs): try: self.run(args, **kwargs) except Exception as e: - print('Failed to log in as %s: %s' % (args.username, str(e))) if self.app.client.debug: raise - return + raise Exception('Failed to log in as %s: %s' % (args.username, str(e))) print('Logged in as %s' % (args.username)) diff --git a/st2client/tests/unit/test_auth.py b/st2client/tests/unit/test_auth.py index d2e49c100f..8d82518b56 100644 --- a/st2client/tests/unit/test_auth.py +++ b/st2client/tests/unit/test_auth.py @@ -289,7 +289,7 @@ def runTest(self, mock_gp): self.assertTrue('Failed to log in as %s' % expected_username in self.stdout.getvalue()) self.assertTrue('Logged in as' not in self.stdout.getvalue()) - self.assertEqual(retcode, 0) + self.assertEqual(retcode, 1) class TestAuthToken(base.BaseCLITestCase):