Skip to content

Commit

Permalink
Add end-to-end signature check test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Vasin committed May 6, 2024
1 parent e75d957 commit fecbd83
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ freezegun = "^1.5.0"
pytest = "^7.4.4"
setuptools = "^69.5.1"
pytest-aiohttp = "^1.0.5"
yarl = "^1.9.4"

[build-system]
requires = ["poetry-core"]
Expand Down
19 changes: 19 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from pathlib import Path

import pytest
from freezegun import freeze_time
from yarl import URL

from aiohttp_s3_client import S3Client

Expand Down Expand Up @@ -138,3 +140,20 @@ async def async_iterable(iterable: bytes):
# FIXME: uncomment after update fakes3 image
actual = gzip.GzipFile(fileobj=BytesIO(result)).read()
assert actual == data


@freeze_time("2024-01-01")
def test_presign_url(s3_client, s3_url):
url = s3_client.presign_url('get', URL('./example'))
assert url.path == (s3_url / 'example').path
assert url.query == {
'X-Amz-Algorithm': 'AWS4-HMAC-SHA256',
'X-Amz-Content-Sha256': 'UNSIGNED-PAYLOAD',
'X-Amz-Credential': 'user/20240101/us-east-1/s3/aws4_request',
'X-Amz-Date': '20240101T000000Z',
'X-Amz-Expires': '86400',
'X-Amz-SignedHeaders': 'host',
'X-Amz-Signature': (
'7359f1286edf554b0eab363e3c93ee32855b8d429d975fdb0a5d2cb7ad5c0db0'
)
}

0 comments on commit fecbd83

Please sign in to comment.