use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderHtmlParserUnitTest method shouldFindUrlsInImgElements.
@Test
public void shouldFindUrlsInImgElements() {
// Given
SpiderHtmlParser htmlParser = new SpiderHtmlParser(new SpiderParam());
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage messageHtmlResponse = createMessageWith("ImgElementsSpiderHtmlParser.html");
Source source = createSource(messageHtmlResponse);
// When
boolean completelyParsed = htmlParser.parseResource(messageHtmlResponse, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
assertThat(listener.getNumberOfUrlsFound(), is(equalTo(7)));
assertThat(listener.getUrlsFound(), contains("http://img.example.com/base/scheme", "http://img.example.com:8000/b", "https://img.example.com/c?a=b", "http://example.com/sample/img/relative", "http://example.com/sample/", "http://example.com/img/absolute", "ftp://img.example.com/"));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderHtmlParserUnitTest method shouldNeverConsiderCompletelyParsed.
@Test
public void shouldNeverConsiderCompletelyParsed() {
// Given
Source source = null;
SpiderHtmlParser htmlParser = new SpiderHtmlParser(new SpiderParam());
HttpMessage messageHtmlResponse = createMessageWith("NoURLsSpiderHtmlParser.html");
// When
boolean completelyParsed = htmlParser.parseResource(messageHtmlResponse, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderHtmlParserUnitTest method shouldFindUrlsInFrameElements.
@Test
public void shouldFindUrlsInFrameElements() {
// Given
SpiderHtmlParser htmlParser = new SpiderHtmlParser(new SpiderParam());
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage messageHtmlResponse = createMessageWith("FrameElementsSpiderHtmlParser.html");
Source source = createSource(messageHtmlResponse);
// When
boolean completelyParsed = htmlParser.parseResource(messageHtmlResponse, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
assertThat(listener.getNumberOfUrlsFound(), is(equalTo(7)));
assertThat(listener.getUrlsFound(), contains("http://frame.example.com/base/scheme", "http://frame.example.com:8000/b", "https://frame.example.com/c?a=b", "http://example.com/sample/frame/relative", "http://example.com/sample/", "http://example.com/frame/absolute", "ftp://frame.example.com/"));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderHtmlParserUnitTest method shouldNotParseHtmlResponseIfAlreadyParsed.
@Test
public void shouldNotParseHtmlResponseIfAlreadyParsed() {
// Given
SpiderHtmlParser htmlParser = new SpiderHtmlParser(new SpiderParam());
HttpMessage messageHtmlResponse = createMessageWith("NoURLsSpiderHtmlParser.html");
boolean parsed = true;
// When
boolean canParse = htmlParser.canParseResource(messageHtmlResponse, ROOT_PATH, parsed);
// Then
assertThat(canParse, is(equalTo(false)));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderSitemapXMLParserUnitTest method shouldNotParseXmlMessageWithDoctype.
@Test
public void shouldNotParseXmlMessageWithDoctype() {
// Given
SpiderSitemapXMLParser spiderParser = createSpiderSitemapXMLParser();
HttpMessage message = createMessageWith("DoctypeSitemap.xml");
// When
boolean completelyParsed = spiderParser.parseResource(message, null, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
}
Aggregations