diff --git a/aws/middleware/user_agent.go b/aws/middleware/user_agent.go index 02182220cb1..01d758d5ff8 100644 --- a/aws/middleware/user_agent.go +++ b/aws/middleware/user_agent.go @@ -89,15 +89,15 @@ const ( UserAgentFeatureS3AccessGrants = "K" // not yet implemented UserAgentFeatureGZIPRequestCompression = "L" UserAgentFeatureProtocolRPCV2CBOR = "M" - UserAgentFeatureRequestChecksumWhenSupported = "Z" - UserAgentFeatureRequestChecksumWhenRequired = "a" - UserAgentFeatureResponseChecksumWhenSupported = "b" - UserAgentFeatureResponseChecksumWhenRequired = "c" UserAgentFeatureRequestChecksumCRC32 = "U" UserAgentFeatureRequestChecksumCRC32C = "V" UserAgentFeatureRequestChecksumCRC64 = "W" UserAgentFeatureRequestChecksumSHA1 = "X" UserAgentFeatureRequestChecksumSHA256 = "Y" + UserAgentFeatureRequestChecksumWhenSupported = "Z" + UserAgentFeatureRequestChecksumWhenRequired = "a" + UserAgentFeatureResponseChecksumWhenSupported = "b" + UserAgentFeatureResponseChecksumWhenRequired = "c" ) // RequestUserAgent is a build middleware that set the User-Agent for the request. diff --git a/feature/s3/manager/integ_upload_test.go b/feature/s3/manager/integ_upload_test.go index 3a289459f93..96383c243eb 100644 --- a/feature/s3/manager/integ_upload_test.go +++ b/feature/s3/manager/integ_upload_test.go @@ -222,7 +222,7 @@ func TestInteg_UploadPresetChecksum(t *testing.T) { }, }, "auto multipart part": { - "no checksum": { + "no checksum algorithm passed": { payload: bytes.NewReader(multiPartBytes), expectParts: []s3types.CompletedPart{ { diff --git a/service/internal/checksum/algorithms_test.go b/service/internal/checksum/algorithms_test.go index 7c821f1e2a5..05e46fb1050 100644 --- a/service/internal/checksum/algorithms_test.go +++ b/service/internal/checksum/algorithms_test.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.21 +// +build go1.21 package checksum diff --git a/service/internal/checksum/aws_chunked_encoding_test.go b/service/internal/checksum/aws_chunked_encoding_test.go index 4f208b4c099..5b991b14b86 100644 --- a/service/internal/checksum/aws_chunked_encoding_test.go +++ b/service/internal/checksum/aws_chunked_encoding_test.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.21 +// +build go1.21 package checksum diff --git a/service/internal/checksum/middleware_add_test.go b/service/internal/checksum/middleware_add_test.go index 7219c4a4172..20e8c72a483 100644 --- a/service/internal/checksum/middleware_add_test.go +++ b/service/internal/checksum/middleware_add_test.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.21 +// +build go1.21 package checksum diff --git a/service/internal/checksum/middleware_checksum_metrics_tracking_test.go b/service/internal/checksum/middleware_checksum_metrics_tracking_test.go index aad42493c5b..cbbbb8d230c 100644 --- a/service/internal/checksum/middleware_checksum_metrics_tracking_test.go +++ b/service/internal/checksum/middleware_checksum_metrics_tracking_test.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.21 +// +build go1.21 package checksum @@ -10,56 +10,10 @@ import ( "github.com/aws/smithy-go/middleware" smithyhttp "github.com/aws/smithy-go/transport/http" "net/http" - "runtime" "strings" "testing" ) -var expectedAgent = aws.SDKName + "/" + aws.SDKVersion + - " ua/2.1" + - " os/" + getNormalizedOSName() + - " lang/go#" + strings.Map(rules, languageVersion) + // normalize as the user-agent builder will - " md/GOOS#" + runtime.GOOS + - " md/GOARCH#" + runtime.GOARCH - -var languageVersion = strings.TrimPrefix(runtime.Version(), "go") - -func getNormalizedOSName() (os string) { - switch runtime.GOOS { - case "android": - os = "android" - case "linux": - os = "linux" - case "windows": - os = "windows" - case "darwin": - os = "macos" - case "ios": - os = "ios" - default: - os = "other" - } - return os -} - -var validChars = map[rune]bool{ - '!': true, '#': true, '$': true, '%': true, '&': true, '\'': true, '*': true, '+': true, - '-': true, '.': true, '^': true, '_': true, '`': true, '|': true, '~': true, -} - -func rules(r rune) rune { - switch { - case r >= '0' && r <= '9': - return r - case r >= 'A' && r <= 'Z' || r >= 'a' && r <= 'z': - return r - case validChars[r]: - return r - default: - return '-' - } -} - func TestRequestChecksumMetricsTracking(t *testing.T) { cases := map[string]struct { requestChecksumCalculation aws.RequestChecksumCalculation @@ -69,26 +23,26 @@ func TestRequestChecksumMetricsTracking(t *testing.T) { "default": { requestChecksumCalculation: aws.RequestChecksumCalculationWhenSupported, reqHeaders: map[string][]string{}, - expectedUserAgentHeader: expectedAgent + " m/Z", + expectedUserAgentHeader: " m/Z", }, "calculate checksum when required": { requestChecksumCalculation: aws.RequestChecksumCalculationWhenRequired, reqHeaders: map[string][]string{}, - expectedUserAgentHeader: expectedAgent + " m/a", + expectedUserAgentHeader: " m/a", }, "default with crc32 checksum": { requestChecksumCalculation: aws.RequestChecksumCalculationWhenSupported, reqHeaders: map[string][]string{ "X-Amz-Checksum-Crc32": {"aa"}, }, - expectedUserAgentHeader: expectedAgent + " m/U,Z", + expectedUserAgentHeader: " m/U,Z", }, "calculate checksum when required with sha256 checksum": { requestChecksumCalculation: aws.RequestChecksumCalculationWhenRequired, reqHeaders: map[string][]string{ "X-Amz-Checksum-Sha256": {"aa"}, }, - expectedUserAgentHeader: expectedAgent + " m/Y,a", + expectedUserAgentHeader: " m/Y,a", }, "default with crc32c and crc64": { requestChecksumCalculation: aws.RequestChecksumCalculationWhenSupported, @@ -96,7 +50,7 @@ func TestRequestChecksumMetricsTracking(t *testing.T) { "X-Amz-Checksum-Crc32c": {"aa"}, "X-Amz-Checksum-Crc64nvme": {"aa"}, }, - expectedUserAgentHeader: expectedAgent + " m/V,W,Z", + expectedUserAgentHeader: " m/V,W,Z", }, } @@ -120,8 +74,8 @@ func TestRequestChecksumMetricsTracking(t *testing.T) { return })) - if e, a := c.expectedUserAgentHeader, req.Header["User-Agent"][0]; e != a { - t.Errorf("expected user agent header to be %s, got %s", e, a) + if e, a := c.expectedUserAgentHeader, req.Header["User-Agent"][0]; !strings.Contains(a, e) { + t.Errorf("expected user agent header to include %s, got %s", e, a) } }) } @@ -134,11 +88,11 @@ func TestResponseChecksumMetricsTracking(t *testing.T) { }{ "default": { responseChecksumValidation: aws.ResponseChecksumValidationWhenSupported, - expectedUserAgentHeader: expectedAgent + " m/b", + expectedUserAgentHeader: " m/b", }, "validate checksum when required": { responseChecksumValidation: aws.ResponseChecksumValidationWhenRequired, - expectedUserAgentHeader: expectedAgent + " m/c", + expectedUserAgentHeader: " m/c", }, } @@ -161,8 +115,8 @@ func TestResponseChecksumMetricsTracking(t *testing.T) { return })) - if e, a := c.expectedUserAgentHeader, req.Header["User-Agent"][0]; e != a { - t.Errorf("expected user agent header to be %s, got %s", e, a) + if e, a := c.expectedUserAgentHeader, req.Header["User-Agent"][0]; !strings.Contains(a, e) { + t.Errorf("expected user agent header to contain %s, got %s", e, a) } }) } diff --git a/service/internal/checksum/middleware_compute_input_checksum_test.go b/service/internal/checksum/middleware_compute_input_checksum_test.go index 43dc87a7ef0..a2e9b02df83 100644 --- a/service/internal/checksum/middleware_compute_input_checksum_test.go +++ b/service/internal/checksum/middleware_compute_input_checksum_test.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.21 +// +build go1.21 package checksum diff --git a/service/internal/checksum/middleware_setup_context_test.go b/service/internal/checksum/middleware_setup_context_test.go index 0f766430eb8..81c7250940a 100644 --- a/service/internal/checksum/middleware_setup_context_test.go +++ b/service/internal/checksum/middleware_setup_context_test.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.21 +// +build go1.21 package checksum diff --git a/service/internal/checksum/middleware_validate_output_test.go b/service/internal/checksum/middleware_validate_output_test.go index 618c233dc6f..2b2d4bbca6d 100644 --- a/service/internal/checksum/middleware_validate_output_test.go +++ b/service/internal/checksum/middleware_validate_output_test.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.21 +// +build go1.21 package checksum