Skip to content

Commit

Permalink
Resolve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Jan 22, 2024
1 parent 915edd2 commit 7893d17
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
5 changes: 3 additions & 2 deletions fence/blueprints/data/indexd.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,9 @@ def init_multipart_upload(key, expires_in=None, bucket=None):
Returns:
uploadId(str)
"""
bucket = bucket or flask.current_app.config["DATA_UPLOAD_BUCKET"]
if not bucket:
try:
bucket = bucket or flask.current_app.config["DATA_UPLOAD_BUCKET"]
except KeyError:
raise InternalError(
"fence not configured with data upload bucket; can't create signed URL"
)
Expand Down
20 changes: 9 additions & 11 deletions fence/resources/aws/boto_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,28 @@ class BotoManager(object):
)

def __init__(self, config, buckets, logger):
self.sts_client = client("sts", **config)
self.s3_client = client("s3", **config)
default = list(config.values())[0]
self.sts_client = client("sts", **default)
self.s3_client = client("s3", **default)
self.s3_clients = self.create_s3_clients(config, buckets)
self.logger = logger
self.ec2 = None
self.iam = None

def create_s3_clients(self, config, buckets):
s3_clients = {}
for creds in config:
if config[creds]['aws'] == 'true':
s3_clients = {'default': self.s3_client}
s3_clients = {'default': self.s3_client}

for bucket in buckets:
cred_name = buckets[bucket]['cred']
keys = config[cred_name]
if 'aws' in keys:
keys.pop('aws')
creds = {}
if cred_name != '*':
creds = config[cred_name]

if 'endpoint_url' in buckets[bucket]:
endpoint_url = buckets[bucket]['endpoint_url']
s3_clients[bucket] = client('s3', **keys, endpoint_url=endpoint_url)
s3_clients[bucket] = client('s3', **creds, endpoint_url=endpoint_url)
else:
s3_clients[bucket] = client('s3', **keys)
s3_clients[bucket] = client('s3', **creds)
return s3_clients

def get_s3_client(self, bucket):
Expand Down

0 comments on commit 7893d17

Please sign in to comment.