Files
floci/compatibility-tests/sdk-test-awscli/test/cloudfront.bats
T
Alex Banna 520c0f4da2 feat(cloudfront): apply response-headers policies when serving (#1833)
* feat(cloudfront): serve distribution requests from S3 and custom origins

* feat(cloudfront): add response headers policy support

* chore: re-run CI

The Build and Test failure on the previous head was RuntimeApiServerTest's
extension/stop race, a pre-existing flake unrelated to this change — it also failed
on #1820, #1823 and on #2131's own branch (the PR that tried to de-flake it).
Reproduced locally under `--cpus=1` and fixed separately.

* fix(cloudfront): wildcard aliases match exactly one subdomain level

wildcardAliasMatches did a plain suffix check, so "*.example.com" also matched
a.b.example.com. AWS is explicit that a wildcard alternate domain name replaces the
wildcard at that level only:

  "you can't add alternate domain names that are at levels higher or lower than the
   wildcard. For example, you can't add the alternate domain names example.com or
   marketing.product.example.com."

  https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html

Practical effect: a distribution owning "*.example.com" would answer for
a.b.example.com, which on AWS belongs to whoever owns "*.b.example.com" — or to
nobody. Require the label standing in for the wildcard to contain no dot.

wildcardAliasesMatchSubdomainsAndPreferMoreSpecificNames asserted the old behaviour
(a.b.example.test resolving to the *.example.test distribution); it now asserts no
match, plus the same for a deeper wildcard.

* test(dynamodb): retain Quarkus port for cleanup

* fix(cloudfront): isolate mocked storage backends

* fix: validate credentialed CloudFront CORS headers

* fix: log ignored CloudFront policy parse errors

* fix(ec2): wire managed prefix list storage in public IP test

* fix(cloudfront): preserve custom CORS-like headers
2026-08-20 18:06:12 -04:00

40 lines
1.4 KiB
Bash

#!/usr/bin/env bats
# CloudFront AWS CLI compatibility tests
setup() {
load 'test_helper/common-setup'
}
@test "CloudFront: list response headers policies decodes the modeled payload" {
run aws_cmd cloudfront list-response-headers-policies \
--type managed \
--max-items 1 \
--no-paginate
assert_success
[ "$(json_get "$output" '.ResponseHeadersPolicyList.Quantity')" = "1" ]
[ "$(json_get "$output" '.ResponseHeadersPolicyList.MaxItems')" = "1" ]
[ "$(json_get "$output" '.ResponseHeadersPolicyList.Items | length')" = "1" ]
[ "$(json_get "$output" '.ResponseHeadersPolicyList.Items[0].Type')" = "managed" ]
[ -n "$(json_get "$output" \
'.ResponseHeadersPolicyList.Items[0].ResponseHeadersPolicy.Id // empty')" ]
[ -n "$(json_get "$output" \
'.ResponseHeadersPolicyList.NextMarker // empty')" ]
first_id="$(json_get "$output" \
'.ResponseHeadersPolicyList.Items[0].ResponseHeadersPolicy.Id')"
next_marker="$(json_get "$output" \
'.ResponseHeadersPolicyList.NextMarker')"
run aws_cmd cloudfront list-response-headers-policies \
--type managed \
--marker "$next_marker" \
--max-items 1 \
--no-paginate
assert_success
[ "$(json_get "$output" '.ResponseHeadersPolicyList.Quantity')" = "1" ]
[ "$(json_get "$output" \
'.ResponseHeadersPolicyList.Items[0].ResponseHeadersPolicy.Id')" != "$first_id" ]
}