예제 #1
0
        public async Task ChangeConfigLogicConfigSetUnauthorized()
        {
            var data   = new UserApiDataHandler();
            var model  = UserData.GetFirst();
            var config = UserConfigData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <UserById>())).Returns(model);
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <User> >())).Returns(model);

            var command = new ChangeConfig
            {
                DataHandler  = data,
                CurrentUser  = NonTenantUser,
                Key          = "CANAUTH",
                Value        = "true",
                ResultConfig = config,
                UserId       = StandardUser.Id
            };

            await command.Execute();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <User> >()), Times.Never());
        }
예제 #2
0
        public void RootSettingsShouldOverrideImportedWhenImportedIsFirst()
        {
            var lvlTwo = this.CreateSettings(@"
  <var name='ORIGIN' value='lvlTwo' />
  <var name='IMPORTED' value='lvlTwo' />
  <var name='IMPORTED_LVL2' value='lvlTwo' />");

            var lvlOne = this.CreateSettings($@"
  <import from='{lvlTwo}' />
  <var name='ORIGIN' value='lvlOne' />
  <var name='IMPORTED' value='lvlOne' />");

            var root = this.CreateSettings($@"
  <import from='{lvlOne}' />
  <var name='ORIGIN' value='root' />");

            var configWithImportSection = this.CreateConfig(@"
  <!--{@origin=ORIGIN @imported=IMPORTED @imported_v2=IMPORTED_LVL2}-->
  <setting />
");

            this.liveConfigPath = ChangeConfig.Execute(configWithImportSection, root);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{@origin=ORIGIN @imported=IMPORTED @imported_v2=IMPORTED_LVL2}-->
  <setting origin=""root"" imported=""lvlOne"" imported_v2=""lvlTwo"" />
");
        }
예제 #3
0
        public void NewLinesInAttributes()
        {
            var settingsPath = this.CreateSettings(@"
  <var name='STORAGE_SERVICE_ZIP_PATH' value='D:\Temp\StorageService.zip' />
  <var name='STORAGE_SERVICE_BIN_PATH' value='D:\Temp\StorageService\bin\Storage' />");

            var attributesWithoutNewlines = this.CreateConfig(@"
  <!--{@storageServicePort=STORAGE_SERVICE_PORT @storageServiceZipPath=STORAGE_SERVICE_ZIP_PATH @storageServiceBinPath=STORAGE_SERVICE_BIN_PATH}-->
  <storageServiceSetting />
");

            this.liveConfigPath = ChangeConfig.Execute(attributesWithoutNewlines, settingsPath);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{@storageServicePort=STORAGE_SERVICE_PORT @storageServiceZipPath=STORAGE_SERVICE_ZIP_PATH @storageServiceBinPath=STORAGE_SERVICE_BIN_PATH}-->
  <storageServiceSetting storageServiceZipPath=""D:\Temp\StorageService.zip"" storageServiceBinPath=""D:\Temp\StorageService\bin\Storage"" />
");

            var attributesWithNewlines = this.CreateConfig(@"
  <!--{@storageServicePort=STORAGE_SERVICE_PORT 
       @storageServiceZipPath=STORAGE_SERVICE_ZIP_PATH 
       @storageServiceBinPath=STORAGE_SERVICE_BIN_PATH}-->
  <storageServiceSetting />
");

            this.liveConfigPath = ChangeConfig.Execute(attributesWithNewlines, settingsPath);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{@storageServicePort=STORAGE_SERVICE_PORT 
       @storageServiceZipPath=STORAGE_SERVICE_ZIP_PATH 
       @storageServiceBinPath=STORAGE_SERVICE_BIN_PATH}-->
  <storageServiceSetting storageServiceZipPath=""D:\Temp\StorageService.zip"" storageServiceBinPath=""D:\Temp\StorageService\bin\Storage"" />
");
        }
예제 #4
0
        public void UncommentBlock()
        {
            var settingsPath = this.CreateSettings(@"
  <block name='IS_TEST_ENABLED_BLOCK' enabled='true' />");

            var enabledBlockConfigPath = this.CreateConfig(@"
  <!--{~IS_TEST_ENABLED_BLOCK}-->
  <!--<SomeBlock/>-->");

            this.liveConfigPath = ChangeConfig.Execute(enabledBlockConfigPath, settingsPath);

            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{~IS_TEST_ENABLED_BLOCK}-->
  <SomeBlock />
");
        }
예제 #5
0
        public void UncommentBlockAndChangeAttributeValue()
        {
            var settingsPath = this.CreateSettings(@"
  <var name='DATABASE_ENGINE' value='postgres' />");

            var enabledBlockConfigPath = this.CreateConfig(@"
  <!--{@attrName=""ChangedValue""}-->
  <!--{~$equals(DATABASE_ENGINE, ""postgres"")}-->
  <!--<PostgresBlock attrName='AttrValue'/>-->
");

            this.liveConfigPath = ChangeConfig.Execute(enabledBlockConfigPath, settingsPath);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{@attrName=""ChangedValue""}-->
  <!--{~$equals(DATABASE_ENGINE, ""postgres"")}-->
  <PostgresBlock attrName=""ChangedValue"" />
");
        }
예제 #6
0
        public void ImportFromAbsolutePath()
        {
            var subSettingsPath = this.CreateSettings(@"
  <var name='IMPORTED' value='From subSettingsPath' />");
            var settingsPath    = this.CreateSettings($@"
  <var name='ORIGIN' value='From Origin' />
  <import from='{subSettingsPath}'/>");

            var configWithImportSection = this.CreateConfig(@"
  <!--{@origin=ORIGIN @imported=IMPORTED}-->
  <setting />
");

            this.liveConfigPath = ChangeConfig.Execute(configWithImportSection, settingsPath);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{@origin=ORIGIN @imported=IMPORTED}-->
  <setting origin=""From Origin"" imported=""From subSettingsPath"" />
");
        }
예제 #7
0
        public void TryUncommentBlockWhenVarIsEquals()
        {
            var settingsPath = this.CreateSettings(@"
  <var name='DATABASE_ENGINE' value='postgres' />");

            var enabledBlockConfigPath = this.CreateConfig(@"
  <!--{~$equals(DATABASE_ENGINE, ""mssql"")}-->
  <!--<MssqlBlock />-->
  <!--{~$equals(DATABASE_ENGINE, ""postgres"")}-->
  <!--<PostgresBlock />-->
");

            this.liveConfigPath = ChangeConfig.Execute(enabledBlockConfigPath, settingsPath);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{~$equals(DATABASE_ENGINE, ""mssql"")}-->
  <!--<MssqlBlock />-->
  <!--{~$equals(DATABASE_ENGINE, ""postgres"")}-->
  <PostgresBlock />
");
        }
예제 #8
0
        public void TryUncommentBlockWhenBlockIsNotEquals()
        {
            var settingsPath = this.CreateSettings(@"
  <block name='IS_TEST_ENABLED_BLOCK' enabled='true' />
  <block name='IS_TEST_DISABLED_BLOCK' enabled='false' />");

            var enabledBlockConfigPath = this.CreateConfig(@"
  <!--{~$not(IS_TEST_ENABLED_BLOCK)}-->
  <!--<TestEnabledBlock />--> 
  <!--{~$not(IS_TEST_DISABLED_BLOCK)}-->
  <!--<TestDisabledBlock />--> 
");

            this.liveConfigPath = ChangeConfig.Execute(enabledBlockConfigPath, settingsPath);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{~$not(IS_TEST_ENABLED_BLOCK)}-->
  <!--<TestEnabledBlock />-->
  <!--{~$not(IS_TEST_DISABLED_BLOCK)}-->
  <TestDisabledBlock />
");
        }
예제 #9
0
        public void CommentBlockNegative()
        {
            var settingsPath = this.CreateSettings(@"
  <block name='IS_TEST_ENABLED_BLOCK' enabled='true' />
  <block name='IS_TEST_DISABLED_BLOCK' enabled='false' />");

            var enabledBlockConfigPath = this.CreateConfig(@"
  <!--{~!IS_TEST_ENABLED_BLOCK}-->
  <EnabledBlock />  
  <!--{~!IS_TEST_DISABLED_BLOCK}-->
  <DisabledBlock />");

            this.liveConfigPath = ChangeConfig.Execute(enabledBlockConfigPath, settingsPath);

            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{~!IS_TEST_ENABLED_BLOCK}-->
  <!--<EnabledBlock />-->
  <!--{~!IS_TEST_DISABLED_BLOCK}-->
  <DisabledBlock />
");
        }
예제 #10
0
        public async Task ChangeConfigLogicConfigSetDefault(string key, string value)
        {
            var data   = new UserConfigApiDataHandler();
            var config = UserConfigData.GetFirst();

            var command = new ChangeConfig
            {
                DataHandler  = data,
                CurrentUser  = StandardUser,
                Key          = key,
                Value        = value,
                ResultConfig = config,
                UserId       = StandardUser.Id
            };

            await command.Execute();

            data.HasExecuted.Should().BeFalse();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <UserConfig> >()), Times.Never());
        }
예제 #11
0
        public void ImportFromRelativePath()
        {
            var subSettingsPath     = this.CreateSettings(@"
  <var name='IMPORTED' value='From subSettingsPath' />");
            var subSettingsFileName = Path.GetFileName(subSettingsPath);

            File.Move(subSettingsPath, Path.Combine(this.tempImportedPath, subSettingsFileName));
            var lastDirName  = Path.GetFileName(this.tempImportedPath);
            var relativePath = $@"..\{Path.Combine(lastDirName, subSettingsFileName)}";
            var settingsPath = this.CreateSettings($@"
  <var name='ORIGIN' value='From Origin' />
  <import from='{relativePath}'/>");

            var configWithImportSection = this.CreateConfig(@"
  <!--{@origin=ORIGIN @imported=IMPORTED}-->
  <setting />
");

            this.liveConfigPath = ChangeConfig.Execute(configWithImportSection, settingsPath);
            this.GetLiveConfig(this.liveConfigPath).Should().Be(@"
  <!--{@origin=ORIGIN @imported=IMPORTED}-->
  <setting origin=""From Origin"" imported=""From subSettingsPath"" />
");
        }
예제 #12
0
        public async Task ChangeConfigLogicRightSet(string key, string value)
        {
            var data   = new UserApiDataHandler();
            var config = UserConfigData.GetFourth();

            data.Result.Setup(m => m.Execute(It.IsAny <Persist <User> >())).Returns(SuperUser);

            var command = new ChangeConfig
            {
                DataHandler  = data,
                CurrentUser  = SuperUser,
                Key          = key,
                Value        = value,
                ResultConfig = config,
                UserId       = SuperUser.Id,
                ResultUser   = SuperUser
            };

            await command.Execute();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeFalse();
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <User> >()), Times.Once());
        }
 private void ApplySettingsToСonfig()
 {
     this.liveConfigPath = ChangeConfig.Execute(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "source.config"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "settings.xml"));
 }
예제 #14
0
 private void ApplySettingsToLogСonfigWithAppDataPathWithoutResolvePathFunc(string currentConfigPath)
 {
     this.liveConfigPath = ChangeConfig.Execute(currentConfigPath, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "settings_with_appdata_path.xml"));
 }
 private void ApplySettingsToWithGeneratedBlock()
 {
     this.liveConfigDateTime = File.GetLastWriteTime(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "with_generated_section.live.config"));
     this.liveConfigPath     = ChangeConfig.Execute(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "with_generated_section.config"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "settings.xml"));
 }
 private void ApplySettingsToLogСonfigWithAppDataPath()
 {
     this.liveConfigPath = ChangeConfig.Execute(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "source_log.config"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "settings_with_appdata_path.xml"));
 }
예제 #17
0
 private void ApplySettingsToLogСonfig(string currentConfigPath)
 {
     this.liveConfigPath = ChangeConfig.Execute(currentConfigPath, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ChangeConfig", "Etalon", "settings.xml"), ResolveForcedAppDataPath);
 }