-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
customizations_test.go
75 lines (67 loc) · 1.85 KB
/
customizations_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//go:build go1.8
// +build go1.8
package cognitoidentity_test
import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/awstesting/unit"
"github.com/aws/aws-sdk-go/service/cognitoidentity"
)
var svc = cognitoidentity.New(unit.Session)
func TestUnsignedRequests(t *testing.T) {
cases := map[string]struct {
ReqFn func() *request.Request
}{
"GetId": {
ReqFn: func() *request.Request {
req, _ := svc.GetIdRequest(&cognitoidentity.GetIdInput{
IdentityPoolId: aws.String("IdentityPoolId"),
})
return req
},
},
"GetOpenIdToken": {
ReqFn: func() *request.Request {
req, _ := svc.GetOpenIdTokenRequest(&cognitoidentity.GetOpenIdTokenInput{
IdentityId: aws.String("IdentityId"),
})
return req
},
},
"UnlinkIdentity": {
ReqFn: func() *request.Request {
req, _ := svc.UnlinkIdentityRequest(&cognitoidentity.UnlinkIdentityInput{
IdentityId: aws.String("IdentityId"),
Logins: map[string]*string{},
LoginsToRemove: []*string{},
})
return req
},
},
"GetCredentialsForIdentity": {
ReqFn: func() *request.Request {
req, _ := svc.GetCredentialsForIdentityRequest(&cognitoidentity.GetCredentialsForIdentityInput{
IdentityId: aws.String("IdentityId"),
})
return req
},
},
}
for cn, c := range cases {
t.Run(cn, func(t *testing.T) {
req := c.ReqFn()
err := req.Sign()
if err != nil {
t.Errorf("expected no error, but received %v", err)
}
if e, a := credentials.AnonymousCredentials, req.Config.Credentials; e != a {
t.Errorf("expect request to use anonymous credentias, %v", a)
}
if e, a := "", req.HTTPRequest.Header.Get("Authorization"); e != a {
t.Errorf("expected empty value '%v', but received, %v", e, a)
}
})
}
}