use of org.zaproxy.zap.extension.script.ScriptsCache.CachedScript in project zaproxy by zaproxy.
the class ScriptsCacheUnitTest method shouldNotCacheScriptsThatHaveErrors.
@Test
void shouldNotCacheScriptsThatHaveErrors() throws Exception {
// Given
Script script1 = mock(Script.class);
ScriptWrapper scriptWrapper1 = mockScriptWrapper(script1);
Script script2 = mock(Script.class);
ScriptWrapper scriptWrapper2 = mockScriptWrapper(script2);
ScriptException scriptException = mock(ScriptException.class);
given(extensionScript.getInterface(scriptWrapper2, targetInterface)).willThrow(scriptException);
given(extensionScript.getScripts(scriptType)).willReturn(asList(scriptWrapper1, scriptWrapper2));
// When
scriptsCache.refresh();
// Then
List<CachedScript<Script>> cachedScripts = scriptsCache.getCachedScripts();
assertThat(cachedScripts, hasSize(1));
assertCachedScript(cachedScripts.get(0), scriptWrapper1, script1);
verify(extensionScript, times(1)).getScripts(scriptType);
verify(extensionScript, times(1)).getInterface(scriptWrapper1, targetInterface);
verify(extensionScript, times(1)).getInterface(scriptWrapper2, targetInterface);
verify(extensionScript, times(1)).handleScriptException(scriptWrapper2, scriptException);
verifyNoMoreInteractions(extensionScript);
}
Aggregations