use of net.htmlparser.jericho.Source in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldFailToParseAnUndefinedMessage.
@Test(expected = NullPointerException.class)
public void shouldFailToParseAnUndefinedMessage() {
// Given
HttpMessage undefinedMessage = null;
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
Source source = createSource(createMessageWith("NoForms.html"));
// When
htmlParser.parseResource(undefinedMessage, source, BASE_DEPTH);
// Then = NullPointerException
}
use of net.htmlparser.jericho.Source in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldUseAbsolutePathBaseHtmlUrlWhenParsingGetFormWithRelativeAction.
@Test
public void shouldUseAbsolutePathBaseHtmlUrlWhenParsingGetFormWithRelativeAction() {
// Given
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage msg = createMessageWith("GET", "FormWithHtmlBase.html", "action/relative", "/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.getNumberOfUrlsFound(), is(equalTo(1)));
assertThat(listener.getUrlsFound(), contains("http://example.com/base/absolute/path/action/relative?q=Search&submit=Submit"));
}
Aggregations