use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class AbstractPluginUnitTest method shouldRaiseAlertWith7ParamsBingoDefaultingToMessageUriWhenGivenUriIsNull.
@Test
@SuppressWarnings("deprecation")
void shouldRaiseAlertWith7ParamsBingoDefaultingToMessageUriWhenGivenUriIsNull() {
// Given
AbstractPlugin plugin = createDefaultPlugin();
HostProcess hostProcess = mock(HostProcess.class);
plugin.init(mock(HttpMessage.class), hostProcess);
String uri = null;
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 shouldRaiseAlertWith13ParamsBingoDefaultingToMessageUriWhenGivenUriIsNull.
@Test
@SuppressWarnings("deprecation")
void shouldRaiseAlertWith13ParamsBingoDefaultingToMessageUriWhenGivenUriIsNull() {
// Given
AbstractPlugin plugin = createDefaultPlugin();
HostProcess hostProcess = mock(HostProcess.class);
plugin.init(mock(HttpMessage.class), hostProcess);
String uri = null;
String messageUri = "http://example.com/";
HttpMessage alertMessage = createAlertMessage(messageUri);
// When
plugin.bingo(Alert.RISK_LOW, Alert.CONFIDENCE_HIGH, "", "", uri, "", "", "", "", "", 0, 0, 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 isPage500ShouldReturnTrueIfNoCustomPageMatchButStatusCode500.
@Test
void isPage500ShouldReturnTrueIfNoCustomPageMatchButStatusCode500() {
// Given
CustomPage.Type type = CustomPage.Type.ERROR_500;
HttpMessage message = new HttpMessage();
message.getResponseHeader().setStatusCode(500);
given(parent.isCustomPage(message, type)).willReturn(true);
plugin.init(message, parent);
// When
boolean result = plugin.isPage500(message);
// Then
assertThat(result, is(equalTo(true)));
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 isSuccessShouldReturnFalseIfCustomPage404Matches.
@Test
void isSuccessShouldReturnFalseIfCustomPage404Matches() {
// Given
CustomPage.Type type = CustomPage.Type.NOTFOUND_404;
HttpMessage message = new HttpMessage();
message.getResponseHeader().setStatusCode(200);
given(parent.isCustomPage(message, type)).willReturn(true);
given(parent.isCustomPage(message, CustomPage.Type.ERROR_500)).willReturn(false);
given(parent.getAnalyser()).willReturn(analyser);
plugin.init(message, parent);
// When
boolean result = plugin.isSuccess(message);
// Then
assertThat(result, is(equalTo(false)));
verify(parent).isCustomPage(message, CustomPage.Type.NOTFOUND_404);
}
use of org.parosproxy.paros.network.HttpMessage in project zaproxy by zaproxy.
the class AbstractPluginUnitTest method shouldRaiseAlertWith10ParamsBingo.
@Test
@SuppressWarnings("deprecation")
void shouldRaiseAlertWith10ParamsBingo() {
// Given
AbstractPlugin plugin = createDefaultPlugin();
HostProcess hostProcess = mock(HostProcess.class);
plugin.init(mock(HttpMessage.class), hostProcess);
int risk = Alert.RISK_LOW;
int confidence = Alert.CONFIDENCE_HIGH;
String name = "name";
String description = "description";
String uri = "uri";
String param = "param";
String attack = "attack";
String otherInfo = "otherInfo";
String solution = "solution";
HttpMessage alertMessage = createAlertMessage();
// When
plugin.bingo(risk, confidence, name, description, uri, param, attack, otherInfo, solution, alertMessage);
// Then
Alert alert = getRaisedAlert(hostProcess);
assertThat(alert.getPluginId(), is(equalTo(plugin.getId())));
assertThat(alert.getName(), is(equalTo(name)));
assertThat(alert.getRisk(), is(equalTo(risk)));
assertThat(alert.getConfidence(), is(equalTo(confidence)));
assertThat(alert.getDescription(), is(equalTo(description)));
assertThat(alert.getUri(), is(equalTo(uri)));
assertThat(alert.getParam(), is(equalTo(param)));
assertThat(alert.getAttack(), is(equalTo(attack)));
assertThat(alert.getEvidence(), is(equalTo("")));
assertThat(alert.getOtherInfo(), is(equalTo(otherInfo)));
assertThat(alert.getSolution(), is(equalTo(solution)));
assertThat(alert.getReference(), is(equalTo(plugin.getReference())));
assertThat(alert.getCweId(), is(equalTo(plugin.getCweId())));
assertThat(alert.getWascId(), is(equalTo(plugin.getWascId())));
assertThat(alert.getMessage(), is(sameInstance(alertMessage)));
}
Aggregations