use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method createSpiderHtmlFormParser.
private static SpiderHtmlFormParser createSpiderHtmlFormParser(ValueGenerator valueGenerator) {
SpiderParam spiderOptions = createSpiderParamWithConfig();
spiderOptions.setProcessForm(true);
spiderOptions.setPostForm(true);
return new SpiderHtmlFormParser(spiderOptions, valueGenerator);
}
use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldParseFormAsGetIfFormHasNoMethodEvenIfPostFormProcessingIsDisabled.
@Test
void shouldParseFormAsGetIfFormHasNoMethodEvenIfPostFormProcessingIsDisabled() {
// Given
SpiderParam spiderOptions = createSpiderParamWithConfig();
spiderOptions.setProcessForm(true);
spiderOptions.setPostForm(false);
SpiderHtmlFormParser htmlParser = new SpiderHtmlFormParser(spiderOptions, new DefaultValueGenerator());
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage messageHtmlResponse = createMessageWith("NoMethodForm.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(1)));
assertThat(listener.getUrlsFound(), contains("http://example.org/?field1=Text+1&field2=Text+2&submit=Submit"));
}
use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldNotParsePostFormIfPostFormProcessingIsDisabled.
@Test
void shouldNotParsePostFormIfPostFormProcessingIsDisabled() {
// Given
SpiderParam spiderOptions = createSpiderParamWithConfig();
spiderOptions.setProcessForm(true);
spiderOptions.setPostForm(false);
SpiderHtmlFormParser htmlParser = new SpiderHtmlFormParser(spiderOptions, new DefaultValueGenerator());
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage messageHtmlResponse = createMessageWith("POST", "Form.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(0)));
}
use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.
the class DefaultParseFilterUnitTest method shouldFailToCreateDefaultParseFilterWithNullConfigs.
@Test
void shouldFailToCreateDefaultParseFilterWithNullConfigs() {
// Given
SpiderParam configs = null;
// When / Then
assertThrows(IllegalArgumentException.class, () -> new DefaultParseFilter(configs, resourceBundle));
}
use of org.zaproxy.zap.spider.SpiderParam in project zaproxy by zaproxy.
the class DefaultParseFilterUnitTest method shouldFailToCreateDefaultParseFilterWithNullResourceBundle.
@Test
void shouldFailToCreateDefaultParseFilterWithNullResourceBundle() {
// Given
ResourceBundle resourceBundle = null;
SpiderParam configs = new SpiderParam();
// When / Then
assertThrows(IllegalArgumentException.class, () -> new DefaultParseFilter(configs, resourceBundle));
}
Aggregations