Search in sources :

Example 11 with ExtensionScript

use of org.zaproxy.zap.extension.script.ExtensionScript in project zaproxy by zaproxy.

the class VariantCustomUnitTest method shouldReturnNullLeafNameWithScriptException.

@Test
void shouldReturnNullLeafNameWithScriptException() throws Exception {
    // Given
    ScriptWrapper scriptWrapper = mock(ScriptWrapper.class);
    String nodeName = "name";
    ExtensionScript extScript = mock(ExtensionScript.class);
    VariantScript variantScript = mock(VariantScript.class);
    given(extScript.getInterface(scriptWrapper, VariantScript.class)).willReturn(variantScript);
    VariantCustom variantCustom = new VariantCustom(scriptWrapper, extScript);
    HttpMessage msg = mock(HttpMessage.class);
    given(variantScript.getLeafName(variantCustom, nodeName, msg)).willThrow(RuntimeException.class);
    // When
    String name = variantCustom.getLeafName(nodeName, msg);
    // Then
    assertThat(name, is(equalTo(null)));
}
Also used : ExtensionScript(org.zaproxy.zap.extension.script.ExtensionScript) ScriptWrapper(org.zaproxy.zap.extension.script.ScriptWrapper) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Aggregations

ExtensionScript (org.zaproxy.zap.extension.script.ExtensionScript)11 HttpMessage (org.parosproxy.paros.network.HttpMessage)8 Test (org.junit.jupiter.api.Test)6 ScriptWrapper (org.zaproxy.zap.extension.script.ScriptWrapper)6 ArrayList (java.util.ArrayList)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ScriptType (org.zaproxy.zap.extension.script.ScriptType)2 Source (net.htmlparser.jericho.Source)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 HostProcess (org.parosproxy.paros.core.scanner.HostProcess)1 HttpRequestHeader (org.parosproxy.paros.network.HttpRequestHeader)1 ExtensionAlert (org.zaproxy.zap.extension.alert.ExtensionAlert)1