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)));
}
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
}
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")));
}
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"));
}
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)));
}
Aggregations