Search in sources :

Example 1 with InterfaceErrorMessageProvider

use of org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider in project zaproxy by zaproxy.

the class ScriptsPassiveScannerUnitTest method shouldCreateScriptsCacheWithExpectedConfiguration.

@Test
@SuppressWarnings("unchecked")
void shouldCreateScriptsCacheWithExpectedConfiguration() {
    // Given / When
    new ScriptsPassiveScanner();
    // Then
    ArgumentCaptor<Configuration<PassiveScript>> argumentCaptor = ArgumentCaptor.forClass(Configuration.class);
    verify(extensionScript).createScriptsCache(argumentCaptor.capture());
    Configuration<PassiveScript> configuration = argumentCaptor.getValue();
    assertThat(configuration.getScriptType(), is(equalTo(SCRIPT_TYPE)));
    assertThat(configuration.getTargetInterface(), is(equalTo(TARGET_INTERFACE)));
    InterfaceErrorMessageProvider errorMessageProvider = configuration.getInterfaceErrorMessageProvider();
    assertThat(errorMessageProvider, is(not(nullValue())));
    ScriptWrapper scriptWrapper = mock(ScriptWrapper.class);
    given(scriptWrapper.getName()).willReturn("Name");
    assertThat(errorMessageProvider.getErrorMessage(scriptWrapper), is(not(nullValue())));
}
Also used : InterfaceErrorMessageProvider(org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider) Configuration(org.zaproxy.zap.extension.script.ScriptsCache.Configuration) ScriptWrapper(org.zaproxy.zap.extension.script.ScriptWrapper) PassiveScript(org.zaproxy.zap.extension.pscan.PassiveScript) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 2 with InterfaceErrorMessageProvider

use of org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider in project zaproxy by zaproxy.

the class HttpSenderScriptListenerUnitTest method shouldCreateScriptsCacheWithExpectedConfiguration.

@Test
@SuppressWarnings("unchecked")
void shouldCreateScriptsCacheWithExpectedConfiguration() {
    // Given / When
    new HttpSenderScriptListener(extensionScript);
    // Then
    ArgumentCaptor<Configuration<HttpSenderScript>> argumentCaptor = ArgumentCaptor.forClass(Configuration.class);
    verify(extensionScript).createScriptsCache(argumentCaptor.capture());
    Configuration<HttpSenderScript> configuration = argumentCaptor.getValue();
    assertThat(configuration.getScriptType(), is(equalTo(SCRIPT_TYPE)));
    assertThat(configuration.getTargetInterface(), is(equalTo(TARGET_INTERFACE)));
    InterfaceErrorMessageProvider errorMessageProvider = configuration.getInterfaceErrorMessageProvider();
    assertThat(errorMessageProvider, is(not(nullValue())));
    assertThat(errorMessageProvider.getErrorMessage(null), is(not(nullValue())));
}
Also used : InterfaceErrorMessageProvider(org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider) Configuration(org.zaproxy.zap.extension.script.ScriptsCache.Configuration) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 3 with InterfaceErrorMessageProvider

use of org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider in project zaproxy by zaproxy.

the class VariantFactoryUnitTest method shouldCreateScriptsCacheWithExpectedConfiguration.

@Test
@SuppressWarnings("unchecked")
void shouldCreateScriptsCacheWithExpectedConfiguration() {
    // Given / When
    factory.createSiteModifyingVariants();
    // Then
    ArgumentCaptor<Configuration<VariantScript>> argumentCaptor = ArgumentCaptor.forClass(Configuration.class);
    verify(extensionScript).createScriptsCache(argumentCaptor.capture());
    Configuration<VariantScript> configuration = argumentCaptor.getValue();
    assertThat(configuration.getScriptType(), is(equalTo(SCRIPT_TYPE)));
    assertThat(configuration.getTargetInterface(), is(equalTo(TARGET_INTERFACE)));
    InterfaceErrorMessageProvider errorMessageProvider = configuration.getInterfaceErrorMessageProvider();
    assertThat(errorMessageProvider, is(not(nullValue())));
    assertThat(errorMessageProvider.getErrorMessage(mock(ScriptWrapper.class)), is(not(nullValue())));
}
Also used : InterfaceErrorMessageProvider(org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider) Configuration(org.zaproxy.zap.extension.script.ScriptsCache.Configuration) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) VariantScript(org.parosproxy.paros.core.scanner.VariantScript) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with InterfaceErrorMessageProvider

use of org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider in project zaproxy by zaproxy.

the class ProxyListenerScriptUnitTest method shouldCreateScriptsCacheWithExpectedConfiguration.

@Test
@SuppressWarnings("unchecked")
void shouldCreateScriptsCacheWithExpectedConfiguration() {
    // Given / When
    new ProxyListenerScript(extensionScript);
    // Then
    ArgumentCaptor<Configuration<ProxyScript>> argumentCaptor = ArgumentCaptor.forClass(Configuration.class);
    verify(extensionScript).createScriptsCache(argumentCaptor.capture());
    Configuration<ProxyScript> configuration = argumentCaptor.getValue();
    assertThat(configuration.getScriptType(), is(equalTo(SCRIPT_TYPE)));
    assertThat(configuration.getTargetInterface(), is(equalTo(TARGET_INTERFACE)));
    InterfaceErrorMessageProvider errorMessageProvider = configuration.getInterfaceErrorMessageProvider();
    assertThat(errorMessageProvider, is(not(nullValue())));
    assertThat(errorMessageProvider.getErrorMessage(null), is(not(nullValue())));
}
Also used : InterfaceErrorMessageProvider(org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider) Configuration(org.zaproxy.zap.extension.script.ScriptsCache.Configuration) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Aggregations

Test (org.junit.jupiter.api.Test)4 WithConfigsTest (org.zaproxy.zap.WithConfigsTest)4 Configuration (org.zaproxy.zap.extension.script.ScriptsCache.Configuration)4 InterfaceErrorMessageProvider (org.zaproxy.zap.extension.script.ScriptsCache.InterfaceErrorMessageProvider)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 VariantScript (org.parosproxy.paros.core.scanner.VariantScript)1 PassiveScript (org.zaproxy.zap.extension.pscan.PassiveScript)1 ScriptWrapper (org.zaproxy.zap.extension.script.ScriptWrapper)1 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)1