Search in sources :

Example 26 with URI

use of org.apache.commons.httpclient.URI 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)

Example 27 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class HttpPrefixFetchFilterUnitTest method shouldKeepNonDefaultPortFromPrefix.

@Test
public void shouldKeepNonDefaultPortFromPrefix() throws Exception {
    // Given
    URI prefixUri = new URI("https://example.org:8443/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    // When
    String normalisedPrefix = fetchFilter.getNormalisedPrefix();
    // Then
    assertThat(normalisedPrefix, is(equalTo("https://example.org:8443/")));
}
Also used : URI(org.apache.commons.httpclient.URI) Test(org.junit.Test)

Example 28 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class HttpPrefixFetchFilterUnitTest method shouldDiscardEverythingAfterPathComponentFromPrefix.

@Test
public void shouldDiscardEverythingAfterPathComponentFromPrefix() throws Exception {
    // Given
    URI prefixUri = new URI("https://example.org/path?query#fragment", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    // When
    String normalisedPrefix = fetchFilter.getNormalisedPrefix();
    // Then
    assertThat(normalisedPrefix, is(equalTo("https://example.org/path")));
}
Also used : URI(org.apache.commons.httpclient.URI) Test(org.junit.Test)

Example 29 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class HttpPrefixFetchFilterUnitTest method shouldFilterUriWithDifferentPortAsOutOfScope.

@Test
public void shouldFilterUriWithDifferentPortAsOutOfScope() throws Exception {
    // Given
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("http://example.org:1234/", 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)

Example 30 with URI

use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.

the class HttpPrefixFetchFilterUnitTest method shouldFilterUriWithDifferentSmallerPathAsOutOfScope.

@Test
public void shouldFilterUriWithDifferentSmallerPathAsOutOfScope() throws Exception {
    // Given
    URI prefixUri = new URI("http://example.org/path", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("http://example.org/p", 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)135 Test (org.junit.Test)72 FetchStatus (org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus)33 URIException (org.apache.commons.httpclient.URIException)32 HttpMessage (org.parosproxy.paros.network.HttpMessage)10 ArrayList (java.util.ArrayList)9 HttpRequestHeader (org.parosproxy.paros.network.HttpRequestHeader)8 DatabaseException (org.parosproxy.paros.db.DatabaseException)7 IOException (java.io.IOException)6 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)6 HandleParametersOption (org.zaproxy.zap.spider.SpiderParam.HandleParametersOption)6 Header (org.apache.commons.httpclient.Header)5 InvalidParameterException (java.security.InvalidParameterException)3 Matcher (java.util.regex.Matcher)3 Pattern (java.util.regex.Pattern)3 Cookie (org.apache.commons.httpclient.Cookie)3 EntityEnclosingMethod (org.apache.commons.httpclient.methods.EntityEnclosingMethod)3 StructuralNode (org.zaproxy.zap.model.StructuralNode)3 File (java.io.File)2 HashMap (java.util.HashMap)2