Search in sources :

Example 71 with ZapXmlConfiguration

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

the class ExtensionSessionManagementUnitTest method shouldImportContextWithUnknownSessionMgmtType.

@Test
void shouldImportContextWithUnknownSessionMgmtType() throws ConfigurationException {
    // Given
    Context context = mock(Context.class);
    Configuration config = new ZapXmlConfiguration();
    int sessMgmtTypeId = 100;
    config.addProperty(ExtensionSessionManagement.CONTEXT_CONFIG_SESSION_TYPE, sessMgmtTypeId);
    // When
    extSessMgmt.importContextData(context, config);
    // Then
    verify(context, times(0)).setSessionManagementMethod(any());
}
Also used : Context(org.zaproxy.zap.model.Context) 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)

Example 72 with ZapXmlConfiguration

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

the class ExtensionSessionManagementUnitTest method shouldImportContextWithHttpSessionMgmtType.

@Test
void shouldImportContextWithHttpSessionMgmtType() throws ConfigurationException {
    // Given
    Context context = mock(Context.class);
    Configuration config = new ZapXmlConfiguration();
    int sessMgmtTypeId = 1;
    config.addProperty(ExtensionSessionManagement.CONTEXT_CONFIG_SESSION_TYPE, sessMgmtTypeId);
    // When
    extSessMgmt.importContextData(context, config);
    // Then
    verify(context).setSessionManagementMethod(any(HttpAuthSessionManagementMethod.class));
}
Also used : Context(org.zaproxy.zap.model.Context) HttpAuthSessionManagementMethod(org.zaproxy.zap.session.HttpAuthSessionManagementMethodType.HttpAuthSessionManagementMethod) 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)

Example 73 with ZapXmlConfiguration

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

the class PluginPassiveScannerUnitTest method createConfiguration.

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

Example 74 with ZapXmlConfiguration

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

the class ExtensionAuthorizationUnitTest method shouldImportContextWithNoAuthorizationDetectionMethod.

@Test
void shouldImportContextWithNoAuthorizationDetectionMethod() throws ConfigurationException {
    // Given
    Context context = mock(Context.class);
    Configuration config = new ZapXmlConfiguration();
    // When
    extensionAuthorization.importContextData(context, config);
    // Then
    verify(context, times(0)).setAuthorizationDetectionMethod(any());
}
Also used : Context(org.zaproxy.zap.model.Context) Configuration(org.apache.commons.configuration.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) Test(org.junit.jupiter.api.Test)

Example 75 with ZapXmlConfiguration

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

the class ExtensionParamUnitTest method createTestConfig.

private static FileConfiguration createTestConfig(boolean... states) {
    ZapXmlConfiguration config = new ZapXmlConfiguration();
    if (states == null || states.length == 0) {
        return config;
    }
    for (int i = 0; i < states.length; ++i) {
        String elementBaseKey = "extensions.extension(" + i + ").";
        config.setProperty(elementBaseKey + "name", "Extension " + (i + 1));
        config.setProperty(elementBaseKey + "enabled", states[i]);
    }
    return config;
}
Also used : ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration)

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