Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions lambda-events/src/event/cognito/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ pub struct CognitoEventUserPoolsCreateAuthChallengeRequest {
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub client_metadata: HashMap<String, String>,
#[serde(default)]
pub user_not_found: bool,
}

/// `CognitoEventUserPoolsCreateAuthChallengeResponse` defines create auth challenge response parameters
Expand Down Expand Up @@ -389,6 +391,8 @@ where
#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub client_metadata: HashMap<String, String>,
#[serde(default)]
pub user_not_found: bool,
}

/// `CognitoEventUserPoolsVerifyAuthChallengeResponse` defines verify auth challenge response parameters
Expand Down Expand Up @@ -482,6 +486,20 @@ mod test {
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "cognito")]
fn example_cognito_event_userpools_create_auth_challenge_user_not_found() {
let data =
include_bytes!("../../fixtures/example-cognito-event-userpools-create-auth-challenge-user-not-found.json");
let parsed: CognitoEventUserPoolsCreateAuthChallenge = serde_json::from_slice(data).unwrap();

assert!(parsed.request.user_not_found);

let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CognitoEventUserPoolsCreateAuthChallenge = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "cognito")]
fn example_cognito_event_userpools_custommessage() {
Expand Down Expand Up @@ -518,6 +536,20 @@ mod test {
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "cognito")]
fn example_cognito_event_userpools_define_auth_challenge_user_not_found() {
let data =
include_bytes!("../../fixtures/example-cognito-event-userpools-define-auth-challenge-user-not-found.json");
let parsed: CognitoEventUserPoolsDefineAuthChallenge = serde_json::from_slice(data).unwrap();

assert!(parsed.request.user_not_found);

let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CognitoEventUserPoolsDefineAuthChallenge = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "cognito")]
fn example_cognito_event_userpools_migrateuser() {
Expand Down Expand Up @@ -612,4 +644,18 @@ mod test {
let reparsed: CognitoEventUserPoolsVerifyAuthChallenge = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}

#[test]
#[cfg(feature = "cognito")]
fn example_cognito_event_userpools_verify_auth_challenge_user_not_found() {
let data =
include_bytes!("../../fixtures/example-cognito-event-userpools-verify-auth-challenge-user-not-found.json");
let parsed: CognitoEventUserPoolsVerifyAuthChallenge = serde_json::from_slice(data).unwrap();

assert!(parsed.request.user_not_found);

let output: String = serde_json::to_string(&parsed).unwrap();
let reparsed: CognitoEventUserPoolsVerifyAuthChallenge = serde_json::from_slice(output.as_bytes()).unwrap();
assert_eq!(parsed, reparsed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "1",
"region": "us-west-2",
"userPoolId": "<userPoolId>",
"userName": "<userName>",
"callerContext": {
"awsSdkVersion": "aws-sdk-unknown-unknown",
"clientId": "<clientId>"
},
"triggerSource": "CreateAuthChallenge_Authentication",
"request": {
"userAttributes": {
"sub": "<sub>",
"cognito:user_status": "CONFIRMED",
"phone_number_verified": "true",
"cognito:phone_number_alias": "+12223334455",
"phone_number": "+12223334455"
},
"challengeName": "CUSTOM_CHALLENGE",
"session": [
{
"challengeName": "PASSWORD_VERIFIER",
"challengeResult": true,
"challengeMetadata": "metadata"
}
],
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
},
"userNotFound": true
},
"response": {
"publicChallengeParameters": {
"a": "b"
},
"privateChallengeParameters": {
"c": "d"
},
"challengeMetadata": "challengeMetadata"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
],
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
}
},
"userNotFound": false
},
"response": {
"publicChallengeParameters": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "1",
"region": "us-west-2",
"userPoolId": "<userPoolId>",
"userName": "<userName>",
"callerContext": {
"awsSdkVersion": "aws-sdk-unknown-unknown",
"clientId": "<clientId>"
},
"triggerSource": "DefineAuthChallenge_Authentication",
"request": {
"userAttributes": {
"sub": "<sub>",
"cognito:user_status": "CONFIRMED",
"phone_number_verified": "true",
"cognito:phone_number_alias": "+12223334455",
"phone_number": "+12223334455"
},
"session": [
{
"challengeName": "PASSWORD_VERIFIER",
"challengeResult": true,
"challengeMetadata": "metadata"
}
],
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
},
"userNotFound": true
},
"response": {
"challengeName": "challengeName",
"issueTokens": true,
"failAuthentication": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"challengeAnswer": "123xxxx",
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
}
},
"userNotFound": false
},
"response": {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"version": "1",
"region": "us-west-2",
"userPoolId": "<userPoolId>",
"userName": "<userName>",
"callerContext": {
"awsSdkVersion": "aws-sdk-unknown-unknown",
"clientId": "<clientId>"
},
"triggerSource": "VerifyAuthChallengeResponse_Authentication",
"request": {
"userAttributes": {
"sub": "<sub>",
"cognito:user_status": "CONFIRMED",
"phone_number_verified": "true",
"cognito:phone_number_alias": "+12223334455",
"phone_number": "+12223334455"
},
"privateChallengeParameters": {
"secret": "11122233"
},
"challengeAnswer": "123xxxx",
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
},
"userNotFound": true
},
"response": {
"answerCorrect": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"challengeAnswer": "123xxxx",
"clientMetadata": {
"exampleMetadataKey": "example metadata value"
}
},
"userNotFound": false
},
"response": {
"answerCorrect": true
Expand Down