use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class AbstractPluginUnitTest method isPage500ShouldReturnFalseIfNoStatusCodeOrCustomPageMatches.
@Test
void isPage500ShouldReturnFalseIfNoStatusCodeOrCustomPageMatches() {
// Given
CustomPage.Type type = CustomPage.Type.ERROR_500;
HttpMessage message = new HttpMessage();
message.getResponseHeader().setStatusCode(200);
given(parent.isCustomPage(message, type)).willReturn(false);
plugin.init(message, parent);
// When
boolean result = plugin.isPage500(message);
// Then
assertThat(result, is(equalTo(false)));
verify(parent).isCustomPage(message, CustomPage.Type.OK_200);
verify(parent).isCustomPage(message, CustomPage.Type.NOTFOUND_404);
verify(parent).isCustomPage(message, type);
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class AbstractPluginUnitTest method isClientErrorShouldReturnTrueIfStatusCodeMatches.
@Test
void isClientErrorShouldReturnTrueIfStatusCodeMatches() {
// Given
CustomPage.Type type = CustomPage.Type.NOTFOUND_404;
HttpMessage message = new HttpMessage();
message.getResponseHeader().setStatusCode(403);
plugin.init(message, parent);
given(parent.isCustomPage(message, type)).willReturn(false);
given(parent.isCustomPage(message, CustomPage.Type.OK_200)).willReturn(false);
given(parent.getAnalyser()).willReturn(analyser);
given(parent.getAnalyser().isFileExist(message)).willReturn(false);
// When
boolean result = plugin.isClientError(message);
// Then
assertThat(result, is(equalTo(true)));
verify(parent).isCustomPage(message, type);
verify(parent).isCustomPage(message, CustomPage.Type.OK_200);
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class AbstractPluginUnitTest method shouldRaiseAlertWith10ParamsBingoDefaultingToMessageUriWhenGivenUriIsEmpty.
@Test
@SuppressWarnings("deprecation")
void shouldRaiseAlertWith10ParamsBingoDefaultingToMessageUriWhenGivenUriIsEmpty() {
// Given
AbstractPlugin plugin = createDefaultPlugin();
HostProcess hostProcess = mock(HostProcess.class);
plugin.init(mock(HttpMessage.class), hostProcess);
String uri = "";
String messageUri = "http://example.com/";
HttpMessage alertMessage = createAlertMessage(messageUri);
// When
plugin.bingo(Alert.RISK_LOW, Alert.CONFIDENCE_HIGH, "", "", uri, "", "", "", "", alertMessage);
// Then
Alert alert = getRaisedAlert(hostProcess);
assertThat(alert.getUri(), is(equalTo(messageUri)));
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class AbstractPluginUnitTest method isPage500ShouldReturnFalseIfNoStatusCodeOrCustomPageMatchesButCustomPage200Does.
@Test
void isPage500ShouldReturnFalseIfNoStatusCodeOrCustomPageMatchesButCustomPage200Does() {
// Given
CustomPage.Type type = CustomPage.Type.ERROR_500;
HttpMessage message = new HttpMessage();
message.getResponseHeader().setStatusCode(302);
given(parent.isCustomPage(message, type)).willReturn(false);
given(parent.isCustomPage(message, CustomPage.Type.OK_200)).willReturn(true);
plugin.init(message, parent);
// When
boolean result = plugin.isPage500(message);
// Then
assertThat(result, is(equalTo(false)));
verify(parent).isCustomPage(message, CustomPage.Type.OK_200);
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class AbstractPluginUnitTest method isSuccessShouldReturnTrueIfStatusCodeMatches.
@Test
void isSuccessShouldReturnTrueIfStatusCodeMatches() {
// Given
CustomPage.Type type = CustomPage.Type.NOTFOUND_404;
HttpMessage message = new HttpMessage();
message.getResponseHeader().setStatusCode(204);
plugin.init(message, parent);
given(parent.isCustomPage(message, CustomPage.Type.NOTFOUND_404)).willReturn(false);
given(parent.isCustomPage(message, CustomPage.Type.ERROR_500)).willReturn(false);
given(parent.isCustomPage(message, type)).willReturn(false);
given(parent.getAnalyser()).willReturn(analyser);
given(parent.getAnalyser().isFileExist(message)).willReturn(false);
// When
boolean result = plugin.isSuccess(message);
// Then
assertThat(result, is(equalTo(true)));
verify(parent).isCustomPage(message, CustomPage.Type.NOTFOUND_404);
verify(parent).isCustomPage(message, CustomPage.Type.ERROR_500);
verify(parent).isCustomPage(message, type);
}
Aggregations