Execute() public method

public Execute ( StringBuilder>.Dictionary values, IWorkspace theWorkspace ) : StringBuilder
values StringBuilder>.Dictionary
theWorkspace IWorkspace
return StringBuilder
 public void SecurityWrite_Execute_NoValuesPassed_ExceptionThrown()
 {
     //------------Setup for test--------------------------
     var securityWrite = new SecurityWrite();
     //------------Execute Test---------------------------
     securityWrite.Execute(null, null);
     //------------Assert Results-------------------------
 }
 public void SecurityWrite_Execute_SecuritySettingsValuePassedNotValidJSON_ExceptionThrown()
 {
     //------------Setup for test--------------------------
     var securityWrite = new SecurityWrite();
     //------------Execute Test---------------------------
     securityWrite.Execute(new Dictionary<string, StringBuilder> { { "SecuritySettings", new StringBuilder("Something") } }, null);
     //------------Assert Results-------------------------
 }
示例#3
0
 public void SecurityWrite_Execute_SecuritySettingsValuePassedValidJSON_ShouldWriteFile()
 {
     //------------Setup for test--------------------------
     var permission = new WindowsGroupPermission { Administrator = true, IsServer = true, WindowsGroup = Environment.UserName };
     var windowsGroupPermissions = new List<WindowsGroupPermission> { permission };
     var securitySettings = new SecuritySettingsTO(windowsGroupPermissions) { CacheTimeout = new TimeSpan(0, 2, 0) };
     var securitySettingsValue = JsonConvert.SerializeObject(securitySettings);
     var securityWrite = new SecurityWrite();
     //------------Execute Test---------------------------
     securityWrite.Execute(new Dictionary<string, StringBuilder> { { "SecuritySettings", new StringBuilder(securitySettingsValue) } }, null);
     //------------Assert Results-------------------------
     Assert.IsTrue(File.Exists("secure.config"));
     var fileData = File.ReadAllText("secure.config");
     Assert.IsFalse(fileData.StartsWith("{"));
     Assert.IsFalse(fileData.EndsWith("}"));
     Assert.IsFalse(fileData.Contains("IsServer"));
     File.Delete("secure.config");
 }
        public void SecurityRead_Execute_WhenSecureConfigDoesExistWithNoGuestPermission_ShouldHaveExistingPermissionsAndGuest()
        {
            //------------Setup for test--------------------------
            if(File.Exists("secure.config"))
            {
                File.Delete("secure.config");
            }
            var permission = new WindowsGroupPermission { Administrator = true, IsServer = true, WindowsGroup = Environment.UserName };
            var permission2 = new WindowsGroupPermission { Administrator = false, DeployFrom = false, IsServer = true, WindowsGroup = "NETWORK SERVICE" };
            var windowsGroupPermissions = new List<WindowsGroupPermission> { permission, permission2 };
            var securitySettings = new SecuritySettingsTO(windowsGroupPermissions) { CacheTimeout = new TimeSpan(0, 10, 0) };
            var serializeObject = JsonConvert.SerializeObject(securitySettings);
            var securityWrite = new SecurityWrite();
            var securityRead = new SecurityRead();
            securityWrite.Execute(new Dictionary<string, StringBuilder> { { "SecuritySettings", new StringBuilder(serializeObject) } }, null);
            //------------Assert Preconditions-------------------------
            Assert.IsTrue(File.Exists("secure.config"));
            //------------Execute Test---------------------------
            var jsonPermissions = securityRead.Execute(null, null);
            File.Delete("secure.config");
            var readSecuritySettings = JsonConvert.DeserializeObject<SecuritySettingsTO>(jsonPermissions.ToString());
            //------------Assert Results-------------------------
            Assert.AreEqual(4, readSecuritySettings.WindowsGroupPermissions.Count);
            var guestPermission = readSecuritySettings.WindowsGroupPermissions.FirstOrDefault(p => p.WindowsGroup == WindowsGroupPermission.BuiltInGuestsText);
            Assert.IsNotNull(guestPermission);
            Assert.AreEqual(true, guestPermission.IsServer);
            Assert.AreEqual(false, guestPermission.View);
            Assert.AreEqual(false, guestPermission.Execute);
            Assert.AreEqual(false, guestPermission.Contribute);
            Assert.AreEqual(false, guestPermission.DeployTo);
            Assert.AreEqual(false, guestPermission.DeployFrom);
            Assert.AreEqual(false, guestPermission.Administrator);

            var networkServicePermission = readSecuritySettings.WindowsGroupPermissions.FirstOrDefault(p => p.WindowsGroup == "NETWORK SERVICE");
            Assert.IsNotNull(networkServicePermission);
            Assert.AreEqual(true, networkServicePermission.IsServer);
            Assert.AreEqual(false, networkServicePermission.View);
            Assert.AreEqual(false, networkServicePermission.Execute);
            Assert.AreEqual(false, networkServicePermission.Contribute);
            Assert.AreEqual(false, networkServicePermission.DeployTo);
            Assert.AreEqual(false, networkServicePermission.DeployFrom);
            Assert.AreEqual(false, networkServicePermission.Administrator);

            var userPermission = readSecuritySettings.WindowsGroupPermissions.FirstOrDefault(p => p.WindowsGroup == Environment.UserName);
            Assert.IsNotNull(userPermission);
            Assert.AreEqual(true, userPermission.IsServer);
            Assert.AreEqual(false, userPermission.View);
            Assert.AreEqual(false, userPermission.Execute);
            Assert.AreEqual(false, userPermission.Contribute);
            Assert.AreEqual(false, userPermission.DeployTo);
            Assert.AreEqual(false, userPermission.DeployFrom);
            Assert.AreEqual(true, userPermission.Administrator);

            Assert.AreEqual(new TimeSpan(0, 10, 0), readSecuritySettings.CacheTimeout);
        }