Search in sources :

Example 66 with ZapXmlConfiguration

use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.

the class AbstractPluginUnitTest method shouldRetrieveConfigSet.

@Test
void shouldRetrieveConfigSet() {
    // Given
    AbstractPlugin plugin = createAbstractPlugin();
    Configuration config = new ZapXmlConfiguration();
    // WHen
    plugin.setConfig(config);
    // Then
    assertThat(plugin.getConfig(), is(equalTo(config)));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 67 with ZapXmlConfiguration

use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.

the class AbstractPluginUnitTest method shouldFailToSaveToConfigIfConfigNotSet.

@Test
void shouldFailToSaveToConfigIfConfigNotSet() {
    // Given
    AbstractPlugin plugin = createAbstractPlugin();
    Configuration config = new ZapXmlConfiguration();
    // When / Then
    assertThrows(NullPointerException.class, () -> plugin.saveTo(config));
}
Also used : Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 68 with ZapXmlConfiguration

use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.

the class PluginPassiveScannerUnitTest method createConfiguration.

private static Configuration createConfiguration(String classname, Boolean enabled, AlertThreshold alertThreshold) {
    ZapXmlConfiguration configuration = new ZapXmlConfiguration();
    setClassname(configuration, 0, classname);
    setProperties(configuration, 0, enabled, alertThreshold);
    return configuration;
}
Also used : ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration)

Example 69 with ZapXmlConfiguration

use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.

the class RuleConfigParamUnitTest method setUp.

@BeforeEach
void setUp() throws Exception {
    rcp = new RuleConfigParam();
    configuration = new ZapXmlConfiguration();
    rcp.load(configuration);
}
Also used : ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 70 with ZapXmlConfiguration

use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.

the class ExtensionSessionManagementUnitTest method shouldImportContextWithScriptSessionMgmtType.

@Test
void shouldImportContextWithScriptSessionMgmtType() throws ConfigurationException {
    // Given
    Context context = mock(Context.class);
    Configuration config = new ZapXmlConfiguration();
    int sessMgmtTypeId = 2;
    config.addProperty(ExtensionSessionManagement.CONTEXT_CONFIG_SESSION_TYPE, sessMgmtTypeId);
    // When
    extSessMgmt.importContextData(context, config);
    // Then
    verify(context).setSessionManagementMethod(any(ScriptBasedSessionManagementMethod.class));
}
Also used : Context(org.zaproxy.zap.model.Context) ScriptBasedSessionManagementMethod(org.zaproxy.zap.session.ScriptBasedSessionManagementMethodType.ScriptBasedSessionManagementMethod) Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Aggregations

ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)82 Test (org.junit.jupiter.api.Test)37 Configuration (org.apache.commons.configuration.Configuration)19 WithConfigsTest (org.zaproxy.zap.WithConfigsTest)18 Context (org.zaproxy.zap.model.Context)17 ConfigurationException (org.apache.commons.configuration.ConfigurationException)15 File (java.io.File)11 IOException (java.io.IOException)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 ConversionException (org.apache.commons.configuration.ConversionException)6 XMLConfiguration (org.apache.commons.configuration.XMLConfiguration)5 InvalidParameterException (java.security.InvalidParameterException)4 HttpMessage (org.parosproxy.paros.network.HttpMessage)4 MalformedURLException (java.net.MalformedURLException)3 Path (java.nio.file.Path)3 ParseException (java.text.ParseException)3 ArrayList (java.util.ArrayList)3 Locale (java.util.Locale)3 NoSuchElementException (java.util.NoSuchElementException)3 URI (org.apache.commons.httpclient.URI)3