Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/blackbox/s3_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,17 @@ def assert_get_access_point(request):
assert "/v20180820/accesspoint/" in request.path, (
f"GetAccessPoint: expected /v20180820/accesspoint/ in {request.path}"
)
assert (
request.headers.get("x-amz-account-id") is not None
), "GetAccessPoint: required header x-amz-account-id is missing"


def assert_get_caller_identity(request):
"""Assert request is an STS GetCallerIdentity (POST /)."""
assert request.method == "POST", (
f"GetCallerIdentity: expected POST, got {request.method}"
)
assert "Action=GetCallerIdentity" in request.body, (
f"GetCallerIdentity: expected Action=GetCallerIdentity in body, "
f"got {request.body!r}"
)
254 changes: 154 additions & 100 deletions tests/blackbox/test_cp_command.py

Large diffs are not rendered by default.

77 changes: 75 additions & 2 deletions tests/blackbox/test_ls_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
assert_list_buckets,
assert_list_objects_v2,
)

from tests.blackbox.utils import (
cli_env,
format_requests,
get_query_params,
list_objects_xml,
run_cli,
mock_server,
run_cli,
setup_responses,
xml_response,
)
Expand Down Expand Up @@ -572,3 +571,77 @@ async def test_list_objects_ignores_bucket_region(aws_cli: str) -> None:
req = server.requests[0]
params = get_query_params(req)
assert "bucket-region" not in params


@pytest.mark.asyncio
async def test_list_objects_with_unicode_keys(aws_cli):
"""ls handles objects with Unicode keys (CJK, emoji)."""
async with mock_server() as (server, proxy):
setup_responses(
server,
[
xml_response(
list_objects_xml(
contents=[
{
"Key": "文件.txt",
"Size": 100,
"LastModified": "2023-01-01T00:00:00Z",
},
{
"Key": "📄data.csv",
"Size": 200,
"LastModified": "2023-01-01T00:00:00Z",
},
]
)
),
],
)
stdout, stderr, rc = await run_cli(
aws_cli,
["s3", "ls", "s3://bucket/"],
cli_env(proxy),
)

assert rc == 0, stderr.decode()
output = stdout.decode()
assert "文件.txt" in output
assert "📄data.csv" in output


@pytest.mark.asyncio
async def test_list_objects_with_url_encoded_keys(aws_cli):
"""ls handles keys that S3 returns with URL encoding."""
async with mock_server() as (server, proxy):
setup_responses(
server,
[
xml_response(
list_objects_xml(
contents=[
{
"Key": "my+file.txt",
"Size": 100,
"LastModified": "2023-01-01T00:00:00Z",
},
{
"Key": "path/to/my%20doc.pdf",
"Size": 200,
"LastModified": "2023-01-01T00:00:00Z",
},
]
)
),
],
)
stdout, stderr, rc = await run_cli(
aws_cli,
["s3", "ls", "s3://bucket/"],
cli_env(proxy),
)

assert rc == 0, stderr.decode()
output = stdout.decode()
assert "my+file.txt" in output
assert "my%20doc.pdf" in output
34 changes: 29 additions & 5 deletions tests/blackbox/test_mb_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
from tests.blackbox.s3_assertions import (
assert_create_bucket,
)

from tests.blackbox.utils import (
cli_env,
create_bucket_response,
format_requests,
run_cli,
mock_server,
run_cli,
setup_responses,
)

Expand All @@ -39,9 +38,7 @@ async def test_make_bucket(self, aws_cli):
)
assert rc == 0, stderr.decode()
assert len(server.requests) == 1, format_requests(server)
assert_create_bucket(
server.requests[0], Bucket="bucket"
)
assert_create_bucket(server.requests[0], Bucket="bucket")

async def test_adds_location_constraint(self, aws_cli):
async with mock_server() as (server, proxy):
Expand Down Expand Up @@ -298,3 +295,30 @@ async def test_tags_with_three_arguments_fails(self, aws_cli):
assert rc == 252
assert len(server.requests) == 0, format_requests(server)
assert "ParamValidation" in stderr.decode()


@pytest.mark.asyncio
async def test_create_bucket_with_non_ascii_tag_value(aws_cli):
"""mb --tags with non-ASCII tag value sends correct XML body."""
async with mock_server() as (server, proxy):
setup_responses(server, [create_bucket_response()])
stdout, stderr, rc = await run_cli(
aws_cli,
[
"s3",
"mb",
"s3://bucket",
"--tags",
"Author",
"José García",
"--region",
"us-west-2",
],
cli_env(proxy),
)

assert rc == 0, stderr.decode()
req = server.requests[0]
assert (
"José" in req.body or "Jos" in req.body
), f"Expected non-ASCII tag value in body, got: {req.body[:200]}"
18 changes: 15 additions & 3 deletions tests/blackbox/test_mv_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -1348,7 +1348,11 @@ async def test_mv_works_if_access_point_arn_resolves_to_different_bucket(
assert_head_object(
server.requests[1], Bucket="bucket", Key="key"
)
assert_copy_object(server.requests[2])
assert_copy_object(
server.requests[2],
Bucket="arn:aws:s3:us-west-2:123456789012:accesspoint/myaccesspoint",
Key="key",
)
assert_delete_object(
server.requests[3], Bucket="bucket", Key="key"
)
Expand Down Expand Up @@ -1390,7 +1394,11 @@ async def test_mv_works_if_access_point_alias_resolves_to_different_bucket(
assert_head_object(
server.requests[2], Bucket="bucket", Key="key"
)
assert_copy_object(server.requests[3])
assert_copy_object(
server.requests[3],
Bucket="myaccesspoint-foobar-s3alias",
Key="key",
)
assert_delete_object(
server.requests[4], Bucket="bucket", Key="key"
)
Expand Down Expand Up @@ -1430,7 +1438,11 @@ async def test_mv_works_if_outpost_access_point_arn_resolves_to_different_bucket
assert_head_object(
server.requests[1], Bucket="bucket", Key="key"
)
assert_copy_object(server.requests[2])
assert_copy_object(
server.requests[2],
Bucket="arn:aws:s3-outposts:us-east-1:123456789012:outpost/op-foobar/accesspoint/myaccesspoint",
Key="key",
)
assert_delete_object(
server.requests[3], Bucket="bucket", Key="key"
)
Expand Down
Loading
Loading