From 5e9c562683e5e071e2c5c7a08113119dfac456aa Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 3 Feb 2025 18:03:14 +0300 Subject: [PATCH] [#607] Fix aws example test for trailing with sigv4 Signed-off-by: Denis Kirillov --- api/handler/put_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/handler/put_test.go b/api/handler/put_test.go index 3e92d6af..57982670 100644 --- a/api/handler/put_test.go +++ b/api/handler/put_test.go @@ -614,9 +614,16 @@ func getChunkedRequestTrailing(ctx context.Context, t *testing.T, bktName, objNa require.NoError(t, err) _, err = reqBody.WriteString("\r\n0;chunk-signature=2ca2aba2005185cf7159c6277faf83795951dd77a3a99e6e65d5c9f85863f992\r\n") require.NoError(t, err) - _, err = reqBody.WriteString("\r\nx-amz-checksum-crc32c:sOO8/Q==\n") + _, err = reqBody.WriteString("x-amz-checksum-crc32c:sOO8/Q==\n") require.NoError(t, err) - _, err = reqBody.WriteString("x-amz-trailer-signature:63bddb248ad2590c92712055f51b8e78ab024eead08276b24f010b0efd74843f") + + // original signature is 63bddb248ad2590c92712055f51b8e78ab024eead08276b24f010b0efd74843f, + // but we use d81f82fc3505edab99d459891051a732e8730629a2e4a59689829ca17fe2e435 + // because original signature is incorrect + // it was calculated using the`AWS4-HMAC-SHA256-PAYLOAD` constant in canonical string instead of + // `AWS4-HMAC-SHA256-TRAILER` that actually must be used by spec + // (java sdk use correct `AWS4-HMAC-SHA256-TRAILER` string). + _, err = reqBody.WriteString("x-amz-trailer-signature:d81f82fc3505edab99d459891051a732e8730629a2e4a59689829ca17fe2e435") require.NoError(t, err) req, err := http.NewRequest("PUT", "https://s3.amazonaws.com/"+bktName+"/"+objName, nil)