Search in sources :

Example 6 with SpiderResourceFound

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());
}
Also used : HttpHeaderField(org.parosproxy.paros.network.HttpHeaderField) SpiderResourceFound(org.zaproxy.zap.spider.parser.SpiderResourceFound) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 7 with SpiderResourceFound

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());
}
Also used : SpiderResourceFound(org.zaproxy.zap.spider.parser.SpiderResourceFound) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 8 with SpiderResourceFound

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());
}
Also used : HttpHeaderField(org.parosproxy.paros.network.HttpHeaderField) SpiderResourceFound(org.zaproxy.zap.spider.parser.SpiderResourceFound) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Aggregations

SpiderResourceFound (org.zaproxy.zap.spider.parser.SpiderResourceFound)8 Test (org.junit.jupiter.api.Test)7 WithConfigsTest (org.zaproxy.zap.WithConfigsTest)7 ArrayList (java.util.ArrayList)4 HttpHeaderField (org.parosproxy.paros.network.HttpHeaderField)4 URIException (org.apache.commons.httpclient.URIException)1