public async Task SuccessfulConfirmation_OfAccount_ReturnsStatusCode_Ok() { var user = new AwsCognitoUser { UserName = "******", ConfirmationCode = "123456" }; _cognitoAdapterHelper.UserExists(Arg.Any <AwsCognitoUser>()).Returns(true); _cognitoAdapterHelper.UserIsConfirmed(Arg.Any <AwsCognitoUser>()).Returns(false); _awsCognitoClient.ConfirmSignUpAsync(Arg.Any <ConfirmSignUpRequest>()).Returns(new ConfirmSignUpResponse()); var confirmUserResponse = await _authAdapter.ConfirmUserAsync(user); Assert.AreEqual(HttpStatusCode.OK, confirmUserResponse.StatusCode); }
public async Task <HttpResponseMessage> ConfirmUserAsync(AwsCognitoUser user) { if (!await _cognitoAdapterHelper.UserExists(user)) { return(new HttpResponseMessage(HttpStatusCode.NotFound)); } if (await _cognitoAdapterHelper.UserIsConfirmed(user)) { return(new HttpResponseMessage(HttpStatusCode.Conflict)); } var confirmSignupRequest = new ConfirmSignUpRequest { Username = user.UserName, ConfirmationCode = user.ConfirmationCode, ClientId = _clientId }; await _awsCognitoClient.ConfirmSignUpAsync(confirmSignupRequest); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public async Task UserIsConfirmed_ReturnsTrue_IfUserIsInConfirmedState() { var user = new AwsCognitoUser { UserName = "******", Password = "******" }; _awsCognitoClient.ListUsersAsync(Arg.Any <ListUsersRequest>()).Returns(new ListUsersResponse { Users = new List <UserType> { new UserType { Username = user.UserName, UserStatus = UserStatusType.CONFIRMED } } }); var userIsConfirmed = await _cognitoAdapterHelper.UserIsConfirmed(user); Assert.IsTrue(userIsConfirmed); }