From e789ef155f68add3b5e71586bf4701b927f6d277 Mon Sep 17 00:00:00 2001 From: Rohan Weeden Date: Mon, 12 Dec 2022 14:04:36 -0900 Subject: [PATCH] Change s3credential response to use camelCase keys --- docs/s3access.md | 14 +++++++------- lambda/app.py | 7 +++++++ tests/test_app.py | 8 ++++---- tests_e2e/test_s3credentials.py | 8 ++++---- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/docs/s3access.md b/docs/s3access.md index ad5d6d42..fc441e81 100644 --- a/docs/s3access.md +++ b/docs/s3access.md @@ -48,10 +48,10 @@ The response is your temporary credentials as returned by Amazon STS. See the **Example:** ```json { - "AccessKeyId": "AKIAIOSFODNN7EXAMPLE", - "SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", - "SessionToken": "LONGSTRINGOFCHARACTERS.../HJLgV91QJFCMlmY8slIEOjrOChLQYmzAqrb5U1ekoQAK6f86HKJFTT2dONzPgmJN9ZvW5DBwt6XUxC9HAQ0LDPEYEwbjGVKkzSNQh/", - "Expiration": "2021-01-27 00:50:09+00:00" + "accessKeyId": "AKIAIOSFODNN7EXAMPLE", + "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + "sessionToken": "LONGSTRINGOFCHARACTERS.../HJLgV91QJFCMlmY8slIEOjrOChLQYmzAqrb5U1ekoQAK6f86HKJFTT2dONzPgmJN9ZvW5DBwt6XUxC9HAQ0LDPEYEwbjGVKkzSNQh/", + "expiration": "2021-01-27 00:50:09+00:00" } ``` @@ -94,9 +94,9 @@ def lambda_handler(event, context): # Set up separate boto3 clients for download and upload download_client = boto3.client( "s3", - aws_access_key_id=creds["AccessKeyId"], - aws_secret_access_key=creds["SecretAccessKey"], - aws_session_token=creds["SessionToken"] + aws_access_key_id=creds["accessKeyId"], + aws_secret_access_key=creds["secretAccessKey"], + aws_session_token=creds["sessionToken"] ) # Lambda needs to have permission to upload to destination bucket upload_client = boto3.client("s3") diff --git a/lambda/app.py b/lambda/app.py index c5fe411e..ec317326 100644 --- a/lambda/app.py +++ b/lambda/app.py @@ -1008,6 +1008,13 @@ def s3credentials(): creds = get_s3_credentials(user_profile.user_id, role_session_name, policy) timer.mark() + creds = { + "accessKeyId": creds["AccessKeyId"], + "secretAccessKey": creds["SecretAccessKey"], + "sessionToken": creds["SessionToken"], + "expiration": creds["Expiration"] + } + log.debug("timing for s3credentials()") timer.log_all(log) diff --git a/tests/test_app.py b/tests/test_app.py index d659941c..f96656c9 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1430,10 +1430,10 @@ def test_s3credentials( response = client.http.get("/s3credentials") assert response.json_body == { - "AccessKeyId": "access_key", - "SecretAccessKey": "secret_access_key", - "SessionToken": "session_token", - "Expiration": "expiration" + "accessKeyId": "access_key", + "secretAccessKey": "secret_access_key", + "sessionToken": "session_token", + "expiration": "expiration" } assert response.status_code == 200 diff --git a/tests_e2e/test_s3credentials.py b/tests_e2e/test_s3credentials.py index dad281d3..5a627940 100644 --- a/tests_e2e/test_s3credentials.py +++ b/tests_e2e/test_s3credentials.py @@ -17,8 +17,8 @@ def test_authenticated_user_can_get_creds(urls, auth_cookies): assert r.status_code == 200 assert list(data.keys()) == [ - "AccessKeyId", - "SecretAccessKey", - "SessionToken", - "Expiration" + "accessKeyId", + "secretAccessKey", + "sessionToken", + "expiration" ]