From 997c9f11dd508621cfe917164ca64e6f28013908 Mon Sep 17 00:00:00 2001 From: Gil Shapira Date: Mon, 28 Nov 2022 15:27:46 +0200 Subject: [PATCH] Ensure management key is set before passing through calls to management APIs --- descope/descope_client.py | 4 ++++ tests/test_descope_client.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/descope/descope_client.py b/descope/descope_client.py index d2868a59..7c8fcd73 100644 --- a/descope/descope_client.py +++ b/descope/descope_client.py @@ -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 diff --git a/tests/test_descope_client.py b/tests/test_descope_client.py index 83a21704..a436c19e 100644 --- a/tests/test_descope_client.py +++ b/tests/test_descope_client.py @@ -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)