use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.
the class HttpPrefixFetchFilterUnitTest method shouldFilterUriWithDifferentHostAsOutOfScope.
@Test
public void shouldFilterUriWithDifferentHostAsOutOfScope() throws Exception {
// Given
URI prefixUri = new URI("http://example.org/", true);
HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
URI uri = new URI("http://domain.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 shouldDiscardDefaultHttpsPortFromPrefix.
@Test
public void shouldDiscardDefaultHttpsPortFromPrefix() throws Exception {
// Given
URI prefixUri = new URI("https://example.org:443/", true);
HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
// When
String normalisedPrefix = fetchFilter.getNormalisedPrefix();
// Then
assertThat(normalisedPrefix, is(equalTo("https://example.org/")));
}
use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.
the class HttpPrefixFetchFilterUnitTest method shouldFailToCreateFetchFilterWithNoScheme.
@Test(expected = IllegalArgumentException.class)
public void shouldFailToCreateFetchFilterWithNoScheme() throws Exception {
// Given
URI prefixUri = new URI("example.org/", true);
// When
new HttpPrefixFetchFilter(prefixUri);
// Then = IllegalArgumentException
}
use of org.apache.commons.httpclient.URI in project zaproxy by zaproxy.
the class HttpPrefixFetchFilterUnitTest method shouldFilterUriWithNonHttpOrHttpsSchemeAsOutOfScope.
@Test
public void shouldFilterUriWithNonHttpOrHttpsSchemeAsOutOfScope() throws Exception {
// Given
URI prefixUri = new URI("http://example.org/", true);
HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
URI uri = new URI("ftp://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 shouldFilterUriWithSamePathPrefixAsValid.
@Test
public void shouldFilterUriWithSamePathPrefixAsValid() throws Exception {
// Given
URI prefixUri = new URI("http://example.org/path", true);
HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
URI uri = new URI("http://example.org/path/subtree", true);
// When
FetchStatus filterStatus = fetchFilter.checkFilter(uri);
// Then
assertThat(filterStatus, is(equalTo(FetchStatus.VALID)));
}
Aggregations