Exemplo n.º 1
0
 public void ResetPassword()
 {
     var    target   = new TableMembershipProvider();
     string username = StringHelper.ValidString();
     string answer   = StringHelper.ValidString();
     var    actual   = target.ResetPassword(username, answer);
 }
Exemplo n.º 2
0
 public void DeleteUser()
 {
     var    target               = new TableMembershipProvider();
     string username             = StringHelper.ValidString();
     bool   deleteAllRelatedData = false;
     var    actual               = target.DeleteUser(username, deleteAllRelatedData);
 }
Exemplo n.º 3
0
 public void GetUserTestUserKey()
 {
     var    target          = new TableMembershipProvider();
     object providerUserKey = new object();
     bool   userIsOnline    = false;
     var    actual          = target.GetUser(providerUserKey, userIsOnline);
 }
Exemplo n.º 4
0
        public void MinRequiredNonAlphanumericCharacters()
        {
            var target = new TableMembershipProvider();
            int actual = target.MinRequiredNonAlphanumericCharacters;

            Assert.AreEqual <int>(0, actual);
        }
Exemplo n.º 5
0
        public void MinRequiredPasswordLength()
        {
            var target = new TableMembershipProvider();
            int actual = target.MinRequiredPasswordLength;

            Assert.AreEqual <int>(0, actual);
        }
Exemplo n.º 6
0
        public void UpdateUser()
        {
            var            target = new TableMembershipProvider();
            MembershipUser user   = null;

            target.UpdateUser(user);
        }
Exemplo n.º 7
0
 public void ChangePassword()
 {
     var    target      = new TableMembershipProvider();
     string username    = StringHelper.ValidString();
     string oldPassword = StringHelper.ValidString();
     string newPassword = StringHelper.ValidString();
     var    actual      = target.ChangePassword(username, oldPassword, newPassword);
 }
Exemplo n.º 8
0
        public void GetUserUnknown()
        {
            var    target       = new TableMembershipProvider();
            string username     = StringHelper.ValidString();
            bool   userIsOnline = false;
            var    actual       = target.GetUser(username, userIsOnline);

            Assert.IsNull(actual);
        }
Exemplo n.º 9
0
 public void ChangePasswordQuestionAndAnswer()
 {
     var    target              = new TableMembershipProvider();
     string username            = StringHelper.ValidString();
     string password            = StringHelper.ValidString();
     string newPasswordQuestion = StringHelper.ValidString();
     string newPasswordAnswer   = StringHelper.ValidString();
     var    actual              = target.ChangePasswordQuestionAndAnswer(username, password, newPasswordQuestion, newPasswordAnswer);
 }
Exemplo n.º 10
0
 public void GetAllUsers()
 {
     var random       = new Random();
     var target       = new TableMembershipProvider();
     int pageIndex    = random.Next();
     int pageSize     = random.Next();
     int totalRecords = random.Next();
     var actual       = target.GetAllUsers(pageIndex, pageSize, out totalRecords);
 }
Exemplo n.º 11
0
        public void GetUserInvalid()
        {
            var    target       = new TableMembershipProvider();
            string username     = StringHelper.NullEmptyWhiteSpace();
            bool   userIsOnline = false;
            var    actual       = target.GetUser(username, userIsOnline);

            Assert.IsNull(actual);
        }
Exemplo n.º 12
0
        public void ValidateUser()
        {
            var    target   = new TableMembershipProvider();
            string username = StringHelper.ValidString();
            string password = StringHelper.ValidString();
            bool   expected = false;
            var    actual   = target.ValidateUser(username, password);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 13
0
 public void FindUsersByName()
 {
     var    random          = new Random();
     var    target          = new TableMembershipProvider();
     string usernameToMatch = StringHelper.ValidString();
     int    pageIndex       = random.Next();
     int    pageSize        = random.Next();
     int    totalRecords    = random.Next();
     var    actual          = target.FindUsersByName(usernameToMatch, pageIndex, pageSize, out totalRecords);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Register user on site
        /// </summary>
        /// <param name="userIdentity">user Identity</param>
        /// <returns>New User</returns>
        private bool Register(IIdentity userIdentity)
        {
            using (new Service.PerformanceMonitor())
            {
                if (userIdentity.IsAuthenticated)
                {
                    var identity = (IClaimsIdentity)userIdentity;

                    var register = new RegisterModel()
                    {
                        Email          = User.Identity.EmailAddress(),
                        NameIdentifier = User.Identity.NameIdentifier(),
                        UserName       = identity.Name,
                    };

                    var      source = new DomainSource();
                    UserData user   = null;
                    if (!string.IsNullOrWhiteSpace(register.NameIdentifier) && null != (user = source.GetUserByNameIdentifier(ServerConfiguration.ApplicationIdentifier, register.NameIdentifier)))
                    {
                        user.LastLoggedInOn = DateTime.UtcNow;
                        user.LastActivityOn = DateTime.UtcNow;

                        source.Update(user);
                    }
                    else if (!string.IsNullOrWhiteSpace(register.Email) && null != (user = source.GetUserByEmail(ServerConfiguration.ApplicationIdentifier, register.Email)))
                    {
                        user.LastLoggedInOn = DateTime.UtcNow;
                        user.LastActivityOn = DateTime.UtcNow;
                        user.NameIdentifier = register.NameIdentifier;

                        source.Update(user);
                    }
                    else
                    {
                        var provider = new TableMembershipProvider();
                        MembershipCreateStatus status;
                        provider.CreateUser(register.UserName, Guid.NewGuid().ToString(), register.Email, null, null, true, register.NameIdentifier, out status);
                        if (status == MembershipCreateStatus.Success)
                        {
                            log.Log("New user signed up.");
                            return(true);
                        }
                        else
                        {
                            log.Log("New user failed to signed up; status: '{0}'".FormatWithCulture(status));
                        }
                    }
                }
            }

            return(false);
        }
Exemplo n.º 15
0
        private bool Login(GitHubProfile profile)
        {
            var newUser  = false;
            var register = new RegisterModel()
            {
                Email          = profile.Email,
                NameIdentifier = string.Format("github{0}", profile.Id),
                UserName       = profile.Name,
            };

            var      source = new DomainSource();
            UserData user   = null;

            if (!string.IsNullOrWhiteSpace(register.NameIdentifier) && null != (user = source.GetUserByNameIdentifier(Application.Default.Identifier, register.NameIdentifier)))
            {
                user.LastLoggedInOn = DateTime.UtcNow;
                user.LastActivityOn = DateTime.UtcNow;

                source.Update(user);
            }
            else if (!string.IsNullOrWhiteSpace(register.Email) && null != (user = source.GetUserByEmail(Application.Default.Identifier, register.Email)))
            {
                user.LastLoggedInOn = DateTime.UtcNow;
                user.LastActivityOn = DateTime.UtcNow;
                user.NameIdentifier = register.NameIdentifier;

                source.Update(user);
            }
            else
            {
                var provider = new TableMembershipProvider();
                MembershipCreateStatus status;
                provider.CreateUser(register.UserName, Guid.NewGuid().ToString(), register.Email, null, null, true, register.NameIdentifier, out status);
                if (status == MembershipCreateStatus.Success)
                {
                    log.Log("New user signed up.");
                    newUser = true;
                }
                else
                {
                    log.Log(string.Format("New user failed to signed up; status: '{0}'", status));
                }
            }

            FormsAuthentication.SetAuthCookie(register.Email, true);

            return(newUser);
        }
Exemplo n.º 16
0
 public void PasswordAttemptWindow()
 {
     var target = new TableMembershipProvider();
     var actual = target.PasswordAttemptWindow;
 }
Exemplo n.º 17
0
 public void PasswordFormat()
 {
     var target = new TableMembershipProvider();
     var actual = target.PasswordFormat;
 }
Exemplo n.º 18
0
        public void ApplicationNameTestSet()
        {
            var target = new TableMembershipProvider();

            target.ApplicationName = StringHelper.ValidString();
        }
Exemplo n.º 19
0
 public void EnablePasswordReset()
 {
     var target = new TableMembershipProvider();
     var actual = target.EnablePasswordReset;
 }
Exemplo n.º 20
0
 public void RequiresUniqueEmail()
 {
     var target = new TableMembershipProvider();
     var actual = target.RequiresUniqueEmail;
 }
Exemplo n.º 21
0
 public void ApplicationNameTestGet()
 {
     var target = new TableMembershipProvider();
     var actual = target.ApplicationName;
 }
Exemplo n.º 22
0
        public void GetUserNameByEmailInvalidEmail()
        {
            var target = new TableMembershipProvider();

            target.GetUserNameByEmail(StringHelper.NullEmptyWhiteSpace());
        }
Exemplo n.º 23
0
 public void GetNumberOfUsersOnline()
 {
     var target = new TableMembershipProvider();
     var actual = target.GetNumberOfUsersOnline();
 }
Exemplo n.º 24
0
        public void TableMembershipProviderConstructor()
        {
            var target = new TableMembershipProvider();

            Assert.IsNotNull(target);
        }
Exemplo n.º 25
0
 public void UnlockUser()
 {
     var    target   = new TableMembershipProvider();
     string userName = StringHelper.ValidString();
     var    actual   = target.UnlockUser(userName);
 }
Exemplo n.º 26
0
 public void DetermineRoleTypeManager()
 {
     Assert.AreEqual <RoleType>(RoleType.Manager, TableMembershipProvider.DetermineRoleType("*****@*****.**"));
 }
Exemplo n.º 27
0
 public void DetermineRoleTypeClient()
 {
     Assert.AreEqual <RoleType>(RoleType.Client, TableMembershipProvider.DetermineRoleType(StringHelper.ValidString()));
 }
Exemplo n.º 28
0
 public void DetermineRoleTypeInvalidEmail()
 {
     Assert.AreEqual <RoleType>(RoleType.Client, TableMembershipProvider.DetermineRoleType(StringHelper.NullEmptyWhiteSpace()));
 }
Exemplo n.º 29
0
 public void RequiresQuestionAndAnswer()
 {
     var target = new TableMembershipProvider();
     var actual = target.RequiresQuestionAndAnswer;
 }
Exemplo n.º 30
0
 public void MaxInvalidPasswordAttempts()
 {
     var target = new TableMembershipProvider();
     var actual = target.MaxInvalidPasswordAttempts;
 }