public void Can_Confirm_Account_Using_Token_Recieved_While_Registering_Expecting_True()
        {
            var variableToken = DateTime.Now.ToLongTimeString();

            var          username = "******" + variableToken;
            const string email    = "*****@*****.**";
            const string woFs     = "myTwoFactorSecret";
            const string pwd      = "password";

            _uow = new SimpleMembershipUnitOfWorkAsync(_dataContextAsync, _loggingService);
            _simpleMembershipService = new WebSecurity(_uow, _loggingService);

            if (!_simpleMembershipService.FoundUser(username))
            {
                var token = _simpleMembershipService.CreateUserAndAccount(username, pwd, email, true);
                CreatedTestUsers.Add(username);
                Assert.IsNotNull(token, "Token for selected username: [ " + username + " ] was *null*. ");
            }

            // Getting the confirmation token...
            var actualToken = _simpleMembershipService.GetConfirmationToken(username);

            // Passing the confirmation token and confirming the account...
            // We expect the user to be confirmed
            var isConfirmed = _simpleMembershipService.ConfirmAccount(actualToken);

            Assert.IsTrue(isConfirmed, "The requested users acount: [ " + username + " ] could *not* be confirmed. ");
        }
        public void Can_Validate_User_When_User_Has_Confirmed_His_Account_Expected_True()
        {
            var variableToken = DateTime.Now.ToLongTimeString();

            var          username = "******" + variableToken;
            const string email    = "*****@*****.**";
            const string woFs     = "myTwoFactorSecret";
            const string pwd      = "password";

            if (!_simpleMembershipService.FoundUser(username))
            {
                var token = _simpleMembershipService.CreateUserAndAccount(username, pwd, email, true);
                CreatedTestUsers.Add(username);
                Assert.IsNotNull(token, "Token for selected username: [ " + username + " ] was *null*. ");

                var actualToken = _simpleMembershipService.GetConfirmationToken(username);

                // Setting up the test - the users account must be confirmed for this test.
                var isConfirmed = _simpleMembershipService.ConfirmAccount(actualToken);
            }

            // We expect the user to be validated as he had already confirmed his account using the generated confirmation token...
            var userIsValidated = _simpleMembershipService.ValidateUser(username, pwd);

            Assert.IsTrue(userIsValidated,
                          "Users account: [ " + username + " ] was *not* validated even after being confirmed. ");
        }
        Can_Generate_Password_Retrieve_Token_That_Expires_In_1_Minute_And_Reset_Password_After_Time_Limit_Expected_Fail
            ()
        {
            var variableToken = DateTime.Now.ToLongTimeString();

            var          username = "******" + variableToken;
            const string email    = "*****@*****.**";
            const string woFs     = "myTwoFactorSecret";
            const string pwd      = "password";

            _uow = new SimpleMembershipUnitOfWorkAsync(_dataContextAsync, _loggingService);
            _simpleMembershipService = new WebSecurity(_uow, _loggingService);

            if (!_simpleMembershipService.FoundUser(username))
            {
                var token = _simpleMembershipService.CreateUserAndAccount(username, pwd, email, true);
                CreatedTestUsers.Add(username);
                Assert.IsNotNull(token, "Token for selected username: [ " + username + " ] was *null*. ");
            }

            var actualToken = _simpleMembershipService.GetConfirmationToken(username);

            Assert.IsNotNull(actualToken, "Confirmation token for selected username: [ " + username + " ] was *null*. ");

            var isConfirmed = _simpleMembershipService.ConfirmAccount(actualToken);

            Assert.IsTrue(isConfirmed, "The requested users acount: [ " + username + " ] could *not* be confirmed. ");

            // We expect the account to already be confirmed at this point...
            var passwordResetToken = _simpleMembershipService.GeneratePasswordResetToken(username, 1);

            Assert.IsTrue(passwordResetToken.Length > 1, "Password reset token was *not* generated. ");

            Thread.Sleep(65000); // Minute and a half...

            // We expect the password reset to fail due to the timeout period expiry...
            var passwordWasReset = _simpleMembershipService.ResetPassword(passwordResetToken, "newPassword");

            Assert.IsFalse(passwordWasReset, "Password should *not* have been reset - due to timeout. ");
        }
        public void Can_Get_Confirmation_Token_For_UserName_Expecting_Token()
        {
            var variableToken = DateTime.Now.ToLongTimeString();

            const string username = "******";
            const string email    = "*****@*****.**";
            const string woFs     = "myTwoFactorSecret";
            const string pwd      = "password";

            _uow = new SimpleMembershipUnitOfWorkAsync(_dataContextAsync, _loggingService);
            _simpleMembershipService = new WebSecurity(_uow, _loggingService);

            if (!_simpleMembershipService.FoundUser(username))
            {
                var token = _simpleMembershipService.CreateUserAndAccount(username, pwd, email, true);
                CreatedTestUsers.Add(username);
                Assert.IsNotNull(token, "Token for selected username: [ " + username + " ]  was *null*. ");
            }

            var actualToken = _simpleMembershipService.GetConfirmationToken(username);

            // The confirmation token should be generated...
            Assert.IsNotNull(actualToken, "Token for requested username: [ " + username + " ] is *null*. ");
        }