public void TestCreatePrisonUser_UserExist() { using (ShimsContext.Create()) { ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return(true); }; PrisonUser user = new PrisonUser("untst"); user.Create(); } }
public void TestCreatePrisonUser_UserExist() { using (ShimsContext.Create()) { ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return true; }; PrisonUser user = new PrisonUser("untst"); user.Create(); } }
public void TestDeletePrisonUser_UserDoNotExist() { using (ShimsContext.Create()) { ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return(false); }; ShimWindowsUsersAndGroups.CreateUserStringString = (username, password) => { return; }; ShimWindowsUsersAndGroups.GetLocalUserSidString = (username) => { return("a string"); }; PrisonUser user = new PrisonUser("untst"); user.Create(); ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return(false); }; user.Delete(); } }
public void CreateAndDeleteUser() { // Arrange PrisonUser user = new PrisonUser("untst"); // Act user.Create(); // Assert Assert.IsTrue(PrisonUser.ListUsers("untst").Any(u => u.Username == user.Username)); // Act user.Delete(); // Assert Assert.IsFalse(PrisonUser.ListUsers("untst").Any(u => u.Username == user.Username)); }
public void CreateAndDeleteUser() { // Arrange PrisonUser user = new PrisonUser("untst"); // Act user.Create(); // Assert Assert.IsTrue(PrisonUser.ListOrphanedUsers("untst").Contains(user.UserName)); // Act user.Delete(); // Assert Assert.IsFalse(PrisonUser.ListOrphanedUsers("untst").Contains(user.UserName)); }
public static void InitOpenDirectoriesList() { string[] result = null; lock (openDirLock) { PrisonUser isolationUser = new PrisonUser("acl"); isolationUser.Create(); using (new UserImpersonator(isolationUser.Username, ".", isolationUser.Password, true)) { result = GetOpenDirectories(new DirectoryInfo(@"c:\")).ToArray(); } isolationUser.Delete(); openDirs = result; } }
public void TestDeletePrisonUserOK() { using (ShimsContext.Create()) { ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return(false); }; ShimWindowsUsersAndGroups.CreateUserStringString = (username, password) => { return; }; ShimWindowsUsersAndGroups.GetLocalUserSidString = (username) => { return("a string"); }; PrisonUser user = new PrisonUser("untst"); user.Create(); ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return(true); }; ShimWindowsUsersAndGroups.DeleteUserString = (username) => { return; }; user.Delete(); ShimWindowsUsersAndGroups.GetUsers = () => { return(new string[] { "Administrator", "Guest", "openshift_service" }); }; PrisonUser[] users = PrisonUser.ListUsers("untst"); Assert.IsTrue(Array.Find(users, u => u.Username == user.Username) == null); } }
public void TestGrantAndRevokeTokenPrivilege() { // Arrange PrisonUser newUser = new PrisonUser("prtst"); try { newUser.Create(); bool hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege( UserRightsAssignmentPolicies.ReplaceTokenPrivilege, newUser.UserName); Assert.IsFalse(hasPrivilege); // Act UserRightsAssignmentPolicies.GrantPrivilegeToUser( UserRightsAssignmentPolicies.ReplaceTokenPrivilege, newUser.UserName); hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege( UserRightsAssignmentPolicies.ReplaceTokenPrivilege, newUser.UserName); // Assert Assert.IsTrue(hasPrivilege); // Act UserRightsAssignmentPolicies.RevokePrivilegeToUser( UserRightsAssignmentPolicies.ReplaceTokenPrivilege, newUser.UserName); hasPrivilege = UserRightsAssignmentPolicies.UserHasPrivilege( UserRightsAssignmentPolicies.ReplaceTokenPrivilege, newUser.UserName); // Assert Assert.IsFalse(hasPrivilege); } finally { newUser.Delete(); } }
public void TestCreatePrisonUserOK() { using (ShimsContext.Create()) { string newuser = string.Empty; ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return(false); }; ShimWindowsUsersAndGroups.CreateUserStringString = (username, password) => { newuser = username; return; }; ShimWindowsUsersAndGroups.GetLocalUserSidString = (username) => { return("a string"); }; ShimPersistence.SaveValueStringStringObject = (group, key, value) => { return; }; PrisonUser user = new PrisonUser("untst"); user.Create(); ShimWindowsUsersAndGroups.GetUsers = () => { return(new string [] { "Administrator", "Guest", "openshift_service", newuser }); }; PrisonTestsHelper.PersistanceReadDataFake(newuser); PrisonUser[] users = PrisonUser.ListUsers("untst"); Assert.IsTrue(Array.Find(users, u => u.Username == user.Username) != null); } }
public void TestCreatePrisonUserOK() { using (ShimsContext.Create()) { string newuser = string.Empty; ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return false; }; ShimWindowsUsersAndGroups.CreateUserStringString = (username, password) => { newuser = username; return; }; ShimWindowsUsersAndGroups.GetLocalUserSidString = (username) => { return "a string"; }; ShimPersistence.SaveValueStringStringObject = (group, key, value) => { return; }; PrisonUser user = new PrisonUser("untst"); user.Create(); ShimWindowsUsersAndGroups.GetUsers = () => { return new string [] { "Administrator", "Guest", "openshift_service", newuser }; }; PrisonTestsHelper.PersistanceReadDataFake(newuser); PrisonUser[] users = PrisonUser.ListUsers("untst"); Assert.IsTrue(Array.Find(users, u => u.Username == user.Username) != null); } }
public void TestDeletePrisonUserOK() { using (ShimsContext.Create()) { ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return false; }; ShimWindowsUsersAndGroups.CreateUserStringString = (username, password) => { return; }; ShimWindowsUsersAndGroups.GetLocalUserSidString = (username) => { return "a string"; }; PrisonUser user = new PrisonUser("untst"); user.Create(); ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return true; }; ShimWindowsUsersAndGroups.DeleteUserString = (username) => { return; }; user.Delete(); ShimWindowsUsersAndGroups.GetUsers = () => { return new string[] { "Administrator", "Guest", "openshift_service"}; }; PrisonUser[] users = PrisonUser.ListUsers("untst"); Assert.IsTrue(Array.Find(users, u => u.Username == user.Username) == null); } }
public void TestDeletePrisonUser_UserDoNotExist() { using (ShimsContext.Create()) { ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return false; }; ShimWindowsUsersAndGroups.CreateUserStringString = (username, password) => { return; }; ShimWindowsUsersAndGroups.GetLocalUserSidString = (username) => { return "a string"; }; PrisonUser user = new PrisonUser("untst"); user.Create(); ShimWindowsUsersAndGroups.ExistsUserString = (username) => { return false; }; user.Delete(); } }