Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure management key is set before passing calls to management APIs #90

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions descope/descope_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def __init__(

@property
def mgmt(self):
if not self._auth.management_key:
raise AuthException(
400, ERROR_TYPE_INVALID_ARGUMENT, "management_key cannot be empty"
)
return self._mgmt

@property
Expand Down
4 changes: 4 additions & 0 deletions tests/test_descope_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def test_descope_client(self):
DescopeClient(project_id="dummy", public_key=self.public_key_str)
)

def test_mgmt(self):
client = DescopeClient(self.dummy_project_id, self.public_key_dict)
self.assertRaises(AuthException, lambda: client.mgmt)

def test_logout(self):
dummy_refresh_token = ""
client = DescopeClient(self.dummy_project_id, self.public_key_dict)
Expand Down