use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderTextParserUnitTest method shouldNeverConsiderCompletelyParsed.
@Test
public void shouldNeverConsiderCompletelyParsed() {
// Given
SpiderTextParser spiderParser = new SpiderTextParser();
HttpMessage message = createMessageWith("Non Empty Body...");
Source source = createSource(message);
// When
boolean completelyParsed = spiderParser.parseResource(message, source, BASE_DEPTH);
// Then
assertThat(completelyParsed, is(equalTo(false)));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderTextParserUnitTest method shouldFailToEvaluateAnUndefinedMessage.
@Test(expected = NullPointerException.class)
public void shouldFailToEvaluateAnUndefinedMessage() {
// Given
HttpMessage undefinedMessage = null;
SpiderTextParser spiderParser = new SpiderTextParser();
// When
spiderParser.canParseResource(undefinedMessage, ROOT_PATH, false);
// Then = NullPointerException
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class UserUnitTest method shouldRequireAuthenticationAfterResetWithOlderMessage.
@Test
public void shouldRequireAuthenticationAfterResetWithOlderMessage() {
// Given
User u = spy(new User(CONTEXT_ID, USER_NAME));
u.setAuthenticatedSession(Mockito.mock(WebSession.class));
doReturn(3500l).when(u).getLastSuccessfulAuthTime();
// When
HttpMessage msg = Mockito.mock(HttpMessage.class);
when(msg.getTimeSentMillis()).thenReturn(3200l);
u.queueAuthentication(msg);
// Then
verify(msg).getTimeSentMillis();
assertFalse(u.requiresAuthentication());
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderHtmlFormParserUnitTest method shouldParseFormAsGetIfNeitherGetNorPostForm.
@Test
public void shouldParseFormAsGetIfNeitherGetNorPostForm() {
// Given
SpiderHtmlFormParser htmlParser = createSpiderHtmlFormParser();
TestSpiderParserListener listener = createTestSpiderParserListener();
htmlParser.addSpiderParserListener(listener);
HttpMessage messageHtmlResponse = createMessageWith("NonGetPostForm.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.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class SpiderHtmlParserUnitTest method shouldParseMessageEvenWithoutSource.
@Test
public void shouldParseMessageEvenWithoutSource() {
// Given
Source source = null;
SpiderHtmlParser htmlParser = new SpiderHtmlParser(new SpiderParam());
HttpMessage messageHtmlResponse = createMessageWith("NoURLsSpiderHtmlParser.html");
// When
htmlParser.parseResource(messageHtmlResponse, source, BASE_DEPTH);
// Then = No exception
}
Aggregations