File tree Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Expand file tree Collapse file tree 3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -124,3 +124,24 @@ type GroupConfiguration struct {
124124 IAMRolesToOverride []string `json:"iamRolesToOverride"`
125125 PreferredRole * string `json:"preferredRole"`
126126}
127+
128+ // CognitoEventUserPoolsCustomMessage is sent by AWS Cognito User Pools before a verification or MFA message is sent,
129+ // allowing a user to customize the message dynamically.
130+ type CognitoEventUserPoolsCustomMessage struct {
131+ CognitoEventUserPoolsHeader
132+ Request CognitoEventUserPoolsCustomMessageRequest `json:"request"`
133+ Response CognitoEventUserPoolsCustomMessageResponse `json:"response"`
134+ }
135+
136+ // CognitoEventUserPoolsCustomMessageRequest contains the request portion of a CustomMessage event
137+ type CognitoEventUserPoolsCustomMessageRequest struct {
138+ UserAttributes map [string ]interface {} `json:"userAttributes"`
139+ CodeParameter string `json:"codeParameter"`
140+ }
141+
142+ // CognitoEventUserPoolsCustomMessageResponse contains the response portion of a CustomMessage event
143+ type CognitoEventUserPoolsCustomMessageResponse struct {
144+ SMSMessage string `json:"smsMessage"`
145+ EmailMessage string `json:"emailMessage"`
146+ EmailSubject string `json:"emailSubject"`
147+ }
Original file line number Diff line number Diff line change @@ -135,3 +135,30 @@ func TestCognitoEventUserPoolsPostAuthenticationMarshaling(t *testing.T) {
135135
136136 assert .JSONEq (t , string (inputJSON ), string (outputJSON ))
137137}
138+
139+ func TestCognitoEventUserPoolsCustomMessageMarshaling (t * testing.T ) {
140+
141+ // read json from file
142+ inputJSON , err := ioutil .ReadFile ("./testdata/cognito-event-userpools-custommessage.json" )
143+ if err != nil {
144+ t .Errorf ("could not open test file. details: %v" , err )
145+ }
146+
147+ // de-serialize into CognitoEvent
148+ var inputEvent CognitoEventUserPoolsCustomMessage
149+ if err := json .Unmarshal (inputJSON , & inputEvent ); err != nil {
150+ t .Errorf ("could not unmarshal event. details: %v" , err )
151+ }
152+
153+ // serialize to json
154+ outputJSON , err := json .Marshal (inputEvent )
155+ if err != nil {
156+ t .Errorf ("could not marshal event. details: %v" , err )
157+ }
158+
159+ assert .JSONEq (t , string (inputJSON ), string (outputJSON ))
160+ }
161+
162+ func TestCognitoUserPoolsCustomMessageMarshalingMalformedJson (t * testing.T ) {
163+ test .TestMalformedJson (t , CognitoEventUserPoolsCustomMessage {})
164+ }
Original file line number Diff line number Diff line change 1+ {
2+ "version" : " 1" ,
3+ "triggerSource" : " CustomMessage_SignUp/CustomMessage_ResendCode/CustomMessage_ForgotPassword/CustomMessage_VerifyUserAttribute" ,
4+ "region" : " <region>" ,
5+ "userPoolId" : " <userPoolId>" ,
6+ "userName" : " <userName>" ,
7+ "callerContext" : {
8+ "awsSdkVersion" : " <calling aws sdk with version>" ,
9+ "clientId" : " <apps client id>"
10+ },
11+ "request" : {
12+ "userAttributes" : {
13+ "phone_number_verified" : true ,
14+ "email_verified" : false
15+ },
16+ "codeParameter" : " ####"
17+ },
18+ "response" : {
19+ "smsMessage" : " <custom message to be sent in the message with code parameter>" ,
20+ "emailMessage" : " <custom message to be sent in the message with code parameter>" ,
21+ "emailSubject" : " <custom email subject>"
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments