Пример #1
0
        public void Setup()
        {
            var memStream = new MemoryStream(Encoding.UTF8.GetBytes(_json));

            var parser = new EnvConfigParser();
            _config = parser.GetTypedEnvConfig(memStream, null);
        }
Пример #2
0
        public string Serialize(ConDepEnvConfig config)
        {
            var json          = JsonConvert.SerializeObject(config, JsonSettings);
            var encryptedJson = _crypto.Encrypt(json);

            return(encryptedJson);
        }
Пример #3
0
 public string Serialize(ConDepEnvConfig config)
 {
     using (var stringWriter = new StringWriter())
     {
         var serializer = new Serializer();
         serializer.Serialize(stringWriter, config);
         return(stringWriter.ToString());
     }
 }
        public void Setup()
        {
            var app = new OnlyIfTestApp();

            var config = new ConDepEnvConfig { EnvironmentName = "bogusEnv" };
            var server = new ServerConfig { Name = "bogusHost" };
            config.Servers = new[] { server };

            _sequenceManager = new ExecutionSequenceManager(config.Servers, new DefaultLoadBalancer());

            var settings = new ConDepSettings { Config = config };

            var local = new LocalOperationsBuilder(_sequenceManager.NewLocalSequence("Test"));
            app.Configure(local, settings);

            _serverInfo = new ServerInfo {OperatingSystem = new OperatingSystemInfo {Name = "Windows Server 2012"}};
        }
        public void TestThatExecutionSequenceIsValid()
        {
            var config = new ConDepEnvConfig {EnvironmentName = "bogusEnv"};
            var server = new ServerConfig { Name = "jat-web03" };
            config.Servers = new[] { server };

            var sequenceManager = new ExecutionSequenceManager(config.Servers, new DefaultLoadBalancer());

            var settings = new ConDepSettings();
            settings.Config = config;

            var local = new LocalOperationsBuilder(sequenceManager.NewLocalSequence("Test"));
            //Configure.LocalOperations = local;
            _app.Configure(local, settings);

            var notification = new Notification();
            Assert.That(sequenceManager.IsValid(notification));
        }
Пример #6
0
        public ConDepEnvConfig GetTypedEnvConfig(Stream stream, string cryptoKey)
        {
            ConDepEnvConfig config = _configSerializer.DeSerialize(stream);

            //if (Encrypted(json, out jsonModel))
            //{
            //    if (string.IsNullOrWhiteSpace(cryptoKey))
            //    {
            //        throw new ConDepCryptoException(
            //            "ConDep configuration is encrypted, so a decryption key is needed. Specify using -k switch.");
            //    }
            //    var crypto = new JsonPasswordCrypto(cryptoKey);
            //    DecryptJsonConfig(jsonModel, crypto);
            //    config = ((JObject)jsonModel).ToObject<ConDepEnvConfig>();
            //}
            //else
            //{
            //    config = JsonConvert.DeserializeObject<ConDepEnvConfig>(json, JsonSettings);
            //}

            if (config.Servers != null && config.Tiers != null)
            {
                throw new ConDepConfigurationException(
                          "You cannot define both Tiers and Servers at the same level. Either you use Tiers and define servers for each tier or you use Servers without Tiers. Servers without Tiers would be the same as having just one Tier.");
            }

            if (config.Servers == null)
            {
                config.Servers = new List <ServerConfig>();
            }

            if (config.Node.Port == null)
            {
                config.Node.Port = 4444;
            }
            if (config.Node.TimeoutInSeconds == null)
            {
                config.Node.TimeoutInSeconds = 100;
            }

            if (config.PowerShell.HttpPort == null)
            {
                config.PowerShell.HttpPort = 5985;
            }
            if (config.PowerShell.HttpsPort == null)
            {
                config.PowerShell.HttpsPort = 5986;
            }

            foreach (var server in config.UsingTiers ? config.Tiers.SelectMany(x => x.Servers) : config.Servers)
            {
                if (server.Node == null)
                {
                    server.Node = config.Node;
                }

                if (server.PowerShell == null)
                {
                    server.PowerShell = config.PowerShell;
                }

                if (!server.DeploymentUser.IsDefined())
                {
                    server.DeploymentUser = config.DeploymentUser;
                }

                if (server.Node.Port == null)
                {
                    server.Node.Port = config.Node.Port;
                }
                if (server.Node.TimeoutInSeconds == null)
                {
                    server.Node.TimeoutInSeconds = config.Node.TimeoutInSeconds;
                }

                if (server.PowerShell.HttpPort == null)
                {
                    server.PowerShell.HttpPort = config.PowerShell.HttpPort;
                }
                if (server.PowerShell.HttpsPort == null)
                {
                    server.PowerShell.HttpsPort = config.PowerShell.HttpsPort;
                }
            }
            return(config);
        }
Пример #7
0
 public ConDepSettings()
 {
     Config  = new ConDepEnvConfig();
     Options = new ConDepOptions();
 }
Пример #8
0
 public ConDepSettings()
 {
     Config = new ConDepEnvConfig();
     Options = new ConDepOptions();
 }
        private void SaveExecutionPathScriptsToFolder(string localTargetPath, ConDepEnvConfig config)
        {
            var currDir = Directory.GetCurrentDirectory();

            foreach (var psDir in config.PowerShellScriptFolders)
            {
                var absPath = Path.Combine(currDir, psDir);
                if(!Directory.Exists(absPath)) throw new DirectoryNotFoundException(absPath);

                var dirInfo = new DirectoryInfo(absPath);
                var files = dirInfo.GetFiles("*.ps1", SearchOption.TopDirectoryOnly);
                foreach (var file in files.Select(x => x.FullName))
                {
                    File.Copy(file, Path.Combine(localTargetPath, Path.GetFileName(file)));
                }
            }
        }
Пример #10
0
 public void TestThatEmptyPowerShellScriptFoldersIsNotNullAndEmpty()
 {
     var config = new ConDepEnvConfig();
     Assert.That(config.PowerShellScriptFolders, Is.Not.Null);
     Assert.That(config.PowerShellScriptFolders.Length, Is.EqualTo(0));
 }
Пример #11
0
        public void Setup()
        {
            var memStream = new MemoryStream(Encoding.UTF8.GetBytes(_json));
            var tiersMemStream = new MemoryStream(Encoding.UTF8.GetBytes(_tiersJson));

            _cryptoKey = JsonPasswordCrypto.GenerateKey(256);
            var parser = new EnvConfigParser(new JsonSerializer<ConDepEnvConfig>(new JsonConfigCrypto(_cryptoKey)));
            _config = parser.GetTypedEnvConfig(memStream);
            _tiersConfig = parser.GetTypedEnvConfig(tiersMemStream);
        }