Search in sources :

Example 51 with ValueSource

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)));
}
Also used : Message(org.zaproxy.zap.extension.httppanel.Message) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 52 with ValueSource

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)));
}
Also used : Message(org.zaproxy.zap.extension.httppanel.Message) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 53 with ValueSource

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)));
}
Also used : Message(org.zaproxy.zap.extension.httppanel.Message) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 54 with ValueSource

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)));
}
Also used : Message(org.zaproxy.zap.extension.httppanel.Message) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 55 with ValueSource

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());
}
Also used : Alert(org.parosproxy.paros.core.scanner.Alert) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)266 ValueSource (org.junit.jupiter.params.provider.ValueSource)266 HashSet (java.util.HashSet)23 HistogramTestUtils.constructDoubleHistogram (org.HdrHistogram.HistogramTestUtils.constructDoubleHistogram)23 ArrayList (java.util.ArrayList)22 HashMap (java.util.HashMap)20 ApiResponse (org.hisp.dhis.dto.ApiResponse)15 UpdateModel (com.synopsys.integration.alert.update.model.UpdateModel)13 File (java.io.File)13 List (java.util.List)13 OffsetDateTime (java.time.OffsetDateTime)10 Map (java.util.Map)10 TimeUnit (java.util.concurrent.TimeUnit)10 TopicPartition (org.apache.kafka.common.TopicPartition)9 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)8 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)8 ZooKeeper (org.apache.zookeeper.ZooKeeper)8 JsonObject (com.google.gson.JsonObject)7 IOException (java.io.IOException)7 CountDownLatch (java.util.concurrent.CountDownLatch)7