Search in sources :

Example 1 with VariantScript

use of org.parosproxy.paros.core.scanner.VariantScript 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 2 with VariantScript

use of org.parosproxy.paros.core.scanner.VariantScript in project zaproxy by zaproxy.

the class VariantFactoryUnitTest method shouldUseVariantScripts.

@Test
@SuppressWarnings("unchecked")
void shouldUseVariantScripts() {
    // Given
    VariantScript script = mock(TARGET_INTERFACE);
    CachedScript<VariantScript> cachedScript = createCachedScript(script);
    ScriptsCache<VariantScript> scriptsCache = createScriptsCache(cachedScript);
    given(extensionScript.<VariantScript>createScriptsCache(any())).willReturn(scriptsCache);
    // When
    List<Variant> variants = factory.createSiteModifyingVariants();
    // Then
    verify(scriptsCache, times(1)).refreshAndExecute(any(ScriptWrapperAction.class));
    assertThat(variants, hasSize(1));
    assertThat(variants.get(0), is(instanceOf(VariantCustom.class)));
}
Also used : Variant(org.parosproxy.paros.core.scanner.Variant) ScriptWrapperAction(org.zaproxy.zap.extension.script.ScriptsCache.ScriptWrapperAction) VariantScript(org.parosproxy.paros.core.scanner.VariantScript) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

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