aws / aws-sdk-net-extensions-cognito

An extension library to assist in the Amazon Cognito User Pools authentication process
Apache License 2.0
102 stars 50 forks source link

Virtual methods for CognitoUser #49

Closed WajahatAliAbid closed 3 years ago

WajahatAliAbid commented 4 years ago

Issue #, if available: https://github.com/aws/aws-aspnet-cognito-identity-provider/issues/151 Description of changes:* Mock testing CognitoUser using Moq fails because it needs virtual methods to create a proxy with [1]. image Currently the workaround is to write a subclass to wrap around the CognitoUser class as follows

public class CustomCognitoUser : CognitoUser
    {
        public CustomCognitoUser(string userID, string clientID, CognitoUserPool pool, IAmazonCognitoIdentityProvider provider, string? clientSecret = null, string? status = null, string? username = null, Dictionary<string, string>? attributes = null) : base(userID, clientID, pool, provider, clientSecret, status, username, attributes)
        {
        }
        public virtual new Task<AuthFlowResponse> StartWithAdminNoSrpAuthAsync(InitiateAdminNoSrpAuthRequest adminAuthRequest)
        {
            return base.StartWithAdminNoSrpAuthAsync(adminAuthRequest);
        }
    }

This PR makes the methods of CognitoUser virtual so we can write mock test cases for CognitoUser class.

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

normj commented 3 years ago

This PR is merged as part of version 2.1.0 that went out today.