Example #1
0
        public void Authentication_CheckUserodPassword()
        {
            Userod user = Security.CurUser;

            user.LoginDetails = Authentication.GenerateLoginDetails("awesomePassword", HashTypes.SHA3_512);
            bool result = Authentication.CheckPassword(user, "awesomePassword");

            Assert.IsTrue(result);
            Authentication.UpdatePasswordUserod(user, "awesomePassword");
            //If this is middletier, we need the password to match in our current user object to refill the cache
            Security.PasswordTyped = "awesomePassword";
            //Refresh our user object;
            Userods.RefreshCache();
            user = Userods.GetUser(user.UserNum);
            Assert.AreEqual(88, user.PasswordHash.Length);
            string passhash = Authentication.HashPasswordSHA512("awesomePassword", user.LoginDetails.Salt);

            Assert.IsTrue(Authentication.ConstantEquals(passhash, user.PasswordHash));
            //Reset Security.CurUser password back to the unit test password
            Authentication.UpdatePasswordUserod(user, UnitTestPassword);
            //Reset typed password
            Security.PasswordTyped = UnitTestPassword;
            Userods.RefreshCache();
            Security.CurUser = Userods.GetUser(user.UserNum);
        }
Example #2
0
        public void Authentication_UpdatePasswordSchema()
        {
            Userod user   = Security.CurUser;
            bool   result = Authentication.UpdatePasswordUserod(user, "brandSpankinNewPassword", HashTypes.SHA3_512);

            //If this is middletier, we need the password to match in our current user object to refill the cache
            Security.PasswordTyped = "brandSpankinNewPassword";
            Userods.RefreshCache();
            user = Userods.GetUser(user.UserNum);
            Assert.IsTrue(result);
            result = Authentication.CheckPassword(user, "brandSpankinNewPassword");
            Assert.IsTrue(result);
            //Reset Security.CurUser password back to the unit test password
            Authentication.UpdatePasswordUserod(user, UnitTestPassword, HashTypes.SHA3_512);
            //Reset typed password
            Security.PasswordTyped = UnitTestPassword;
            Userods.RefreshCache();
            Security.CurUser = Userods.GetUser(user.UserNum);
        }
Example #3
0
 public static void CreateUnitTestUser()
 {
     if (Userods.GetUserByName(UnitTestUserName, false) == null)
     {
         Userod newUser = new Userod()
         {
             UserName = UnitTestUserName,
             Password = Userods.HashPassword(UnitTestPassword),
         };
         try {
             Userods.Insert(newUser, new List <long> {
                 1
             });
             Userods.RefreshCache();
         }
         catch (Exception e) {
             throw new Exception("Unable to create the default Unit Test user.", e);
         }
     }
 }
Example #4
0
        public static void SetupClass(TestContext testContext)
        {
            _defRegionN = DefT.CreateDefinition(DefCat.Regions, "RegionN", "RegionN");
            _defRegionS = DefT.CreateDefinition(DefCat.Regions, "RegionS", "RegionS");
            _clinicN    = ClinicT.CreateClinic("ClinicN", regionDef: _defRegionN);
            _clinicNW   = ClinicT.CreateClinic("ClinicNW", regionDef: _defRegionN);
            _clinicS    = ClinicT.CreateClinic("ClinicS", regionDef: _defRegionS);
            _patN       = PatientT.CreatePatient("Tasks", clinicNum: _clinicN.ClinicNum, lName: _clinicN.Description, fName: "Patient");
            _patS       = PatientT.CreatePatient("Tasks", clinicNum: _clinicS.ClinicNum, lName: _clinicS.Description, fName: "Patient");
            _userA      = UserodT.CreateUser(userName: "******", clinicNum: _clinicN.ClinicNum, isClinicIsRestricted: false);
            _userNW     = UserodT.CreateUser(userName: "******", clinicNum: _clinicNW.ClinicNum, isClinicIsRestricted: true);
            Userods.RefreshCache();
            List <UserClinic> listUserClinics = new List <UserClinic>()
            {
                new UserClinic(_clinicNW.ClinicNum, _userNW.UserNum)
            };

            if (UserClinics.Sync(listUserClinics, _userNW.UserNum))            //Either syncs new list, or clears old list if no longer restricted.
            {
                UserClinics.RefreshCache();
            }
        }
Example #5
0
 private void FillListBox()
 {
     Userods.RefreshCache();
     UserGroups.RefreshCache();
     GroupPermissions.RefreshCache();
     listUser.BeginUpdate();
     listUser.Items.Clear();
     if (PrefC.GetBool(PrefName.UserNameManualEntry))
     {
         //Because _listUsers is used to verify the user name typed in, we need to include both non-hidden and CEMT users for offices that type in their credentials instead of picking.
         _listUsers = Userods.GetUsers(true);
     }
     else              //This will be the most common way to fill the user list.  Includes CEMT users.
     {
         _listUsers = Userods.GetUsers(true);
     }
     for (int i = 0; i < _listUsers.Count; i++)
     {
         listUser.Items.Add(_listUsers[i]);
     }
     listUser.SelectedIndex = 0;
     listUser.EndUpdate();
 }
 public void SetupTest()
 {
     TaskListT.ClearTaskListTable();
     TaskT.ClearTaskTable();
     TaskSubscriptionT.ClearTaskSubscriptionTable();
     SignalodT.ClearSignalodTable();
     _taskListParent     = TaskListT.CreateTaskList(descript: "TaskListParent");
     _taskListChild      = TaskListT.CreateTaskList(descript: "TaskListChild", parent: _taskListParent.TaskListNum, parentDesc: _taskListParent.Descript);
     _taskListGrandchild = TaskListT.CreateTaskList(descript: "TaskListGrandchild", parent: _taskListChild.TaskListNum,
                                                    parentDesc: _taskListChild.Descript);
     _task = TaskT.CreateTask(_taskListGrandchild.TaskListNum, descript: "Test Task", fromNum: Security.CurUser.UserNum, priorityDefNum: 1); //Starts in _taskListGrandchild
     TaskSubscriptionT.CreateTaskSubscription(Security.CurUser.UserNum, _taskListParent.TaskListNum);                                        //current user subscribes to top level tasklist.
     Security.CurUser.TaskListInBox = _taskListParent.TaskListNum;                                                                           //Set inbox for current user to _taskListParent.
     try {
         Userods.Update(Security.CurUser);
         Userods.RefreshCache();
     }
     catch {
         Assert.Fail("Failed to update current user task list inbox.");                //Error updating user.
     }
     _formTaskEditInstance = new FormTaskEdit(_task);
     _formTaskEditAccessor = new PrivateObject(_formTaskEditInstance);
     _formTaskEditAccessor.Invoke("LoadTask");
 }
Example #7
0
        ///<summary>Inserts the new user, refreshes the cache and then returns UserNum</summary>
        public static Userod CreateUser(string userName = "", string password = "", List <long> userGroupNumbers = null, long clinicNum = 0, bool isClinicIsRestricted = false)
        {
            if (userName == "")
            {
                userName = "******" + MiscUtils.CreateRandomAlphaNumericString(8);
            }
            if (password == "")
            {
                password = "******";
            }
            if (userGroupNumbers == null)
            {
                userGroupNumbers = new List <long> {
                    1
                };
            }
            Userod newUser = new Userod();

            newUser.UserName           = userName;
            newUser.LoginDetails       = Authentication.GenerateLoginDetails(password, HashTypes.SHA3_512);
            newUser.ClinicNum          = clinicNum;
            newUser.ClinicIsRestricted = isClinicIsRestricted;
            do
            {
                //In case the username is already taken
                try {
                    newUser.UserNum = Userods.Insert(newUser, userGroupNumbers);
                }
                catch {
                    newUser.UserName = "******" + MiscUtils.CreateRandomAlphaNumericString(8);
                }
            }while(newUser.UserNum == 0);
            Userods.RefreshCache();
            UserGroupAttaches.RefreshCache();
            return(newUser);
        }