Search in sources :

Example 11 with URI

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

the class HttpPrefixFetchFilterUnitTest method shouldFilterUriWithDifferentNonEmptyPathAsOutOfScope.

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

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

the class HttpPrefixFetchFilterUnitTest method shouldFailToCreateFetchFilterWithNoHost.

@Test(expected = IllegalArgumentException.class)
public void shouldFailToCreateFetchFilterWithNoHost() throws Exception {
    // Given
    URI prefixUri = new URI("http://", true);
    // When
    new HttpPrefixFetchFilter(prefixUri);
// Then = IllegalArgumentException
}
Also used : URI(org.apache.commons.httpclient.URI) Test(org.junit.Test)

Example 13 with URI

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

the class URLCanonicalizerUnitTest method shouldCorrectlyParseQueryParameterNamesAndValuesWithAmpersandsAndEqualsWhenCanonicalizing.

@Test
public void shouldCorrectlyParseQueryParameterNamesAndValuesWithAmpersandsAndEqualsWhenCanonicalizing() throws URIException {
    // Given
    String uri = new URI("http://example.com/?par%26am%3D1=val%26u%3De1", true).toString();
    // When
    String canonicalizedUri = URLCanonicalizer.getCanonicalURL(uri);
    // Then
    assertThat(canonicalizedUri, is(equalTo("http://example.com/?par%26am%3D1=val%26u%3De1")));
}
Also used : URI(org.apache.commons.httpclient.URI) Test(org.junit.Test)

Example 14 with URI

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

the class URLCanonicalizerUnitTest method shouldCanonicalizeNormalURLWithoutParametersIn_USE_ALL_mode.

// Test of the legacy behavior
@Test
public void shouldCanonicalizeNormalURLWithoutParametersIn_USE_ALL_mode() throws URIException {
    URI uri = new URI("http", null, "host", 9001, "/myservlet");
    String visitedURI = URLCanonicalizer.buildCleanedParametersURIRepresentation(uri, HandleParametersOption.USE_ALL, false);
    assertThat(visitedURI, is("http://host:9001/myservlet"));
}
Also used : URI(org.apache.commons.httpclient.URI) Test(org.junit.Test)

Example 15 with URI

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

the class DefaultFetchFilterUnitTest method shouldFilterNonAlwaysInScopeUriAsOutOfScope.

@Test
public void shouldFilterNonAlwaysInScopeUriAsOutOfScope() throws Exception {
    // Given
    filter.setDomainsAlwaysInScope(domainsAlwaysInScope("scope.example.com"));
    URI uri = createUri("https://example.com");
    // When
    FetchStatus status = filter.checkFilter(uri);
    // Then
    assertThat(status, 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