Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
check hashing on both creds classes
Browse files Browse the repository at this point in the history
  • Loading branch information
zzstoatzz committed Jan 19, 2024
1 parent 95df7a0 commit 1fde31e
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tests/test_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,34 @@ def test_minio_credentials_change_causes_cache_miss(client_type):
assert _get_client_cached.cache_info().misses == 2, "Cache should miss twice"


def test_aws_credentials_hash_changes():
credentials = AwsCredentials(region_name="us-east-1")
@pytest.mark.parametrize(
"credentials_type, initial_field, new_field",
[
(
AwsCredentials,
{"region_name": "us-east-1"},
{"region_name": "us-east-2"},
),
(
MinIOCredentials,
{
"region_name": "us-east-1",
"minio_root_user": "root_user",
"minio_root_password": "root_password",
},
{
"region_name": "us-east-2",
"minio_root_user": "root_user",
"minio_root_password": "root_password",
},
),
],
)
def test_aws_credentials_hash_changes(credentials_type, initial_field, new_field):
credentials = credentials_type(**initial_field)
initial_hash = hash(credentials)

credentials.region_name = "us-west-2"
setattr(credentials, list(new_field.keys())[0], list(new_field.values())[0])
new_hash = hash(credentials)

assert initial_hash != new_hash, "Hash should change when region_name changes"

0 comments on commit 1fde31e

Please sign in to comment.