Search in sources :

Example 6 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldFilterHttpMessageWithNonTextResponse.

@Test
void shouldFilterHttpMessageWithNonTextResponse() throws Exception {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = createDefaultRequest();
    httpMessage.setResponseHeader("HTTP/1.1 200 OK\r\nContent-Type: application/x-binary\r\n");
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(true)));
    assertThat(filterResult.getReason(), is(equalTo(FILTERED_REASON_NOT_TEXT)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 7 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldFilterHttpMessageWithEmptyRequestHeader.

@Test
void shouldFilterHttpMessageWithEmptyRequestHeader() {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = new HttpMessage();
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(true)));
    assertThat(filterResult.getReason(), is(equalTo(FILTERED_REASON_EMPTY)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 8 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldNotFilterHttpMessageWithSitemapXmlRequestEvenWithContentType.

@Test
void shouldNotFilterHttpMessageWithSitemapXmlRequestEvenWithContentType() throws Exception {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = createHttpMessageWithRequestUri("/sitemap.xml");
    httpMessage.getResponseHeader().setHeader(HttpHeader.CONTENT_TYPE, "application/xml");
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(false)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 9 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldFilterHttpMessageWithEmptyResponseHeader.

@Test
void shouldFilterHttpMessageWithEmptyResponseHeader() {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = createDefaultRequest();
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(true)));
    assertThat(filterResult.getReason(), is(equalTo(FILTERED_REASON_EMPTY)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 10 with FilterResult

use of org.zaproxy.zap.spider.filters.ParseFilter.FilterResult in project zaproxy by zaproxy.

the class DefaultParseFilterUnitTest method shouldNotFilterHttpMessageWithSvnXmlRequest.

@Test
void shouldNotFilterHttpMessageWithSvnXmlRequest() throws Exception {
    // Given
    DefaultParseFilter filter = createDefaultParseFilter();
    HttpMessage httpMessage = createHttpMessageWithRequestUri("/.svn/wc.db");
    // When
    FilterResult filterResult = filter.filtered(httpMessage);
    // Then
    assertThat(filterResult.isFiltered(), is(equalTo(false)));
}
Also used : FilterResult(org.zaproxy.zap.spider.filters.ParseFilter.FilterResult) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Aggregations

HttpMessage (org.parosproxy.paros.network.HttpMessage)17 FilterResult (org.zaproxy.zap.spider.filters.ParseFilter.FilterResult)17 Test (org.junit.jupiter.api.Test)16 IOException (java.io.IOException)1 ConnectException (java.net.ConnectException)1 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 UnknownHostException (java.net.UnknownHostException)1 SSLException (javax.net.ssl.SSLException)1 URIException (org.apache.commons.httpclient.URIException)1 DatabaseException (org.parosproxy.paros.db.DatabaseException)1 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)1 ParseFilter (org.zaproxy.zap.spider.filters.ParseFilter)1