use of net.htmlparser.jericho.Source in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldNeverConsiderCompletelyParsed.
@Test
public void shouldNeverConsiderCompletelyParsed() {
// Given
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
HttpMessage messageHtmlResponse = createMessageWith("NoForms.html");
Source source = createSource(messageHtmlResponse);
// When
boolean completelyParsed = htmlParser.parseResource(messageHtmlResponse, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
}
use of net.htmlparser.jericho.Source in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldIgnoreRelativePathBaseHtmlUrlWhenParsingGetFormWithAbsoluteAction.
@Test
public void shouldIgnoreRelativePathBaseHtmlUrlWhenParsingGetFormWithAbsoluteAction() {
// Given
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage msg = createMessageWith("GET", "FormWithHtmlBase.html", "/action/absolute", "base/relative/path/", "/a/b.html");
Source source = createSource(msg);
// When
boolean completelyParsed = htmlParser.parseResource(msg, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
assertThat(listener.getNumberOfUrlsFound(), is(equalTo(1)));
assertThat(listener.getUrlsFound(), contains("http://example.com/action/absolute?q=Search&submit=Submit"));
}
use of net.htmlparser.jericho.Source in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldIgnoreRelativePathBaseHtmlUrlWhenParsingPostFormWithAbsoluteAction.
@Test
public void shouldIgnoreRelativePathBaseHtmlUrlWhenParsingPostFormWithAbsoluteAction() {
// Given
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage msg = createMessageWith("POST", "FormWithHtmlBase.html", "/action/absolute", "base/relative/path/", "/a/b.html");
Source source = createSource(msg);
// When
boolean completelyParsed = htmlParser.parseResource(msg, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
assertThat(listener.getNumberOfResourcesFound(), is(equalTo(1)));
assertThat(listener.getResourcesFound(), contains(postResource(msg, 1, "http://example.com/action/absolute", "q=Search&submit=Submit")));
}
use of net.htmlparser.jericho.Source in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldIgnoreBaseHtmlIfEmptyHrefWhenParsingGetForm.
@Test
public void shouldIgnoreBaseHtmlIfEmptyHrefWhenParsingGetForm() {
// Given
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage msg = createMessageWith("GET", "FormWithHtmlBase.html", "search", "");
Source source = createSource(msg);
// When
boolean completelyParsed = htmlParser.parseResource(msg, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
assertThat(listener.getNumberOfUrlsFound(), is(equalTo(1)));
assertThat(listener.getUrlsFound(), contains("http://example.com/search?q=Search&submit=Submit"));
}
use of net.htmlparser.jericho.Source in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldIgnoreAbsolutePathBaseHtmlUrlWhenParsingPostFormWithAbsoluteAction.
@Test
public void shouldIgnoreAbsolutePathBaseHtmlUrlWhenParsingPostFormWithAbsoluteAction() {
// Given
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage msg = createMessageWith("POST", "FormWithHtmlBase.html", "/action/absolute", "/base/absolute/path/", "/a/b.html");
Source source = createSource(msg);
// When
boolean completelyParsed = htmlParser.parseResource(msg, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
assertThat(listener.getNumberOfResourcesFound(), is(equalTo(1)));
assertThat(listener.getResourcesFound(), contains(postResource(msg, 1, "http://example.com/action/absolute", "q=Search&submit=Submit")));
}
Aggregations