use of org.zaproxy.zap.spider.parser.SpiderResourceFound in project zaproxy by zaproxy.
the class SpiderControllerUnitTest method shouldNotSubmitSameGetTaskWithDifferentHeaderOrder.
@Test
void shouldNotSubmitSameGetTaskWithDifferentHeaderOrder() {
// Given
List<HttpHeaderField> requestHeadersOrder1 = new ArrayList<>();
requestHeadersOrder1.add(new HttpHeaderField("X-Custom-Header-1", "xyz"));
requestHeadersOrder1.add(new HttpHeaderField("X-Custom-Header-2", "123"));
List<HttpHeaderField> requestHeadersOrder2 = new ArrayList<>();
requestHeadersOrder2.add(new HttpHeaderField("X-Custom-Header-2", "123"));
requestHeadersOrder2.add(new HttpHeaderField("X-Custom-Header-1", "xyz"));
SpiderResourceFound spiderResourceFound1 = createGetSpiderResourceFoundWithHeaders("https://example.com/test.html", 2, false, requestHeadersOrder1);
SpiderResourceFound spiderResourceFound2 = createGetSpiderResourceFoundWithHeaders("https://example.com/test.html", 2, false, requestHeadersOrder2);
// When
spiderController.resourceFound(spiderResourceFound1);
spiderController.resourceFound(spiderResourceFound2);
// Then
verify(spider).submitTask(any());
}
use of org.zaproxy.zap.spider.parser.SpiderResourceFound in project zaproxy by zaproxy.
the class SpiderControllerUnitTest method shouldSubmitTasksForDifferentMethods.
@Test
void shouldSubmitTasksForDifferentMethods() {
// Given
SpiderResourceFound getResource = SpiderResourceFound.builder().setMethod(HttpRequestHeader.GET).setUri("http://test.com").build();
SpiderResourceFound postResource = SpiderResourceFound.builder().setMethod(HttpRequestHeader.POST).setUri("http://test.com").build();
SpiderResourceFound putResource = SpiderResourceFound.builder().setMethod(HttpRequestHeader.PUT).setUri("http://test.com").build();
SpiderResourceFound deleteResource = SpiderResourceFound.builder().setMethod(HttpRequestHeader.DELETE).setUri("http://test.com").build();
SpiderResourceFound headResource = SpiderResourceFound.builder().setMethod(HttpRequestHeader.HEAD).setUri("http://test.com").build();
// When
spiderController.resourceFound(getResource);
spiderController.resourceFound(postResource);
spiderController.resourceFound(putResource);
spiderController.resourceFound(deleteResource);
spiderController.resourceFound(headResource);
// Then
verify(spider, times(5)).submitTask(any());
}
use of org.zaproxy.zap.spider.parser.SpiderResourceFound in project zaproxy by zaproxy.
the class SpiderControllerUnitTest method shouldNotSubmitSameGetTaskWithDuplicateHeaders.
@Test
void shouldNotSubmitSameGetTaskWithDuplicateHeaders() {
// Given
List<HttpHeaderField> requestHeadersWithoutDuplicates = new ArrayList<>();
requestHeadersWithoutDuplicates.add(new HttpHeaderField("X-Custom-Header-1", "xyz"));
List<HttpHeaderField> requestHeadersWithDuplicates = new ArrayList<>();
requestHeadersWithDuplicates.add(new HttpHeaderField("X-Custom-Header-1", "xyz"));
requestHeadersWithDuplicates.add(new HttpHeaderField("X-Custom-Header-1", "xyz"));
requestHeadersWithDuplicates.add(new HttpHeaderField("X-Custom-Header-1", "xyz"));
SpiderResourceFound spiderResourceFound1 = createGetSpiderResourceFoundWithHeaders("https://example.com/test.html", 2, false, requestHeadersWithoutDuplicates);
SpiderResourceFound spiderResourceFound2 = createGetSpiderResourceFoundWithHeaders("https://example.com/test.html", 2, false, requestHeadersWithDuplicates);
// When
spiderController.resourceFound(spiderResourceFound1);
spiderController.resourceFound(spiderResourceFound2);
// Then
verify(spider).submitTask(any());
}
Aggregations