Search in sources :

Example 16 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project zaproxy by zaproxy.

the class ExtensionParamUnitTest method shouldHaveLoadedConfigsAfterCloning.

@Test
void shouldHaveLoadedConfigsAfterCloning() {
    // Given
    ExtensionParam param = new ExtensionParam();
    FileConfiguration config = createTestConfig(false, true, false);
    param.load(config);
    // When
    ExtensionParam clone = param.clone();
    // Then
    assertThat(clone.isExtensionEnabled("Extension 1"), is(equalTo(false)));
    assertThat(clone.isExtensionEnabled("Extension 2"), is(equalTo(true)));
    assertThat(clone.isExtensionEnabled("Extension 3"), is(equalTo(false)));
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) Test(org.junit.jupiter.api.Test)

Example 17 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project zaproxy by zaproxy.

the class ExtensionParamUnitTest method shouldParseLoadedFileConfiguration.

@Test
void shouldParseLoadedFileConfiguration() {
    // Given
    ExtensionParam param = new ExtensionParam();
    FileConfiguration config = createTestConfig(false, true, false, true, true);
    // When
    param.load(config);
    // Then
    assertThat(param.isExtensionEnabled("Extension 1"), is(equalTo(false)));
    assertThat(param.isExtensionEnabled("Extension 2"), is(equalTo(true)));
    assertThat(param.isExtensionEnabled("Extension 3"), is(equalTo(false)));
    assertThat(param.isExtensionEnabled("Extension 4"), is(equalTo(true)));
    assertThat(param.isExtensionEnabled("Extension 5"), is(equalTo(true)));
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) Test(org.junit.jupiter.api.Test)

Example 18 with FileConfiguration

use of org.apache.commons.configuration.FileConfiguration in project zaproxy by zaproxy.

the class ExtensionParamUnitTest method shouldNotPersistNullExtensionNamesOrNullEnabledState.

@Test
void shouldNotPersistNullExtensionNamesOrNullEnabledState() {
    // Given
    ExtensionParam param = new ExtensionParam();
    FileConfiguration config = createTestConfig();
    param.load(config);
    Map<String, Boolean> states = new HashMap<>();
    states.put(null, Boolean.FALSE);
    states.put("Extension 2", null);
    // When
    param.setExtensionsState(states);
    // Then
    assertThat(param.getConfig().getKeys().hasNext(), is(equalTo(false)));
}
Also used : FileConfiguration(org.apache.commons.configuration.FileConfiguration) HashMap(java.util.HashMap) Test(org.junit.jupiter.api.Test)

Aggregations

FileConfiguration (org.apache.commons.configuration.FileConfiguration)18 Test (org.junit.jupiter.api.Test)11 ConfigurationException (org.apache.commons.configuration.ConfigurationException)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 FileNotFoundException (java.io.FileNotFoundException)2 Iterator (java.util.Iterator)2 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)2 FileChangedReloadingStrategy (org.apache.commons.configuration.reloading.FileChangedReloadingStrategy)2 File (java.io.File)1 HashMap (java.util.HashMap)1 ReloadingStrategy (org.apache.commons.configuration.reloading.ReloadingStrategy)1 RegexAutoTagScanner (org.zaproxy.zap.extension.pscan.scanner.RegexAutoTagScanner)1 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)1