/* * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ using Amazon.AspNetCore.Identity.Cognito.Exceptions; using Amazon.CognitoIdentityProvider; using Amazon.Extensions.CognitoAuthentication; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Moq; using System; namespace Amazon.AspNetCore.Identity.Cognito.Tests { public class ManagerTestBase { protected Mock contextAccessorMock; protected Mock> claimsFactoryMock; protected Mock> optionsAccessorMock; protected Mock> userConfirmationMock; protected Mock>> loggerSigninManagerMock; protected Mock schemesMock; protected Mock cognitoClientMock; protected Mock cognitoPoolMock; protected Mock errorsMock; protected Mock> userStoreMock; protected Mock> passwordHasherMock; protected Mock> userValidatorsMock; protected Mock> passwordValidatorsMock; protected CognitoKeyNormalizer keyNormalizer; protected Mock servicesMock; protected Mock>> loggerUserManagerMock; public ManagerTestBase() { cognitoClientMock = new Mock(); cognitoPoolMock = new Mock("region_poolName", "clientID", cognitoClientMock.Object, null); errorsMock = new Mock(); optionsAccessorMock = new Mock>(); var idOptions = new IdentityOptions(); idOptions.Lockout.AllowedForNewUsers = false; optionsAccessorMock.Setup(o => o.Value).Returns(idOptions); contextAccessorMock = new Mock(); userConfirmationMock = new Mock>(); loggerSigninManagerMock = new Mock>>(); schemesMock = new Mock(); userStoreMock = new Mock>(cognitoClientMock.Object, cognitoPoolMock.Object, errorsMock.Object); passwordHasherMock = new Mock>(); userValidatorsMock = new Mock>(); passwordValidatorsMock = new Mock>(); keyNormalizer = new CognitoKeyNormalizer(); servicesMock = new Mock(); loggerUserManagerMock = new Mock>>(); } public CognitoUser GetCognitoUser() { return new CognitoUser("userId", "clientId", cognitoPoolMock.Object, cognitoClientMock.Object); } } }