Ejemplo n.º 1
0
        public void When_Adding_Web_Site__Then_It_Should_Be_Able_To_Be_Deleted()
        {
            var simpleRandom = DateTime.Now.Millisecond;
            var username = string.Format("testUser{0}", simpleRandom);
            const string password = "******";
            string fqdn = string.Format("www.testuser{0}.com", simpleRandom);

            var administrationService = new AdministrationService();

            // Test to see if we could add a new user.
            var addUser = administrationService.AddUser(username, password, fqdn);
            Assert.IsTrue(addUser);

            // Test to see if we could reset permissions on home directory.
            var resetPermissions = administrationService.ResetPermissions(username);
            Assert.IsTrue(resetPermissions);

            // Test to see if we could add a new host on IIS.
            var addHost = administrationService.AddHost(username, fqdn);
            Assert.IsTrue(addHost);

            // Test to see if we could delete the newly created host from IIS.
            var delHost = administrationService.DelHost(username, fqdn);
            Assert.IsTrue(delHost);

            // Test to see if we could delete the newly created user from Windows.
            var delUser = administrationService.DelUser(username);
            Assert.IsTrue(delUser);
        }
Ejemplo n.º 2
0
        public void When_Deleting_User__Then_It_Should_Removed_And_Dissappear_From_IIS_IUSRS_Group()
        {
            var username = string.Format("testUser{0}", DateTime.Now.Millisecond);
            var administration = new AdministrationService();
            var userAdded = administration.AddUser(username, "!Password123", "");
            Assert.IsTrue(userAdded);

            var userDeleted = administration.DelUser(username);
            Assert.IsTrue(userDeleted);

            var context = new PrincipalContext(ContextType.Machine);
            UserPrincipal user = UserPrincipal.FindByIdentity(context, username);
            Assert.IsNull(user);

            var grp = GroupPrincipal.FindByIdentity(context, "IIS_IUSRS");
            Assert.IsNotNull(grp);
            user = (UserPrincipal)grp.Members.FirstOrDefault(x => x.Name == username);
            Assert.IsNull(user);
        }
Ejemplo n.º 3
0
        public void When_Setting_NewPassword_On_User__Then_We_Should_Be_Able_To_Logon_With_New_Password()
        {
            var username = string.Format("testUser{0}", DateTime.Now.Millisecond);
            var administration = new AdministrationService();
            var userAdded = administration.AddUser(username, "!Password123", "");
            Assert.IsTrue(userAdded);

            var context = new PrincipalContext(ContextType.Machine);
            UserPrincipal user = UserPrincipal.FindByIdentity(context, username);
            Assert.IsNotNull(user);

            var validated = user.Context.ValidateCredentials(username, "!Password123");
            Assert.IsTrue(validated);

            var passwdChanged = administration.SetPasswd(username, "!Password321");
            Assert.IsTrue(passwdChanged);

            validated = user.Context.ValidateCredentials(username, "!Password321");
            Assert.IsTrue(validated);

            var userDeleted = administration.DelUser(username);
            Assert.IsTrue(userDeleted);
        }