-
Notifications
You must be signed in to change notification settings - Fork 2
/
aws_signed_headers_test.go
42 lines (34 loc) · 1.11 KB
/
aws_signed_headers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package s3
import (
"net/http"
"testing"
"github.com/smarty/assertions/should"
"github.com/smarty/gunit"
)
func init() {
runningAWSTestSuite = true
}
func TestSignedHeadersFixture(t *testing.T) {
gunit.Run(new(SignedHeadersFixture), t)
}
type SignedHeadersFixture struct {
*gunit.Fixture
}
func (this *SignedHeadersFixture) TestCanonicalHeaders() {
actualCanonicalHeaders, actualSignedHeaders := canonicalAndSignedHeaders(http.Header{
"Host": []string{"iam.amazonaws.com:1234"},
"Content-Type": []string{"application/x-www-form-urlencoded; charset=utf-8"},
"My-header1": []string{" a b c "},
"X-Amz-Date": []string{"20150830T123600Z"},
"My-header2": []string{" \"a b c\" "},
})
expectedCanonicalHeaders := `content-type:application/x-www-form-urlencoded; charset=utf-8
host:iam.amazonaws.com
my-header1:a b c
my-header2:"a b c"
x-amz-date:20150830T123600Z
`
expectedSignedHeaders := `content-type;host;my-header1;my-header2;x-amz-date`
this.So(actualCanonicalHeaders, should.Equal, expectedCanonicalHeaders)
this.So(actualSignedHeaders, should.Equal, expectedSignedHeaders)
}