Search in sources :

Example 31 with ZapXmlConfiguration

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

the class ExtensionAuthenticationUnitTest method shouldImportContextWithNoAuthenticationMethod.

@Test
void shouldImportContextWithNoAuthenticationMethod() throws ConfigurationException {
    // Given
    Context context = mock(Context.class);
    Configuration config = new ZapXmlConfiguration();
    // When
    extensionAuthentication.importContextData(context, config);
    // Then
    verify(context, times(0)).setAuthenticationMethod(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 32 with ZapXmlConfiguration

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

the class ExtensionAuthorizationUnitTest method shouldImportContextWithUnknownAuthorizationDetectionMethod.

@Test
void shouldImportContextWithUnknownAuthorizationDetectionMethod() throws ConfigurationException {
    // Given
    Context context = mock(Context.class);
    Configuration config = new ZapXmlConfiguration();
    config.setProperty("context.authorization.type", Integer.MIN_VALUE);
    // 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 33 with ZapXmlConfiguration

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

the class VariantFactoryUnitTest method shouldReturnAllVariantsWhenSet.

@Test
void shouldReturnAllVariantsWhenSet() throws Exception {
    // Given
    ScannerParam scanOptions = Mockito.mock(ScannerParam.class, withSettings().lenient());
    Mockito.when(scanOptions.getConfig()).thenReturn(new ZapXmlConfiguration());
    Mockito.when(scanOptions.getTargetParamsInjectable()).thenReturn(-1);
    Mockito.when(scanOptions.getTargetParamsEnabledRPC()).thenReturn(-1);
    HttpMessage message = new HttpMessage(new URI("https://www.example.com/path?query", true));
    // When
    List<Variant> variants = factory.createVariants(scanOptions, message);
    // Then
    assertThat(variants.size(), is(equalTo(13)));
    assertThat(variants.get(0).getClass(), is(equalTo(VariantURLQuery.class)));
    assertThat(variants.get(1).getClass(), is(equalTo(VariantODataIdQuery.class)));
    assertThat(variants.get(2).getClass(), is(equalTo(VariantODataFilterQuery.class)));
    assertThat(variants.get(3).getClass(), is(equalTo(VariantFormQuery.class)));
    assertThat(variants.get(4).getClass(), is(equalTo(VariantMultipartFormParameters.class)));
    assertThat(variants.get(5).getClass(), is(equalTo(VariantXMLQuery.class)));
    assertThat(variants.get(6).getClass(), is(equalTo(VariantJSONQuery.class)));
    assertThat(variants.get(7).getClass(), is(equalTo(VariantGWTQuery.class)));
    assertThat(variants.get(8).getClass(), is(equalTo(VariantDirectWebRemotingQuery.class)));
    assertThat(variants.get(9).getClass(), is(equalTo(VariantHeader.class)));
    assertThat(variants.get(10).getClass(), is(equalTo(VariantURLPath.class)));
    assertThat(variants.get(11).getClass(), is(equalTo(VariantCookie.class)));
    assertThat(variants.get(12).getClass(), is(equalTo(VariantUserDefined.class)));
}
Also used : Variant(org.parosproxy.paros.core.scanner.Variant) ScannerParam(org.parosproxy.paros.core.scanner.ScannerParam) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) HttpMessage(org.parosproxy.paros.network.HttpMessage) URI(org.apache.commons.httpclient.URI) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with ZapXmlConfiguration

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

the class APIUnitTest method createOptionsParamApi.

private static OptionsParamApi createOptionsParamApi() {
    OptionsParamApi optionsParamApi = new OptionsParamApi();
    optionsParamApi.load(new ZapXmlConfiguration());
    return optionsParamApi;
}
Also used : ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration)

Example 35 with ZapXmlConfiguration

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

the class OptionsParamApiUnitTest method createTestConfig.

private static FileConfiguration createTestConfig() {
    ZapXmlConfiguration config = new ZapXmlConfiguration();
    config.setProperty(API_ENABLED_KEY, "false");
    config.setProperty(API_SECURE_KEY, "true");
    config.setProperty(API_KEY_KEY, "ApiKey");
    config.setProperty(API_DISABLEKEY_KEY, "true");
    config.setProperty(API_INCERRORDETAILS_KEY, "true");
    config.setProperty(API_AUTOFILLKEY_KEY, "true");
    config.setProperty(API_ENABLEJSONP_KEY, "true");
    config.setProperty(API_NO_KEY_FOR_SAFE_OPS, "true");
    config.setProperty(API_REPORT_PERM_ERRORS, "true");
    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