示例#1
0
        public void UserManagementServiceUT_CheckEmailExistence_EmailDoesNotExistsFailure(string email)
        {
            // Act: check that a non existing email returns false.
            bool result = UserManagementServiceUT.CheckEmailExistence(email);

            Assert.IsFalse(result);
        }
示例#2
0
        public void UserManagementServiceUT_CheckPhoneNumberExistence_PhoneNumberDoesNotExistsFailure(string phoneNumber)
        {
            // Act: Check that a nonexistent phonenumber returns false.
            bool result = UserManagementServiceUT.CheckPhoneNumberExistence(phoneNumber);

            Assert.IsFalse(result);
        }
示例#3
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);
        }
示例#4
0
        public void UserManagementServiceUT_NotifySystemAdmin_SendEmailToSystemAdminSuccess(string body)
        {
            // Act: Check that a successfull message to system admin returns true.
            bool notifyResult = UserManagementServiceUT.NotifySystemAdmin(body, Constants.SystemAdminEmailAddress);

            Assert.IsTrue(notifyResult);
        }
示例#5
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);
        }
示例#6
0
        public void UserManagementServiceUT_CheckUserExistence_UserDoesNotExistsFailure(string username)
        {
            // Assert: Check that an non existing user returns false.
            bool result = UserManagementServiceUT.CheckUserExistence(username);

            Assert.IsFalse(result);
        }
示例#7
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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
0
        public void UserManagementServiceUT_CheckIPLock_IpIsNotDisabledSuccess(string ipAddress)
        {
            // Act:  Check that an non existent ip returns ArgumentExcpetions because ip does not exists.
            bool result;

            try
            {
                UserManagementServiceUT.CheckIfIPLocked(ipAddress);
                result = false;
            }
            catch
            {
                result = true;
            }
            Assert.IsTrue(result);
        }
示例#11
0
        public void UserManagementServiceUT_DisableUserName_DisableNonExistingUserFailure(string username)
        {
            // Act: disabling a non existent user should throw an ArgumentException because the user doesn't exists.
            bool result;

            try
            {
                UserManagementServiceUT.DisableUser(username);
                result = false;
            }
            catch
            {
                result = true;
            }

            Assert.IsTrue(result);
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
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);
        }
示例#15
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);
        }
示例#16
0
        public void UserManagementServiceUT_CheckIfIPLocked_IpIsDisabledSuccess(string ipAddress)
        {
            // Arrange: Insert Ip into ip table.
            bool lockResult = UserManagementServiceUT.CreateIP(ipAddress);

            Assert.IsTrue(lockResult);

            // Arrange: Attempt to faile to register 3 times.
            // IPs: Are only locked this way.
            for (int i = 0; i < 3; i++)
            {
                bool registerResult = UserManagementServiceUT.IncrementRegistrationFailures(ipAddress, Constants.RegistrationTriesResetTime, Constants.MaxRegistrationAttempts);
                Assert.IsTrue(registerResult);
            }


            // Act
            bool result = UserManagementServiceUT.CheckIfIPLocked(ipAddress);

            // Assert: Check that an IP that is inserted returns true.
            Assert.IsTrue(result);
        }