mirror of
https://github.com/versity/versitygw.git
synced 2026-01-08 12:41:10 +00:00
Fixes #1707 The `Expect` HTTP header is ignored by the AWS SDK SigV4 signer and is omitted during signature calculation. As a result, the signature is computed incorrectly when the `Expect` header is included in the signed headers. This PR removes the `Expect` header from the SigV4 ignored headers list in the SDK-derived source code.
64 lines
1.3 KiB
Go
64 lines
1.3 KiB
Go
package v4
|
|
|
|
import "testing"
|
|
|
|
func TestAllowedQueryHoisting(t *testing.T) {
|
|
cases := map[string]struct {
|
|
Header string
|
|
ExpectHoist bool
|
|
}{
|
|
"object-lock": {
|
|
Header: "X-Amz-Object-Lock-Mode",
|
|
ExpectHoist: false,
|
|
},
|
|
"s3 metadata": {
|
|
Header: "X-Amz-Meta-SomeName",
|
|
ExpectHoist: false,
|
|
},
|
|
"another header": {
|
|
Header: "X-Amz-SomeOtherHeader",
|
|
ExpectHoist: true,
|
|
},
|
|
"non X-AMZ header": {
|
|
Header: "X-SomeOtherHeader",
|
|
ExpectHoist: false,
|
|
},
|
|
}
|
|
|
|
for name, c := range cases {
|
|
t.Run(name, func(t *testing.T) {
|
|
if e, a := c.ExpectHoist, AllowedQueryHoisting.IsValid(c.Header); e != a {
|
|
t.Errorf("expect hoist %v, was %v", e, a)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestIgnoredHeaders(t *testing.T) {
|
|
cases := map[string]struct {
|
|
Header string
|
|
ExpectIgnored bool
|
|
}{
|
|
"expect": {
|
|
Header: "Expect",
|
|
ExpectIgnored: false,
|
|
},
|
|
"authorization": {
|
|
Header: "Authorization",
|
|
ExpectIgnored: true,
|
|
},
|
|
"X-AMZ header": {
|
|
Header: "X-Amz-Content-Sha256",
|
|
ExpectIgnored: false,
|
|
},
|
|
}
|
|
|
|
for name, c := range cases {
|
|
t.Run(name, func(t *testing.T) {
|
|
if e, a := c.ExpectIgnored, IgnoredHeaders.IsValid(c.Header); e == a {
|
|
t.Errorf("expect ignored %v, was %v", e, a)
|
|
}
|
|
})
|
|
}
|
|
}
|