use of org.zaproxy.zap.extension.script.ExtensionScript in project zaproxy by zaproxy.
the class VariantCustomUnitTest method shouldReturnNullTreePathWithScriptException.
@Test
void shouldReturnNullTreePathWithScriptException() throws Exception {
// Given
ScriptWrapper scriptWrapper = mock(ScriptWrapper.class);
String expectedPath = "newpath";
List<String> list = new ArrayList<>();
list.add(expectedPath);
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.getTreePath(variantCustom, msg)).willThrow(RuntimeException.class);
// When
List<String> path = variantCustom.getTreePath(msg);
// Then
assertThat(path, is(equalTo(null)));
}
use of org.zaproxy.zap.extension.script.ExtensionScript in project zaproxy by zaproxy.
the class VariantCustomUnitTest method shouldCallScriptForGetLeafName.
@Test
void shouldCallScriptForGetLeafName() throws Exception {
// Given
ScriptWrapper scriptWrapper = mock(ScriptWrapper.class);
given(scriptWrapper.isEnabled()).willReturn(true);
String nodeName = "name";
String expectedName = "newname";
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)).willReturn(expectedName);
// When
String name = variantCustom.getLeafName(nodeName, msg);
// Then
assertThat(name, is(equalTo(expectedName)));
}
use of org.zaproxy.zap.extension.script.ExtensionScript in project zaproxy by zaproxy.
the class ScriptsActiveScannerUnitTest method setUp.
@BeforeEach
void setUp() throws Exception {
extensionScript = mock(ExtensionScript.class);
parent = mock(HostProcess.class);
message = new HttpMessage(new HttpRequestHeader("GET / HTTP/1.1"));
given(extensionLoader.getExtension(ExtensionScript.class)).willReturn(extensionScript);
}
use of org.zaproxy.zap.extension.script.ExtensionScript in project zaproxy by zaproxy.
the class VariantCustomUnitTest method shouldCallScriptForGetTreePath.
@Test
void shouldCallScriptForGetTreePath() throws Exception {
// Given
ScriptWrapper scriptWrapper = mock(ScriptWrapper.class);
given(scriptWrapper.isEnabled()).willReturn(true);
String expectedPath = "newpath";
List<String> list = new ArrayList<>();
list.add(expectedPath);
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.getTreePath(variantCustom, msg)).willReturn(list);
// When
List<String> path = variantCustom.getTreePath(msg);
// Then
assertThat(path.size(), is(equalTo(1)));
assertThat(path.get(0), is(equalTo(expectedPath)));
}
use of org.zaproxy.zap.extension.script.ExtensionScript in project zaproxy by zaproxy.
the class VariantCustomUnitTest method shouldReturnNullTreePathWithDisabledScript.
@Test
void shouldReturnNullTreePathWithDisabledScript() throws Exception {
// Given
ScriptWrapper scriptWrapper = mock(ScriptWrapper.class);
given(scriptWrapper.isEnabled()).willReturn(false);
List<String> list = new ArrayList<>();
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.getTreePath(variantCustom, msg)).willReturn(list);
// When
List<String> path = variantCustom.getTreePath(msg);
// Then
assertThat(path, is(equalTo(null)));
}
Aggregations