Skip to content

Commit 013dc2d

Browse files
committed
Add sample data and serde test
1 parent 849ad2a commit 013dc2d

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

events/cognito_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@ func TestCognitoEventUserPoolsPreTokenGenMarshaling(t *testing.T) {
140140
test.AssertJsonsEqual(t, inputJSON, outputJSON)
141141
}
142142

143+
func TestCognitoEventUserPoolsPreTokenGenV2Marshaling(t *testing.T) {
144+
// read json from file
145+
inputJSON, err := ioutil.ReadFile("./testdata/cognito-event-userpools-pretokengen-v2.json")
146+
if err != nil {
147+
t.Errorf("could not open test file. details: %v", err)
148+
}
149+
150+
// de-serialize into CognitoEvent
151+
var inputEvent CognitoEventUserPoolsPreTokenGenV2
152+
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
153+
t.Errorf("could not unmarshal event. details: %v", err)
154+
}
155+
156+
// serialize to json
157+
outputJSON, err := json.Marshal(inputEvent)
158+
if err != nil {
159+
t.Errorf("could not marshal event. details: %v", err)
160+
}
161+
162+
test.AssertJsonsEqual(t, inputJSON, outputJSON)
163+
}
164+
143165
func TestCognitoEventUserPoolsDefineAuthChallengeMarshaling(t *testing.T) {
144166
var inputEvent CognitoEventUserPoolsDefineAuthChallenge
145167
test.AssertJsonFile(t, "./testdata/cognito-event-userpools-define-auth-challenge.json", &inputEvent)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"version": "2",
3+
"triggerSource": "TokenGeneration_Authentication",
4+
"region": "us-west-2",
5+
"userPoolId": "us-east-1_EXAMPLE",
6+
"userName": "brcotter",
7+
"callerContext": {
8+
"awsSdkVersion": "aws-sdk-unknown-unknown",
9+
"clientId": "1example23456789"
10+
},
11+
"request": {
12+
"userAttributes": {
13+
"sub": "a36036a8-9061-424d-a737-56d57dae7bc6",
14+
"cognito:email_alias": "[email protected]",
15+
"cognito:user_status": "CONFIRMED",
16+
"email_verified": "true",
17+
"email": "[email protected]"
18+
},
19+
"groupConfiguration": {
20+
"groupsToOverride": [],
21+
"iamRolesToOverride": []
22+
},
23+
"scopes": [
24+
"aws.cognito.signin.user.admin"
25+
]
26+
},
27+
"response": {
28+
"claimsAndScopeOverrideDetails": {
29+
"idTokenGeneration": {
30+
"claimsToAddOrOverride": {
31+
"family_name": "xyz"
32+
},
33+
"claimsToSuppress": [
34+
"email",
35+
"birthdate"
36+
]
37+
},
38+
"accessTokenGeneration": {
39+
"claimsToAddOrOverride": {
40+
"family_name": "xyz"
41+
},
42+
"claimsToSuppress": [
43+
"email",
44+
"birthdate"
45+
],
46+
"scopesToAdd": [
47+
"scope1",
48+
"scope2",
49+
"scopeLomond"
50+
],
51+
"scopesToSuppress": [
52+
"phone_number"
53+
]
54+
},
55+
"groupOverrideDetails": {
56+
"groupsToOverride": [
57+
"group-A",
58+
"group-B",
59+
"group-C"
60+
],
61+
"iamRolesToOverride": [
62+
"arn:aws:iam::123456789012:role/sns_callerA",
63+
"arn:aws:iam::123456789012:role/sns_callerB",
64+
"arn:aws:iam::123456789012:role/sns_callerC"
65+
],
66+
"preferredRole": "arn:aws:iam::123456789012:role/sns_caller"
67+
}
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)