Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
DX-1282 Swallow all basic exception (#36)
Browse files Browse the repository at this point in the history
DX-1282 Swallow all basic exception
  • Loading branch information
zachary-nextdoor authored Dec 22, 2021
1 parent 55a9b04 commit 6d27fe6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
10 changes: 4 additions & 6 deletions nd_okta_auth/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
2 changes: 1 addition & 1 deletion nd_okta_auth/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# Copyright 2017 Nextdoor.com, Inc


__version__ = "1.0.4"
__version__ = "1.0.5"
__desc__ = "Nextdoor Okta Auther"
22 changes: 4 additions & 18 deletions nd_okta_auth/test/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

0 comments on commit 6d27fe6

Please sign in to comment.