diff --git a/nd_okta_auth/main.py b/nd_okta_auth/main.py index 73fc235..d02e73b 100644 --- a/nd_okta_auth/main.py +++ b/nd_okta_auth/main.py @@ -113,7 +113,7 @@ def get_config_parser(argv): def entry_point(): """Zero-argument entry point for use with setuptools/distribute.""" config = get_config_parser(sys.argv) - raise base_client.BaseException( + try: auth.login( aws_profile=config.name, okta_appid=config.appid, @@ -122,11 +122,9 @@ def entry_point(): reup=config.reup, debug=config.debug, ) - ) + except base_client.BaseException: + sys.exit(1) if __name__ == "__main__": - try: - entry_point() - except base_client.BaseException: - sys.exit(1) + entry_point() diff --git a/nd_okta_auth/metadata.py b/nd_okta_auth/metadata.py index 59fdd9b..12955f2 100644 --- a/nd_okta_auth/metadata.py +++ b/nd_okta_auth/metadata.py @@ -13,5 +13,5 @@ # Copyright 2017 Nextdoor.com, Inc -__version__ = "1.0.4" +__version__ = "1.0.5" __desc__ = "Nextdoor Okta Auther" diff --git a/nd_okta_auth/test/main_test.py b/nd_okta_auth/test/main_test.py index 94f0419..bf79758 100644 --- a/nd_okta_auth/test/main_test.py +++ b/nd_okta_auth/test/main_test.py @@ -27,24 +27,10 @@ def test_get_config_parser(self): @mock.patch("nd_okta_auth.auth.login") @mock.patch("nd_okta_auth.main.get_config_parser") def test_entry_point(self, config_mock, auth_login): - # Give + # Given fake_parser = mock.MagicMock(name="fake_parser") - fake_parser.name = "eng" - fake_parser.org = "org" - fake_parser.appid = "appid" - fake_parser.username = "username" - fake_parser.debug = True - fake_parser.reup = False config_mock.return_value = fake_parser - # When - with self.assertRaises(base_client.BaseException): + auth_login.side_effect = base_client.BaseException() + # Except + with self.assertRaises(SystemExit): main.entry_point() - # Then - auth_login.assert_called_with( - aws_profile="eng", - okta_appid="appid", - okta_org="org", - username="username", - reup=False, - debug=True, - )