Ejemplo n.º 1
0
        public void SingleUpdateUser_Fail_InvalidPermissions()
        {
            // Arrange
            bool result = true;

            // Initializing User objects to test

            // User to delete from DB
            User u1 = new User(1, null, null, null, "password", null, "System Admin", true, null);

            // User performing operation
            User thisUser = new User(111, null, null, null, "meMEeiaj093QNGEJOW~~~", null, "Admin", true, null);

            Stopwatch stopwatch = new Stopwatch();

            _userManagementManager.SingleCreateUsers(u1, thisUser);

            // Act
            stopwatch.Start();
            try
            {
                u1.FirstName = "Barry"; // lets see if this works
                result       = _userManagementManager.SingleUpdateUser(thisUser, u1, "FirstName");
            }
            catch (ArgumentException)
            {
                result = false;
            }
            catch (Exception) { }
            stopwatch.Stop();
            Console.WriteLine("Elapsed = {0} ms", stopwatch.ElapsedMilliseconds);

            // Assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 2
0
        public IActionResult SingleUpdateUser(User operatedUser, string accountType)
        {
            User invokingUser = new User(0, null, null, null, null, null, accountType, true, null);

            try
            {
                return(Ok(_userManagementManager.SingleUpdateUser(invokingUser, operatedUser, "Password")));
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 3
0
        public void SingleUpdateUser_Pass(int sysID, string fName, string lName, string email,
                                          string password, string salt, string accntType, bool accountStatus, string errMsg)
        {
            // Arrange

            // Initializing User objects to test

            // User to update in DB
            User user = new User(sysID, fName, lName, email, password, salt, accntType, accountStatus, errMsg);

            // User performing operation
            User thisUser = new User(109, null, null, null, "meMEeiaj093QNGEJOW~~~", null, "System Admin", true, null);
            var  um       = new UserManagementManager();
            bool result;

            // Act
            um.SingleCreateUsers(thisUser, user);
            try
            {
                string nameChange = "Bob";
                user.FirstName = nameChange;                                       //attempts to change the user's name to Bob
                result         = um.SingleUpdateUser(thisUser, user, "FirstName"); //then pushes the update
                //TODO: wait... shouldnt we test to see IF our DB is changing values?
            }
            catch (ArgumentException)
            {
                result = false;
            }
            catch (Exception) { result = false; }

            // Assert
            Assert.IsTrue(result);
        }