Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding contracts for Cognito Trigger Events #1051

Merged
merged 1 commit into from
Feb 12, 2023
Merged

Conversation

jon-armen
Copy link
Contributor

Issue #, if available: #1050

Description of changes: Adding contracts for Cognito Trigger Events

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jon-armen jon-armen changed the title PreSignup Adding contracts for Cognito Trigger Events Jan 15, 2022
@jon-armen jon-armen force-pushed the CognitoTriggers branch 3 times, most recently from 4637353 to feea1ad Compare January 15, 2022 11:53
@jon-armen jon-armen force-pushed the CognitoTriggers branch 8 times, most recently from 703c9c5 to 77329a5 Compare February 8, 2022 22:06
@jon-armen jon-armen marked this pull request as ready for review February 8, 2022 22:13
@jon-armen
Copy link
Contributor Author

@normj , this is ready for review.

@ganeshnj ganeshnj self-requested a review February 9, 2022 18:30
@jon-armen
Copy link
Contributor Author

@normj , @ganeshnj Any updates on when this may be reviewed?

@TobbenTM
Copy link
Contributor

TobbenTM commented Mar 5, 2022

This seems like a great addition, any chance this could get some attention @ganeshnj @normj ?

@ashishdhingra
Copy link
Contributor

@jon-armen Could you please rebase your branch and change target branch to aws:dev?

@jon-armen jon-armen force-pushed the CognitoTriggers branch 2 times, most recently from b201517 to 624193d Compare March 22, 2022 22:04
@jon-armen jon-armen changed the base branch from master to dev March 22, 2022 22:05
PreSignup
PostConfirmation
PreAuthentication
PostAuthentication
DefineAuthChallenge
CreateAuthChallenge
VerifyAuthChallenge
PreTokenGeneration
MigrateUser
CustomMessage
CustomEmailSender
CustomSmsSender
@jon-armen
Copy link
Contributor Author

@jon-armen Could you please rebase your branch and change target branch to aws:dev?

@ashishdhingra , done.

@ashishdhingra ashishdhingra added the pr/needs-review This PR needs a review from a Member. label Mar 23, 2022
@jon-armen
Copy link
Contributor Author

@ashishdhingra This has been rebased. Any updates on when it may be reviewed / released?

/// <summary>
/// The input object containing the current group configuration. It includes groupsToOverride, iamRolesToOverride, and preferredRole.
/// </summary>
[DataMember(Name = "groupConfiguration")]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be JsonPropertyName not DataMember

Default behaviour of the serializer is to use PascalCase, and Cognito uses camelCase, so these are essential

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JsonPropertyName is included for NetCoreApp3.1. I followed the patterns called out in examples such as

https://github.com/aws/aws-lambda-dotnet/blob/087590ce99274e16e26d37e1dfd73b0b71d1230a/Libraries/src/Amazon.Lambda.ApplicationLoadBalancerEvents/ApplicationLoadBalancerResponse.cs

with included tests to verify serialization for all supported targets, and under all situations we're getting the correct camelCase serialization. Is this pattern for calling out DataMember and JsonPropertyName deprecated and something that should now be avoided in this library?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used your code in .Net 6 and it fails. Adding JsonPropertyName fixes it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used the Visual Studio 2022 template which injects

[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]

This serializer has a bug that puts all output into PascalCase, and uses JsonPropertyName to override this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take another look at it. I suspect the majority of serialization classes within this repo would exhibit this issue, given this is an existing pattern.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's as simple as removing the conditional and always having the JsonPropertyName attribute present

@ganeshnj
Copy link
Contributor

Thanks for the RP, apologies for picking this late.

How this change is integration tested? I understand from the change, POCOs are created using the docs available but it has proven be wrong lately because of staled version of docs.

If you have not tested the integration, could you?

Thanks again.

@jon-armen
Copy link
Contributor Author

Thanks for the RP, apologies for picking this late.

How this change is integration tested? I understand from the change, POCOs are created using the docs available but it has proven be wrong lately because of staled version of docs.

If you have not tested the integration, could you?

Thanks again.

@ganeshnj I haven't integration tested all of these classes, but I have tested the custom email sender and custom message events. Do you have a standard framework you would prefer me to use for integration testing these? I didn't see anything in the repo for integration testing. These classes are based on the docs, so it is possible it could be wrong if the docs are incorrect. Hopefully if it's a case of the docs being stale that would just mean I'm missing something that could be added at a later date.

@BryanCrotaz
Copy link

I've tested the pre token generation events and they work apart from being PascalCase when they should be camelCase. Interestingly they are case insensitive when deserialising but AWS is case sensitive when reading the serialised output.

I've added a review saying how to fix.

@ganeshnj
Copy link
Contributor

ganeshnj commented May 18, 2022

@ganeshnj I haven't integration tested all of these classes, but I have tested the custom email sender and custom message events. Do you have a standard framework you would prefer me to use for integration testing these? I didn't see anything in the repo for integration testing. These classes are based on the docs, so it is possible it could be wrong if the docs are incorrect. Hopefully if it's a case of the docs being stale that would just mean I'm missing something that could be added at a later date.

I mean by integration tests here is, setting up a trigger in Lambda with Cognito and being able to invoke the Lambda. Also make sure all the properties send by the trigger are correctly deserialized.

@BryanCrotaz
Copy link

BryanCrotaz commented May 18, 2022 via email

@Maxwe11
Copy link

Maxwe11 commented Jul 20, 2022

Api design with separate models per event type looks nice (on the picture :), but it requires creating separate Lambdas for each event.
In a real-world scenario, I'd prefer to have a single lambda that can handle multiple event types.

@Simonl9l
Copy link

is there any chance this pull requests will be merged any soon... it would be great to have the ability to implement dotnet versions of these events.

@michaelakin
Copy link

Please review and merge this or 733 soon. The contract in the Nuget package Amazon.Lambda.CognitoEvents is not valid any longer and causes an exception. Can you please remove this package from Nuget?

@ashishdhingra
Copy link
Contributor

I’ve done that with the pre token trigger and the input is deserialised correctly. The output is not.

@jon-armen As @ganeshnj pointed out, please test all the events end-to-end to ensure these work. We have seen issues in the past where changes were not fully integration tested resulting on post-release issues.

@jon-armen
Copy link
Contributor Author

@ashishdhingra , I'll see about putting together a suite of integration tests. Hopefully I can get to it this evening, otherwise, in the next few days.

@ashishdhingra ashishdhingra added the feature-request A feature should be added or improved. label Oct 11, 2022
@normj normj merged commit a00fdca into aws:dev Feb 12, 2023
@normj
Copy link
Member

normj commented Feb 13, 2023

This PR has been released as part of version 2.1.0 of Amazon.Lambda.CognitoEvents. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. pr/needs-review This PR needs a review from a Member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants