Skip to content

Commit

Permalink
fix: If there is no case-specfic shared key token, return the origina…
Browse files Browse the repository at this point in the history
…l sumoclient instance.
  • Loading branch information
rwiker committed Dec 20, 2024
1 parent 9502bbd commit 6ce4400
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/sumo/wrapper/_auth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def store_shared_access_key_for_case(self, case_uuid, token):
f.write(token)
protect_token_cache(self._resource_id, ".sharedkey", case_uuid)

def has_case_token(self, case_uuid):
return os.path.exists(
get_token_path(self._resource_id, ".sharedkey", case_uuid)
)

pass


Expand Down
17 changes: 10 additions & 7 deletions src/sumo/wrapper/sumo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,16 @@ def create_shared_access_key_for_case(self, case_uuid):
def client_for_case(self, case_uuid):
"""Instantiate and return new SumoClient for accessing the
case identified by *case_uuid*."""
return SumoClient(
env=self.env,
verbosity=self._verbosity,
retry_strategy=self._retry_strategy,
timeout=self._timeout,
case_uuid=case_uuid,
)
if self.auth.has_case_token(case_uuid):
return SumoClient(
env=self.env,
verbosity=self._verbosity,
retry_strategy=self._retry_strategy,
timeout=self._timeout,
case_uuid=case_uuid,
)
else:
return self

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

0 comments on commit 6ce4400

Please sign in to comment.