예제 #1
0
        public void ModifyUser()
        {
            IUsersStorageProviderV40 prov = GetProvider();

            UserInfo user = new UserInfo("username", null, "*****@*****.**", false, DateTime.UtcNow, prov);

            prov.AddUser(user.Username, user.DisplayName, "password", user.Email, user.Active, user.DateTime);
            prov.AddUser("zzzz", null, "password2", "*****@*****.**", false, DateTime.UtcNow);

            // Set new password
            UserInfo expected = new UserInfo(user.Username, "New Display", "*****@*****.**", true, user.DateTime, prov);
            UserInfo result   = prov.ModifyUser(user, "New Display", "newpass", "*****@*****.**", true);

            AssertUserInfosAreEqual(expected, result, true);

            UserInfo[] allUsers = prov.GetUsers();
            Assert.AreEqual(2, allUsers.Length, "Wrong user count");
            Array.Sort(allUsers, delegate(UserInfo x, UserInfo y) { return(x.Username.CompareTo(y.Username)); });
            AssertUserInfosAreEqual(expected, allUsers[0], true);

            Assert.IsTrue(prov.TestAccount(user, "newpass"), "TestAccount should return true");

            // Set null display name
            expected = new UserInfo(user.Username, null, "*****@*****.**", true, user.DateTime, prov);
            result   = prov.ModifyUser(user, null, null, "*****@*****.**", true);
            AssertUserInfosAreEqual(expected, result, true);

            allUsers = prov.GetUsers();
            Assert.AreEqual(2, allUsers.Length, "Wrong user count");
            Array.Sort(allUsers, delegate(UserInfo x, UserInfo y) { return(x.Username.CompareTo(y.Username)); });
            AssertUserInfosAreEqual(expected, allUsers[0], true);

            Assert.IsTrue(prov.TestAccount(user, "newpass"), "TestAccount should return true");
        }
예제 #2
0
        public void TestAccount()
        {
            IUsersStorageProviderV40 prov = GetProvider();

            UserInfo u1 = prov.AddUser("user1", null, "password", "*****@*****.**", true, DateTime.Now);
            UserInfo u2 = prov.AddUser("user2", "User", "password", "*****@*****.**", false, DateTime.Now);

            Assert.IsTrue(prov.TestAccount(u1, "password"), "TestAccount should return true");
            Assert.IsFalse(prov.TestAccount(new UserInfo(u1.Username.ToUpperInvariant(), null, "*****@*****.**", true, DateTime.Now, prov), "password"), "TestAccount should return false");
            Assert.IsFalse(prov.TestAccount(u2, "password"), "TestAccount should return false because the account is disabled");
            Assert.IsFalse(prov.TestAccount(new UserInfo("blah", null, "*****@*****.**", true, DateTime.Now, prov), "blah"), "TestAccount should return false");
            Assert.IsFalse(prov.TestAccount(u1, "password222"), "TestAccount should return false");
            Assert.IsFalse(prov.TestAccount(u1, ""), "TestAccount should return false");
        }
예제 #3
0
        public void TestAccount_NullPassword()
        {
            IUsersStorageProviderV40 prov = GetProvider();

            prov.TestAccount(new UserInfo("blah", null, "*****@*****.**", true, DateTime.UtcNow, prov), null);
        }
예제 #4
0
        public void TestAccount_NullUser()
        {
            IUsersStorageProviderV40 prov = GetProvider();

            prov.TestAccount(null, "pass");
        }