Search in sources :

Example 11 with FetchStatus

use of org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus in project zaproxy by zaproxy.

the class DefaultFetchFilterUnitTest method shouldFilterInContextUriAsValid.

@Test
public void shouldFilterInContextUriAsValid() throws Exception {
    // Given
    filter.setScanContext(contextInScope(true));
    URI uri = createUri("http://example.com");
    // When
    FetchStatus status = filter.checkFilter(uri);
    // Then
    assertThat(status, is(equalTo(FetchStatus.VALID)));
}
Also used : URI(org.apache.commons.httpclient.URI) FetchStatus(org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus) Test(org.junit.Test)

Example 12 with FetchStatus

use of org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus in project zaproxy by zaproxy.

the class DefaultFetchFilterUnitTest method shouldFilterNonExcludedAlwaysInScopeUriAsValid.

@Test
public void shouldFilterNonExcludedAlwaysInScopeUriAsValid() throws Exception {
    // Given
    filter.setDomainsAlwaysInScope(domainsAlwaysInScope("example.com"));
    filter.setExcludeRegexes(excludeRegexes("subdomain\\.example\\.com.*"));
    URI uri = createUri("http://example.com");
    // When
    FetchStatus status = filter.checkFilter(uri);
    // Then
    assertThat(status, is(equalTo(FetchStatus.VALID)));
}
Also used : URI(org.apache.commons.httpclient.URI) FetchStatus(org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus) Test(org.junit.Test)

Example 13 with FetchStatus

use of org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus in project zaproxy by zaproxy.

the class DefaultFetchFilterUnitTest method shouldFilterNonExcludedInScopeUriAsValid.

@Test
public void shouldFilterNonExcludedInScopeUriAsValid() throws Exception {
    // Given
    filter.addScopeRegex("example.com");
    filter.setExcludeRegexes(excludeRegexes("subdomain\\.example\\.com.*"));
    URI uri = createUri("http://example.com");
    // When
    FetchStatus status = filter.checkFilter(uri);
    // Then
    assertThat(status, is(equalTo(FetchStatus.VALID)));
}
Also used : URI(org.apache.commons.httpclient.URI) FetchStatus(org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus) Test(org.junit.Test)

Example 14 with FetchStatus

use of org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus in project zaproxy by zaproxy.

the class DefaultFetchFilterUnitTest method shouldFilterExcludedInContextUriAsUserRules.

@Test
public void shouldFilterExcludedInContextUriAsUserRules() throws Exception {
    // Given
    filter.setScanContext(contextInScope(true));
    filter.setExcludeRegexes(excludeRegexes(".*example\\.com.*"));
    URI uri = createUri("http://example.com");
    // When
    FetchStatus status = filter.checkFilter(uri);
    // Then
    assertThat(status, is(equalTo(FetchStatus.USER_RULES)));
}
Also used : URI(org.apache.commons.httpclient.URI) FetchStatus(org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus) Test(org.junit.Test)

Example 15 with FetchStatus

use of org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus in project zaproxy by zaproxy.

the class HttpPrefixFetchFilterUnitTest method shouldFilterUriWithNoHostAsOutOfScope.

@Test
public void shouldFilterUriWithNoHostAsOutOfScope() throws Exception {
    // Given
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("http://", true);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(uri);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}
Also used : URI(org.apache.commons.httpclient.URI) FetchStatus(org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus) Test(org.junit.Test)

Aggregations

URI (org.apache.commons.httpclient.URI)33 FetchStatus (org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus)33 Test (org.junit.Test)31 FetchFilter (org.zaproxy.zap.spider.filters.FetchFilter)2 ArrayList (java.util.ArrayList)1 URIException (org.apache.commons.httpclient.URIException)1