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

Commit

Permalink
Refactor object_store.drivers.swift.SwiftObjectStorageDriver._check_c…
Browse files Browse the repository at this point in the history
…reds (#1140)

It is possible on errors for the error response object to not contain
an `http_status` attribute, so refactor the error handler so that
this attribute is not required.

There appear to be no unit tests for these, so no tests are provided.

Signed-off-by: Nicolas Simonds <nisimond@cisco.com>
  • Loading branch information
0xDEC0DE committed Jul 28, 2021
1 parent d25f708 commit 433df68
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions anchore_engine/subsys/object_store/drivers/swift.py
Expand Up @@ -70,12 +70,13 @@ def _check_creds(self):
resp = self.client.stat()
if resp["success"]:
return True
elif resp.get("error") and resp.get("error").http_status in [401, 403]:
raise BadCredentialsError(
self.auth_options, endpoint=None, cause=resp.get("error")
)
elif resp.get("error"):
raise DriverConfigurationError(cause=resp.get("error"))
error = resp.get("error")
if getattr(error, "http_status", None) in [401, 403]:
raise BadCredentialsError(
self.auth_options, endpoint=None, cause=error
)
raise DriverConfigurationError(cause=error)
else:
raise DriverConfigurationError(
Exception(
Expand Down

0 comments on commit 433df68

Please sign in to comment.