Skip to content

Commit

Permalink
chore: rollback fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
JBOClara committed Dec 20, 2023
1 parent 8ce9bf2 commit 2a0afe0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
1 change: 0 additions & 1 deletion medusa/storage/s3_base_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ def _consolidate_credentials(config) -> CensoredCredentials:
session.set_config_variable('credentials_file', config.key_file)

boto_credentials = session.get_credentials()

return CensoredCredentials(
access_key_id=boto_credentials.access_key,
secret_access_key=boto_credentials.secret_key,
Expand Down
54 changes: 26 additions & 28 deletions tests/storage/s3_storage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ def test_credentials_from_metadata(self):
self.assertIsNone(os.environ.get("AWS_PROFILE", None))

config = AttributeDict({
"api_profile": None,
"region": "region-from-config",
"storage_provider": "s3_us_west_oregon",
"key_file": empty_file.name,
"concurrent_transfers": "1",
'api_profile': None,
'region': 'region-from-config',
'storage_provider': 's3_us_west_oregon',
'key_file': empty_file.name,
'concurrent_transfers': '1',
})

credentials = S3BaseStorage._consolidate_credentials(config)
self.assertEqual("key-from-instance-metadata", credentials.access_key_id)
self.assertEqual("region-from-config", credentials.region)
self.assertEqual('key-from-instance-metadata', credentials.access_key_id)
self.assertEqual('region-from-config', credentials.region)

def test_credentials_from_env_without_profile(self):
with tempfile.NamedTemporaryFile() as empty_file:
Expand All @@ -80,19 +80,19 @@ def test_credentials_from_env_without_profile(self):
os.environ["AWS_SECRET_ACCESS_KEY"] = "secret-from-env"

config = AttributeDict({
"api_profile": None,
"region": "region-from-config",
"storage_provider": "s3_us_west_oregon",
"key_file": empty_file.name,
"concurrent_transfers": "1",
})
'api_profile': None,
'region': 'region-from-config',
'storage_provider': 's3_us_west_oregon',
'key_file': empty_file.name,
'concurrent_transfers': '1'
})

credentials = S3BaseStorage._consolidate_credentials(config)
self.assertEqual("key-from-env", credentials.access_key_id)
self.assertEqual("region-from-config", credentials.region)
self.assertEqual('key-from-env', credentials.access_key_id)
self.assertEqual('region-from-config', credentials.region)

del os.environ["AWS_ACCESS_KEY_ID"]
del os.environ["AWS_SECRET_ACCESS_KEY"]
del os.environ['AWS_ACCESS_KEY_ID']
del os.environ['AWS_SECRET_ACCESS_KEY']

def test_credentials_from_file(self):
credentials_file_content = """
Expand All @@ -108,19 +108,17 @@ def test_credentials_from_file(self):
self.assertIsNone(os.environ.get("AWS_ACCESS_KEY_ID", None))
self.assertIsNone(os.environ.get("AWS_SECRET_ACCESS_KEY", None))

config = AttributeDict(
{
"api_profile": "default",
"region": "region-from-config",
"storage_provider": "s3_us_west_oregon",
"key_file": credentials_file.name,
"concurrent_transfers": "1",
}
)
config = AttributeDict({
'api_profile': 'default',
'region': 'region-from-config',
'storage_provider': 's3_us_west_oregon',
'key_file': credentials_file.name,
'concurrent_transfers': '1'
})

credentials = S3BaseStorage._consolidate_credentials(config)
self.assertEqual("key-from-file", credentials.access_key_id)
self.assertEqual("region-from-config", credentials.region)
self.assertEqual('key-from-file', credentials.access_key_id)
self.assertEqual('region-from-config', credentials.region)

def test_credentials_from_everything(self):
credentials_file_content = """
Expand Down

0 comments on commit 2a0afe0

Please sign in to comment.