ugh secrets

This commit is contained in:
Kenneth Kehl
2024-08-13 15:32:43 -07:00
parent 76c02a1507
commit db9197e7a6
2 changed files with 18 additions and 2 deletions

View File

@@ -209,7 +209,7 @@
"filename": "tests/app/aws/test_s3.py", "filename": "tests/app/aws/test_s3.py",
"hashed_secret": "67a74306b06d0c01624fe0d0249a570f4d093747", "hashed_secret": "67a74306b06d0c01624fe0d0249a570f4d093747",
"is_verified": false, "is_verified": false,
"line_number": 24, "line_number": 25,
"is_secret": false "is_secret": false
} }
], ],
@@ -384,5 +384,5 @@
} }
] ]
}, },
"generated_at": "2024-08-01T17:38:39Z" "generated_at": "2024-08-13T22:32:28Z"
} }

View File

@@ -6,6 +6,7 @@ from botocore.exceptions import ClientError
from app.aws.s3 import ( from app.aws.s3 import (
file_exists, file_exists,
get_job_from_s3,
get_personalisation_from_s3, get_personalisation_from_s3,
get_phone_number_from_s3, get_phone_number_from_s3,
get_s3_file, get_s3_file,
@@ -86,6 +87,21 @@ def test_get_phone_number_from_s3(
phone_number = get_phone_number_from_s3("service_id", job_id, job_row_number) phone_number = get_phone_number_from_s3("service_id", job_id, job_row_number)
assert phone_number == expected_phone_number assert phone_number == expected_phone_number
def mock_s3_get_object_slowdown(*args, **kwargs):
error_response = {
'Error': {
'Code': 'SlowDown',
'Message': 'Reduce your request rate',
}
}
raise ClientError(error_response, 'GetObject')
def test_get_job_from_s3_exponential_backoff(mocker):
get_s3_object = mocker.patch("app.aws.s3.get_s3_object", side_effect=mock_s3_get_object_slowdown)
with pytest.raises(Exception) as exc_info:
job = get_job_from_s3("service_id", "job_id")
assert 'Failed to get object after 5 attempts' in str(exc_info)
@pytest.mark.parametrize( @pytest.mark.parametrize(
"job, job_id, job_row_number, expected_personalisation", "job, job_id, job_row_number, expected_personalisation",