示例#1
0
        public void UserManagementServiceUT_ChangePassword_ChangePasswordOfExistingUserSuccess(bool isTemp, string username, string name, string email,
                                                                                               string phoneNumber, string password, int disabled, string userType, string salt)
        {
            // Arrange: Create the user.
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, disabled, userType, salt);

            Assert.IsTrue(createResult);

            // Act: Change the user password digest.
            bool passwordResult = UserManagementServiceUT.ChangePassword(username, password, salt);

            Assert.IsTrue(passwordResult);

            // Assert: Read the user and make sure his password now matches the change.
            UserObject user = UserManagementServiceUT.GetUserInfo(username);
            bool       readResult;

            if (user.TempTimestamp == 0 && user.Username == username && user.Name == name && user.Email == email &&
                user.PhoneNumber == phoneNumber && user.Password == password && user.Disabled == disabled && user.UserType == userType && user.Salt == salt)
            {
                readResult = true;
            }
            else
            {
                readResult = false;
            }
            Assert.IsTrue(readResult);

            // Cleanup: Delete that user.
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }
示例#2
0
        public void UserManagementServiceUT_EnableUser_EnableADisabledUserSuccess(bool isTemp, string username, string name, string email,
                                                                                  string phoneNumber, string password, int disabled, string userType, string salt)
        {
            // Arrange: Create a disabled user.
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, disabled, userType, salt);

            Assert.IsTrue(createResult);

            // Act: Perform an enable operation on a disabled user.
            bool enableResult = UserManagementServiceUT.EnableUser(username);

            Assert.IsTrue(enableResult);

            // Assert: Check that the user is enabled.
            UserObject user = UserManagementServiceUT.GetUserInfo(username);
            bool       readResult;

            // User is disabled if user.Disabled == Constants.DisabledStatus
            if (user.TempTimestamp == Constants.NoValueLong && user.Username == username && user.Name == name && user.Email == email &&
                user.PhoneNumber == phoneNumber && user.Password == password && user.Disabled == Constants.EnabledStatus && user.UserType == userType && user.Salt == salt &&
                user.EmailCode == Constants.NoValueString && user.EmailCodeTimestamp == Constants.NoValueLong && user.EmailCodeFailures == Constants.NoValueInt)
            {
                readResult = true;
            }
            else
            {
                readResult = false;
            }
            Assert.IsTrue(readResult);

            // Cleanup: Delete that created user
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }
示例#3
0
        public void UserManagementServiceUT_StoreEmailCode_StoreEmailCodeForUserSuccess(bool isTemp, string username, string name, string email,
                                                                                        string phoneNumber, string password, int disabled, string userType, string salt, string emailCode, long emailCodeTimestamp)
        {
            // Arrange: Create a temporary user to be deleted
            UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, disabled, userType, salt);

            // Act: Store an email code for a user.
            bool result = UserManagementServiceUT.StoreEmailCode(username, emailCode, emailCodeTimestamp);

            Assert.IsTrue(result);

            // Assert: Read the email code and check if it did infact change.
            UserObject user = UserManagementServiceUT.GetUserInfo(username);
            bool       readResult;

            if (user.TempTimestamp == 0 && user.Username == username && user.Name == name && user.Email == email &&
                user.PhoneNumber == phoneNumber && user.Password == password && user.Disabled == disabled && user.UserType == userType && user.Salt == salt)
            {
                readResult = true;
            }
            else
            {
                readResult = false;
            }
            Assert.IsTrue(readResult);

            // Cleanup: Delete that user
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }
示例#4
0
        public void UserManagementServiceUT_MakeTempPerm_ChangeTempToPermSuccess(bool isTemp, string username, string name, string email,
                                                                                 string phoneNumber, string password, int disabled, string userType, string salt)
        {
            // Arrange: Create a temporary user to be deleted.
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, disabled, userType, salt);

            Assert.IsTrue(createResult);

            // Act: Make the temporary user perm
            bool result = UserManagementServiceUT.MakeTempPerm(username);

            Assert.IsTrue(result);

            // Assert: that the user is infact permanent.
            UserObject user = UserManagementServiceUT.GetUserInfo(username);

            bool readResult;

            // TempTimestamp == 0 when the user is permanent.
            if (user.TempTimestamp == 0 && user.Username == username && user.Name == name && user.Email == email &&
                user.PhoneNumber == phoneNumber && user.Password == password && user.Disabled == disabled && user.UserType == userType && user.Salt == salt)
            {
                readResult = true;
            }
            else
            {
                readResult = false;
            }
            Assert.IsTrue(readResult);

            // Cleanup: Delete that user
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }
示例#5
0
        public void UserManagementServiceUT_CreateUser_CreateNonExistentUserSuccess(bool isTemp, string username, string name, string email,
                                                                                    string phoneNumber, string password, int disabled, string userType, string salt)
        {
            // Act: Create the user.
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, disabled, userType, salt);

            // Assert: that user creation was successful
            Assert.IsTrue(createResult);

            // Read that user and assert that it has all the correct columns
            UserObject user = UserManagementServiceUT.GetUserInfo(username);
            bool       readResult;

            if (user.TempTimestamp == 0 && user.Username == username && user.Name == name && user.Email == email &&
                user.PhoneNumber == phoneNumber && user.Password == password && user.Disabled == disabled && user.UserType == userType && user.Salt == salt)
            {
                readResult = true;
            }
            else
            {
                readResult = false;
            }
            Assert.IsTrue(readResult);

            // Cleanup: Delete that user
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }
示例#6
0
        public void UserManagementServiceUT_CheckEmailExistence_EmailExistsSuccess(bool isTemp, string username, string name, string email,
                                                                                   string phoneNumber, string password, int isDisabled, string userType, string salt)
        {
            // Arrange: Create user.
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, isDisabled, userType, salt);

            Assert.IsTrue(createResult);

            // Act: check that an existing email returns true.
            bool result = UserManagementServiceUT.CheckEmailExistence(email);

            Assert.IsTrue(result);

            // Cleanup: Delete that user
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }
示例#7
0
        public void UserManagementServiceUT_EnableUser_EnableAEnabledUserFailure(bool isTemp, string username, string name, string email,
                                                                                 string phoneNumber, string password, int disabled, string userType, string salt)
        {
            // Arrange: Create a user that is enabled
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, disabled, userType, salt);

            Assert.IsTrue(createResult);

            // Act: Enable and already enabled user should return false.
            bool result = UserManagementServiceUT.EnableUser(username);

            Assert.IsFalse(result);

            // Cleanup: Delete that user.
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }
示例#8
0
        public void UserManagementServiceUT_DeleteUser_DeleteUserSuccess(bool isTemp, string username, string name, string email,
                                                                         string phoneNumber, string password, int disabled, string userType, string salt)
        {
            // Arrange: Create a user to be deleted
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, disabled, userType, salt);

            Assert.IsTrue(createResult);

            // Act: Delete the user
            bool result = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(result);

            // Assert: that the user is properly deleted from the table with CheckUserExistence
            bool existResult = UserManagementServiceUT.CheckUserExistence(username);

            Assert.IsFalse(existResult);
        }
示例#9
0
        public void UserManagementServiceUT_CheckIfUserDisabled_UserIsNotDisabledSuccess(bool isTemp, string username, string name, string email,
                                                                                         string phoneNumber, string password, int isDisabled, string userType, string salt)
        {
            // Arrange: Create user that is not diabled
            bool createResult = UserManagementServiceUT.CreateUser(isTemp, username, name, email, phoneNumber, password, isDisabled, userType, salt);

            Assert.IsTrue(createResult);

            // Act: Check that the non disabled returns false.
            bool result = UserManagementServiceUT.CheckIfUserDisabled(username);

            Assert.IsFalse(result);

            // Cleanup: Delete that user.
            bool deleteResult = UserManagementServiceUT.DeleteUser(username);

            Assert.IsTrue(deleteResult);
        }