use of org.junit.jupiter.params.provider.ValueSource in project zaproxy by zaproxy.
the class BreakpointMessageHandler2UnitTest method shouldBeBreakpointIfIgnoreRulesMatchButNotEnable.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldBeBreakpointIfIgnoreRulesMatchButNotEnable(boolean request) {
// Given
Message message = mock(Message.class);
given(message.isInScope()).willReturn(true);
given(breakpointManagementInterface.isBreakRequest()).willReturn(true);
given(breakpointManagementInterface.isBreakResponse()).willReturn(true);
BreakpointMessageInterface skipBreakpoint = mock(BreakpointMessageInterface.class);
given(skipBreakpoint.isEnabled()).willReturn(false);
given(skipBreakpoint.match(message, request, false)).willReturn(true);
List<BreakpointMessageInterface> ignoreRules = Arrays.asList(skipBreakpoint);
breakpointMessageHandler.setEnabledIgnoreRules(ignoreRules);
// When
boolean breakpoint = breakpointMessageHandler.isBreakpoint(message, request, false);
// Then
assertThat(breakpoint, is(equalTo(true)));
}
use of org.junit.jupiter.params.provider.ValueSource in project zaproxy by zaproxy.
the class BreakpointMessageHandler2UnitTest method shouldBeBreakpointIfIgnoreRulesDoNotMatch.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldBeBreakpointIfIgnoreRulesDoNotMatch(boolean request) {
// Given
Message message = mock(Message.class);
given(message.isInScope()).willReturn(true);
given(breakpointManagementInterface.isBreakRequest()).willReturn(true);
given(breakpointManagementInterface.isBreakResponse()).willReturn(true);
BreakpointMessageInterface skipBreakpoint = mock(BreakpointMessageInterface.class);
given(skipBreakpoint.isEnabled()).willReturn(true);
given(skipBreakpoint.match(message, request, false)).willReturn(false);
List<BreakpointMessageInterface> ignoreRules = Arrays.asList(skipBreakpoint);
breakpointMessageHandler.setEnabledIgnoreRules(ignoreRules);
// When
boolean breakpoint = breakpointMessageHandler.isBreakpoint(message, request, false);
// Then
assertThat(breakpoint, is(equalTo(true)));
}
use of org.junit.jupiter.params.provider.ValueSource in project zaproxy by zaproxy.
the class BreakpointMessageHandler2UnitTest method shouldNotFailWithoutIgnoreRules.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldNotFailWithoutIgnoreRules(boolean request) {
// Given
Message message = mock(Message.class);
given(message.isInScope()).willReturn(false);
boolean onlyIfInScope = true;
breakpointMessageHandler.setEnabledIgnoreRules(null);
// When
boolean breakpoint = assertDoesNotThrow(() -> breakpointMessageHandler.isBreakpoint(message, request, onlyIfInScope));
// Then
assertThat(breakpoint, is(equalTo(false)));
}
use of org.junit.jupiter.params.provider.ValueSource in project zaproxy by zaproxy.
the class BreakpointMessageHandler2UnitTest method shouldNotBeBreakpointIfMessageNotInScopeWithOnlyIfInScope.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldNotBeBreakpointIfMessageNotInScopeWithOnlyIfInScope(boolean request) {
// Given
Message message = mock(Message.class);
given(message.isInScope()).willReturn(false);
boolean onlyIfInScope = true;
// When
boolean breakpoint = breakpointMessageHandler.isBreakpoint(message, request, onlyIfInScope);
// Then
assertThat(breakpoint, is(equalTo(false)));
}
use of org.junit.jupiter.params.provider.ValueSource in project zaproxy by zaproxy.
the class ExtensionAlertUnitTest method shouldPrependAlertTagCorrectly.
@ParameterizedTest
@ValueSource(strings = { "Value with whitespace", "example.value", "example_value", "" })
void shouldPrependAlertTagCorrectly(String value) {
extAlert.setAlertOverrideProperty("1.tag." + ORIGINAL_TAG_KEY, "-" + value);
Alert alert1 = newAlert(1);
extAlert.applyOverrides(alert1);
// When/Then
assertEquals(ORIGINAL_NAME, alert1.getName());
assertEquals(ORIGINAL_DESC, alert1.getDescription());
assertEquals(ORIGINAL_SOLN, alert1.getSolution());
assertEquals(ORIGINAL_OTHER, alert1.getOtherInfo());
assertEquals(ORIGINAL_REF, alert1.getReference());
assertEquals(value + ORIGINAL_TAG_VALUE, alert1.getTags().get(ORIGINAL_TAG_KEY));
// Check other alerts are not affected
Alert alert2 = newAlert(2);
extAlert.applyOverrides(alert2);
// When/Then
assertEquals(ORIGINAL_NAME, alert2.getName());
assertEquals(ORIGINAL_DESC, alert2.getDescription());
assertEquals(ORIGINAL_SOLN, alert2.getSolution());
assertEquals(ORIGINAL_OTHER, alert2.getOtherInfo());
assertEquals(ORIGINAL_REF, alert2.getReference());
assertEquals(ORIGINAL_TAG, alert2.getTags());
}
Aggregations