Exemple #1
0
        protected async Task OutputFolderContentsMatchesFolderContentsOf(string name)
        {
            var folder = name.StartsWith("Folder") ? name : MakeFolderName(name);

            Debug.WriteLine(Directory.GetCurrentDirectory());

            var kongReader        = new KongAdminReader(new KongAdminHttpClient(new KongAdminApiConnectionDetails()));
            var kongConfiguration = await kongReader.GetConfiguration();

            var schemas             = kongConfiguration.GetSchemas(kongReader);
            var configReader        = new ConfigFileReader(new PhysicalFileProvider());
            var folderConfiguration = await configReader.ReadConfiguration(folder, schemas);

            var outputConfiguration = await configReader.ReadConfiguration(OutputFolder, schemas);

            folderConfiguration.GlobalConfig.Plugins.Should().NotBeEmpty();
            folderConfiguration.Services.Count.Should().Be(3);

            outputConfiguration.GlobalConfig.Plugins.Should().BeEquivalentTo(folderConfiguration.GlobalConfig.Plugins);
            outputConfiguration.Services.Should().BeEquivalentTo(folderConfiguration.Services);
            foreach (var outputService in outputConfiguration.Services)
            {
                var folderService = folderConfiguration.Services.Single(x => x.Name == outputService.Name);
                outputService.Plugins.Should().BeEquivalentTo(folderService.Plugins);
                outputService.Routes.Should().BeEquivalentTo(folderService.Routes);
                foreach (var outputServiceRoute in outputService.Routes)
                {
                    var folderServiceRoute = folderService.Routes.Single(x => x.Equals(outputServiceRoute));
                    outputServiceRoute.Plugins.Should().BeEquivalentTo(folderServiceRoute.Plugins);
                }
            }
        }
Exemple #2
0
        protected async Task OutputFolderContentsMatchesFolderContentsOf(string name)
        {
            var folder = name.StartsWith("Folder") ? name : MakeFolderName(name);

            Debug.WriteLine(Directory.GetCurrentDirectory());

            var kongReader        = new KongAdminReader(new KongAdminHttpClient(new KongAdminApiConnectionDetails()));
            var kongConfiguration = await kongReader.GetConfiguration();

            var availablePlugins    = kongConfiguration.Plugins.Available.Where(x => x.Value).Select(x => x.Key).ToDictionary(x => x, x => new AsyncLazy <KongPluginSchema>(() => kongReader.GetPluginSchema(x)));
            var configReader        = new ConfigFileReader();
            var folderConfiguration = await configReader.ReadConfiguration(folder, availablePlugins);

            var outputConfiguration = await configReader.ReadConfiguration(OutputFolder, availablePlugins);

            folderConfiguration.GlobalConfig.Plugins.Should().NotBeEmpty();
            folderConfiguration.Services.Count.Should().Be(3);

            outputConfiguration.GlobalConfig.Plugins.Should().BeEquivalentTo(folderConfiguration.GlobalConfig.Plugins);
            outputConfiguration.Services.Should().BeEquivalentTo(folderConfiguration.Services);
            foreach (var outputService in outputConfiguration.Services)
            {
                var folderService = folderConfiguration.Services.Single(x => x.Name == outputService.Name);
                outputService.Plugins.Should().BeEquivalentTo(folderService.Plugins);
                outputService.Routes.Should().BeEquivalentTo(folderService.Routes);
                foreach (var outputServiceRoute in outputService.Routes)
                {
                    var folderServiceRoute = folderService.Routes.Single(x => x.Equals(outputServiceRoute));
                    outputServiceRoute.Plugins.Should().BeEquivalentTo(folderServiceRoute.Plugins);
                }
            }
        }
Exemple #3
0
        public void TestCreateConfigByFile_CommandKeys()
        {
            var reader = new ConfigFileReader(ReadText);
            var config = reader.CreateConfigByFile();

            Assert.Equal(1, config.commandKeys.Count());
        }
        public void UpdateLayersThisDrawing()
        {
            string configPath     = string.Empty;
            var    projectLocator = new LocateFileProject();

            configPath = projectLocator.returnConfigFilePath();

            if (string.IsNullOrEmpty(configPath))
            {
                var res = System.Windows.Forms.MessageBox.Show("Drawing is not connected to a project. Do you want to create a new project?", "Drawing not connected to project", System.Windows.Forms.MessageBoxButtons.YesNo);
                if (res == System.Windows.Forms.DialogResult.Yes)
                {
                    UpdateLayers();
                }
                return;
            }

            var reader = new ConfigFileReader();

            propertyList = reader.readConfigFile(configPath);

            Document document = Application.DocumentManager.MdiActiveDocument;

            ModifyOpenDrawing(document);

            document.Editor.WriteMessage("\nModified " + layersModified + " out of " + totalLayers + " layers\n");
        }
Exemple #5
0
        public void TestCreateConfigByFile_MappedKeys()
        {
            var reader = new ConfigFileReader(ReadText);
            var config = reader.CreateConfigByFile();

            Assert.Equal(4, config.mappedKeys.Count());
        }
 /// <summary>
 /// Gets this instance.
 /// </summary>
 /// <returns></returns>
 public HttpResponseMessage Get()
 {
     var serverConfigDetails = new ConfigFileReader().GetAllServerDetailsFromConfig();
     return serverConfigDetails.Any()
         ? Request.CreateResponse(HttpStatusCode.OK, serverConfigDetails)
         : Request.CreateErrorResponse(HttpStatusCode.NotFound, "No results found");
 }
Exemple #7
0
        public void IgnoreMatchingNone()
        {
            var xml =
                @"<RecursiveCleaner>
    <Ignore>
        <MatchingNone>            
            <OlderThan seconds='1' />
            <Regex>.*</Regex>
            <Wildcards>*.*</Wildcards>
        </MatchingNone>       
    </Ignore>
</RecursiveCleaner>";

            using (var file = new TemporaryFile {
                Contents = xml
            })
            {
                var rules = ConfigFileReader.Read(file.Path).ToArray();
                Assert.AreEqual(1, rules.Length);
                Assert.IsInstanceOf <IgnoreRule>(rules[0]);
                Assert.IsInstanceOf <MatchingNoneFilter>(rules[0].Filter);
                var filter   = rules[0].Filter as ParentFilter;
                var children = filter.Children.ToArray();
                Assert.AreEqual(3, children.Length);
                Assert.IsInstanceOf <OlderThanFilter>(children[0]);
                Assert.IsInstanceOf <RegexFilter>(children[1]);
                Assert.IsInstanceOf <WildcardsFilter>(children[2]);
            }
        }
Exemple #8
0
        public static string GetPlatformDBAdminUser()
        {
            ConfigFileReader confFileParser = new ConfigFileReader(Program.platformConfigurationFilepath, Program.osPlatformVersion);
            ConfigFileDBInfo platformDBInfo = confFileParser.DBPlatformInfo;

            return(platformDBInfo.GetProperty("AdminUser").Value);
        }
        protected async Task OutputFolderContentsMatchInputFolderContents()
        {
            Debug.WriteLine(Directory.GetCurrentDirectory());

            var configReader       = new ConfigFileReader();
            var inputConfiguration = await configReader.ReadConfiguration(InputFolder);

            var outputConfiguration = await configReader.ReadConfiguration(OutputFolder);

            inputConfiguration.GlobalConfig.Plugins.Should().NotBeEmpty();
            inputConfiguration.Services.Count.Should().Be(3);

            outputConfiguration.GlobalConfig.Plugins.Should().BeEquivalentTo(inputConfiguration.GlobalConfig.Plugins);
            outputConfiguration.Services.Should().BeEquivalentTo(inputConfiguration.Services);
            foreach (var outputService in outputConfiguration.Services)
            {
                var inputService = inputConfiguration.Services.Single(x => x.Name == outputService.Name);
                outputService.Plugins.Should().BeEquivalentTo(inputService.Plugins);
                outputService.Routes.Should().BeEquivalentTo(inputService.Routes);
                foreach (var outputServiceRoute in outputService.Routes)
                {
                    var inputServiceRoute = inputService.Routes.Single(x => x.Equals(outputServiceRoute));
                    outputServiceRoute.Plugins.Should().BeEquivalentTo(inputServiceRoute.Plugins);
                }
            }
        }
 public void EmptyFile()
 {
     using (var file = new TemporaryFile())
     {
         ConfigFileReader.Read(file.Path);
     }
 }
        // must still be added to the Tool code
        private static void HsconfReader(List <string> HsconfPropertiesList)
        {
            //IDictionary<string,string> HsConfPropertiesVal;
            ConfigFileReader confFileParser = new ConfigFileReader("<ServerHsConfLocation>", "test");
            ConfigFileDBInfo platformDBInfo = confFileParser.DBPlatformInfo;
            string           _propValue;

            IDictionary <string, string> HsConfPropertiesVal = new Dictionary <string, string>();

            foreach (string HsconfProperty in HsconfPropertiesList)
            {
                bool isEncrypted = platformDBInfo.GetProperty(HsconfProperty).IsEncrypted; // checking if prop is encrypted

                if (isEncrypted)
                {
                    _propValue = platformDBInfo.GetProperty(HsconfProperty).GetDecryptedValue(CryptoUtils.GetPrivateKeyFromFile("<ServerHsConfLocation>"));
                }
                else
                {
                    _propValue = platformDBInfo.GetProperty(HsconfProperty).Value;
                }

                HsConfPropertiesVal.Add(HsconfProperty, _propValue);
                Console.WriteLine(HsconfProperty + " " + _propValue);
            }
        }
Exemple #12
0
        public void ReadConfigFileNonexistingFile()
        {
            //Give
            var configFileReader = new ConfigFileReader();

            //Then
            Assert.Throws <FileNotFoundException>(() => configFileReader.ReadConfigFile(_nonexistingConfigFilePath));
        }
Exemple #13
0
        /// <summary>
        /// Gets this instance.
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage Get()
        {
            var serverConfigDetails = new ConfigFileReader().GetAllServerDetailsFromConfig();

            return(serverConfigDetails.Any()
                ? Request.CreateResponse(HttpStatusCode.OK, serverConfigDetails)
                : Request.CreateErrorResponse(HttpStatusCode.NotFound, "No results found"));
        }
Exemple #14
0
        public void ReadConfigFileInvalidConfigFile()
        {
            //Give
            var configFileReader = new ConfigFileReader();

            //Then
            Assert.Throws <InvalidDataException>(() => configFileReader.ReadConfigFile(_invalidConfigFilePath));
        }
Exemple #15
0
 public SimpleConfig(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     reader = new ConfigFileReader(path);
 }
Exemple #16
0
        public ItemsTests()
        {
            ConfigFileReader reader = ConfigFileReader.CreateFromFile(null, "config.ini");

            Assert.Equal(13, reader.Configurations.Count);

            Item.ConfigFileReader   = reader;
            Item.EnvVarEnvVarPrefix = "CONFIGLITE";
        }
Exemple #17
0
        public void Setup()
        {
            _logger = new LoggerConfiguration()
                      .WriteTo
                      .LiterateConsole()
                      .CreateLogger();

            _configFileReader = new ConfigFileReader(_logger);
        }
Exemple #18
0
        public MainForm()
        {
            InitializeComponent();

            this.ConfigFileReader = new ConfigFileReader(this.ConfigFilePath);
            LoadConfigs();

            this.FormNavigator = new FormNavigator(imgCurrentForm, btnPrevForm, btnNextForm, btnExpandForm, btnPrintForm, btnSaveForm, btnSaveAll, labCounter);
        }
 public void NoProfile()
 {
     Assert.Throws<Exception>(
         delegate
         {
             ConfigFile config = ConfigFileReader.Parse(ConfigPath, "USER_A");
         }
     );
 }
 public void NoLeadingFile()
 {
     Assert.Throws<FileNotFoundException>(
         delegate
         {
             ConfigFile config = ConfigFileReader.Parse("abc");
         }
     );
 }
        public void DestinationAttribute()
        {
            var xml = new XmlSample(@"<Move Destination='somewhere' />");

            using (var reader = xml.Read())
            {
                var rule = ConfigFileReader.ReadRule(reader, false) as MoveRule;
                Assert.AreEqual("somewhere", rule.Destination);
            }
        }
        public void IfExistsDelete()
        {
            var xml = new XmlSample(@"<Rename Name='newname' IfExists='delete' />");

            using (var reader = xml.Read())
            {
                var rule = ConfigFileReader.ReadRule(reader, false) as RenameRule;
                Assert.AreEqual(RenameRule.IfExistsMode.Delete, rule.IfExists);
            }
        }
Exemple #23
0
        public void ValidElement()
        {
            var xml = new XmlSample(@"<Empty />");

            using (var reader = xml.Read())
            {
                var filter = ConfigFileReader.ReadFilter(reader);
                Assert.IsInstanceOf <EmptyFilter>(filter);
            }
        }
        public void ProfiletestDEFAULT()
        {
            ConfigFile config = ConfigFileReader.Parse(ConfigPath, "DEFAULT");

            Assert.Equal("ocid1.tenancy.oc1..test", config.Get("tenancy"));
            Assert.Equal("ocid1.user.oc1..test", config.Get("user"));
            Assert.Equal("1a:2b:3c:4d:5e:6f", config.Get("fingerprint"));
            Assert.Equal("~/.oci/api_key.pem", config.Get("key_file"));
            Assert.Equal("ocid1.compartment.oc1..test", config.Get("custom_compartment_id"));
        }
        public void IfExistsDelete()
        {
            var xml = new XmlSample(@"<Move Destination='somewhere' IfExists='delete' />");

            using (var reader = xml.Read())
            {
                var rule = ConfigFileReader.ReadRule(reader, false) as MoveRule;
                Assert.AreEqual(MoveRule.IfExistsMode.Delete, rule.IfExists);
            }
        }
 public void LineWithNoValue()
 {
     Assert.Throws<KeyNotFoundException>(
         delegate
         {
             ConfigFile config = ConfigFileReader.Parse(ConfigPath);
             string tenancy = config.Get("unit_test_no_value_config");
         }
     );
 }
        public void ProfiletestMyProfile()
        {
            ConfigFile config = ConfigFileReader.Parse(ConfigPath, "myProfile");

            Assert.Equal("ocid1.tenancy.oc1..test", config.Get("tenancy"));
            Assert.Equal("ocid1.user.oc1..myProfile", config.Get("user"));
            Assert.Equal("7g:8h:9i:0j:1k:2l", config.Get("fingerprint"));
            Assert.Equal("~/.oci/my_key.pem", config.Get("key_file"));
            Assert.Equal("ocid1.compartment.oc1..Mytest", config.Get("custom_compartment_id"));
        }
 /// <summary>
 /// Gets the connection string.
 /// </summary>
 /// <param name="region">The region.</param>
 private void GetConnectionString(string region)
 {
     var fileReader = new ConfigFileReader();
     var serverDetails = fileReader.ReadConfigFile
         (new ServerDetailsModel
              {
                  Region = region
              });
     WebConfigPath = serverDetails.ServerList.FirstOrDefault().DeployDirectory + "\\Web.config";
 }
        public void DestinationAttribute()
        {
            var xml = new XmlSample(@"<Rename Name='newname' />");

            using (var reader = xml.Read())
            {
                var rule = ConfigFileReader.ReadRule(reader, false) as RenameRule;
                Assert.AreEqual("newname", rule.Name);
            }
        }
        /// <summary>
        /// Gets the connection string.
        /// </summary>
        /// <param name="region">The region.</param>
        private void GetConnectionString(string region)
        {
            var fileReader    = new ConfigFileReader();
            var serverDetails = fileReader.ReadConfigFile
                                    (new ServerDetailsModel
            {
                Region = region
            });

            WebConfigPath = serverDetails.ServerList.FirstOrDefault().DeployDirectory + "\\Web.config";
        }
        public void readConfigFile()
        {
            var configPath = @"C:\Users\frte\Documents\Projects\Config\MH2 layer plot teknisk.txt";

            var reader          = new ConfigFileReader();
            var LayerFilterList = reader.readConfigFile(configPath);

            var configWriter = new ConfigFileWriter();

            configWriter.writeConfig(configPath, LayerFilterList);
        }
        public void readWriteConfigFile()
        {
            var configPath = @"O:\A005000\A009727\BUSP 2\3.7 Tegninger\Kladd\FRTE\BUS2.txt";

            var reader          = new ConfigFileReader();
            var LayerFilterList = reader.readConfigFile(configPath);

            var configWriter = new ConfigFileWriter();

            configWriter.writeConfig(configPath, LayerFilterList);
        }
        /// <summary>
        /// Selects the source and destination.
        /// </summary>
        /// <param name="promoteCode">The promote code.</param>
        private static string SelectSourceAndDestination(PromoteCodeModel promoteCode)
        {
            var configFileReader = new ConfigFileReader();

            ServerDetailsModel serverDetails = configFileReader.ReadConfigFile(new ServerDetailsModel
                                                {
                                                    Region = promoteCode.Region
                                                });

            var sourceFileName = serverDetails.SourceFileLocation + "\\" + promoteCode.FileName;

            return sourceFileName;
        }
        /// <summary>
        /// Gets this instance.
        /// </summary>
        /// <returns></returns>
        public HttpResponseMessage Get([FromUri]string region)
        {
            var serverDetails = new ConfigFileReader().ReadConfigFile(new ServerDetailsModel
            {
                Region = region
            });

            var serverResponse = new HttpResponseMessage();

            foreach (var server in serverDetails.ServerList)
            {
                serverResponse = new CacheClearHandler().CacheClearCommand(server.ServerUrl);
            }
            return serverResponse.StatusCode == HttpStatusCode.OK
                       ? Request.CreateResponse(HttpStatusCode.OK, "resdis cache cleared")
                       : Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "cache clear task incomplete");
        }
        /// <summary>
        /// Excecutes the specified deploy entity.
        /// </summary>
        /// <param name="deployEntity">The deploy entity.</param>S
        public void Excecute(dynamic deployEntity)
        {
            var promoteCodeModel = (PromoteCodeModel) deployEntity;

            //initialize config file reader
            var configFileReader = new ConfigFileReader();

            //read config file based on region givenS
            ServerDetailsModel serverDetails = configFileReader.ReadConfigFile(new ServerDetailsModel
            {
                Region = promoteCodeModel.Region
            });

            //get the source file name by concatenating sourcelocation and filename
            serverDetails.SourceFileName = serverDetails.SourceFileLocation + "\\" + promoteCodeModel.FileName;

            //create the destination directory if uit does now exists
            if (!Directory.Exists(serverDetails.DestinationFileLocation))
                Directory.CreateDirectory(serverDetails.DestinationFileLocation);
        }
        /// <summary>
        /// Posts the specified promote code.
        /// </summary>
        /// <param name="promoteCode">The promote code.</param>
        /// <returns></returns>
        public async Task<HttpResponseMessage> Post(PromoteCodeModel promoteCode)
        {
            if (String.IsNullOrEmpty(promoteCode.Region))
            {
                return base.Request.CreateResponse(HttpStatusCode.BadRequest, "Please specify the region!");
            }

            string sourceFileName = SelectSourceAndDestination(promoteCode);

            var serverDetails = new ConfigFileReader().ReadConfigFile(new ServerDetailsModel
                                                {
                                                    Region = promoteCode.Region
                                                });

            serverDetails.SourceFileName = sourceFileName;

            //copy destination location to a private variable
            this.DestinationLocation = serverDetails.DestinationFileLocation;
            
            if (!Directory.Exists(serverDetails.DestinationFileLocation))
                Directory.CreateDirectory(serverDetails.DestinationFileLocation);

            var fileProcess = new FileProcessHandler();

            //Call a method to perform Xcopy
            fileProcess.ProcessXcopy(serverDetails);
            fileProcess.DeleteOldFile(serverDetails);
            fileProcess.ReplaceConfigFile(serverDetails);

            //perform the deployment to all servers deployment 
            foreach (var server in serverDetails.ServerList)
            {
                await MoveCodeToServer(server);
            }

            return Request.CreateResponse(HttpStatusCode.Created, "Deployment Completed");
        }