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())));
}
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)));
}
Aggregations