Search in sources :

Example 96 with URI

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

the class URLCanonicalizerUnitTest method shouldPreserveQueryParametersWithSameNameWhenCleaningParametersIn_USE_ALL_mode.

@Test
public void shouldPreserveQueryParametersWithSameNameWhenCleaningParametersIn_USE_ALL_mode() throws URIException {
    // Given
    URI uri = new URI("http://example.com/path/?param%5B%5D=value1.1&param%5B%5D=value1.2&param2=value2", true);
    // When
    String cleanedUri = URLCanonicalizer.buildCleanedParametersURIRepresentation(uri, HandleParametersOption.USE_ALL, false);
    // Then
    assertThat(cleanedUri, is(equalTo("http://example.com/path/?param%5B%5D=value1.1&param%5B%5D=value1.2&param2=value2")));
}
Also used : URI(org.apache.commons.httpclient.URI) Test(org.junit.Test)

Example 97 with URI

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

the class URLCanonicalizerUnitTest method shouldCanonicalizeNormalURLWithParametersIn_USE_ALL_mode.

@Test
public void shouldCanonicalizeNormalURLWithParametersIn_USE_ALL_mode() throws URIException {
    URI uri = new URI("http", null, "host", 9001, "/myservlet", "p1=2&p2=myparam");
    String visitedURI = URLCanonicalizer.buildCleanedParametersURIRepresentation(uri, HandleParametersOption.USE_ALL, false);
    assertThat(visitedURI, is("http://host:9001/myservlet?p1=2&p2=myparam"));
}
Also used : URI(org.apache.commons.httpclient.URI) Test(org.junit.Test)

Example 98 with URI

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

the class HttpPrefixFetchFilterUnitTest method shouldFilterUriWithDifferentSchemeButSamePortAsOutOfScope.

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

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

the class HttpPrefixFetchFilterUnitTest method shouldNotAddPathToNormalisedPrefixIfPrefixDoesNotHavePath.

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

Example 100 with URI

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

the class HttpPrefixFetchFilterUnitTest method shouldDiscardUserInfoFromPrefix.

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

Aggregations

URI (org.apache.commons.httpclient.URI)128 Test (org.junit.Test)72 FetchStatus (org.zaproxy.zap.spider.filters.FetchFilter.FetchStatus)33 URIException (org.apache.commons.httpclient.URIException)28 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 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)6 HandleParametersOption (org.zaproxy.zap.spider.SpiderParam.HandleParametersOption)6 IOException (java.io.IOException)4 Header (org.apache.commons.httpclient.Header)4 InvalidParameterException (java.security.InvalidParameterException)3 Matcher (java.util.regex.Matcher)3 Pattern (java.util.regex.Pattern)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 JSONException (net.sf.json.JSONException)3 StructuralNode (org.zaproxy.zap.model.StructuralNode)3 File (java.io.File)2 List (java.util.List)2