Skip to content

Commit 6ce4400

Browse files
committed
fix: If there is no case-specfic shared key token, return the original sumoclient instance.
1 parent 9502bbd commit 6ce4400

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/sumo/wrapper/_auth_provider.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ def store_shared_access_key_for_case(self, case_uuid, token):
9292
f.write(token)
9393
protect_token_cache(self._resource_id, ".sharedkey", case_uuid)
9494

95+
def has_case_token(self, case_uuid):
96+
return os.path.exists(
97+
get_token_path(self._resource_id, ".sharedkey", case_uuid)
98+
)
99+
95100
pass
96101

97102

src/sumo/wrapper/sumo_client.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -424,13 +424,16 @@ def create_shared_access_key_for_case(self, case_uuid):
424424
def client_for_case(self, case_uuid):
425425
"""Instantiate and return new SumoClient for accessing the
426426
case identified by *case_uuid*."""
427-
return SumoClient(
428-
env=self.env,
429-
verbosity=self._verbosity,
430-
retry_strategy=self._retry_strategy,
431-
timeout=self._timeout,
432-
case_uuid=case_uuid,
433-
)
427+
if self.auth.has_case_token(case_uuid):
428+
return SumoClient(
429+
env=self.env,
430+
verbosity=self._verbosity,
431+
retry_strategy=self._retry_strategy,
432+
timeout=self._timeout,
433+
case_uuid=case_uuid,
434+
)
435+
else:
436+
return self
434437

435438
@raise_for_status_async
436439
async def get_async(self, path: str, params: dict = None):

0 commit comments

Comments
 (0)