From e23fe481ace1e720ffc06fba06e56246781050a7 Mon Sep 17 00:00:00 2001 From: Lakshmi Kannan Date: Fri, 12 Oct 2018 11:15:37 -0400 Subject: [PATCH 1/3] Exit with exit code 1 when st2 login fails --- st2client/st2client/commands/auth.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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)) From 374ea6ad1300bd3aacc3f2cf56dbb22e57748640 Mon Sep 17 00:00:00 2001 From: Lakshmi Kannan Date: Fri, 12 Oct 2018 11:21:33 -0400 Subject: [PATCH 2/3] Update CHANGELOG --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) 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 -------------------------- From ea3c3c02d0efd36d3160126583cd64a9bda48b0f Mon Sep 17 00:00:00 2001 From: Lakshmi Kannan Date: Fri, 12 Oct 2018 12:03:08 -0400 Subject: [PATCH 3/3] Fix test_auth to look for exit code 1 on login failure --- st2client/tests/unit/test_auth.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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):