Search in sources :

Example 6 with FilterResult

use of org.zaproxy.zap.extension.ascan.filters.FilterResult in project zaproxy by zaproxy.

the class GenericFilterUtilityTest method testEmptyFilterValuesIncludeCriteria.

@Test
void testEmptyFilterValuesIncludeCriteria() {
    // Given
    List<String> genericFilterData = new ArrayList<>();
    abstractGenericScanFilter.setFilterData(genericFilterData);
    Set<String> values = new HashSet<>();
    values.add("Dummy");
    // When
    FilterResult filterResult = abstractGenericScanFilter.isFiltered(values);
    // Then
    assertThat(filterResult.isFiltered(), is(false));
}
Also used : ArrayList(java.util.ArrayList) FilterResult(org.zaproxy.zap.extension.ascan.filters.FilterResult) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 7 with FilterResult

use of org.zaproxy.zap.extension.ascan.filters.FilterResult in project zaproxy by zaproxy.

the class GenericFilterUtilityTest method testIncludeCriteriaWithMoreValues.

@Test
void testIncludeCriteriaWithMoreValues() {
    // Given
    List<String> genericFilterData = new ArrayList<>();
    genericFilterData.add("Dummy");
    abstractGenericScanFilter.setFilterData(genericFilterData);
    Set<String> values = new HashSet<>();
    values.add("Dummy");
    values.add("Dummy1");
    // When
    FilterResult filterResult = abstractGenericScanFilter.isFiltered(values);
    // Then
    assertThat(filterResult.isFiltered(), is(false));
}
Also used : ArrayList(java.util.ArrayList) FilterResult(org.zaproxy.zap.extension.ascan.filters.FilterResult) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 8 with FilterResult

use of org.zaproxy.zap.extension.ascan.filters.FilterResult in project zaproxy by zaproxy.

the class GenericFilterUtilityTest method testShouldFailWhenValuesAndFilterDataValuesMismatchIncludeCriteria.

@Test
void testShouldFailWhenValuesAndFilterDataValuesMismatchIncludeCriteria() {
    // Given
    List<String> genericFilterData = new ArrayList<>();
    genericFilterData.add("Dummy");
    abstractGenericScanFilter.setFilterData(genericFilterData);
    Set<String> values = new HashSet<>();
    values.add("Dummy1");
    // When
    FilterResult filterResult = abstractGenericScanFilter.isFiltered(values);
    // Then
    assertThat(filterResult.isFiltered(), is(true));
}
Also used : ArrayList(java.util.ArrayList) FilterResult(org.zaproxy.zap.extension.ascan.filters.FilterResult) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 9 with FilterResult

use of org.zaproxy.zap.extension.ascan.filters.FilterResult in project zaproxy by zaproxy.

the class GenericFilterUtilityTest method testShouldFailInExcludeCriteriaWithMoreFilterValues.

@Test
void testShouldFailInExcludeCriteriaWithMoreFilterValues() {
    // Given
    List<String> genericFilterData = new ArrayList<>();
    genericFilterData.add("Dummy");
    genericFilterData.add("Dummy1");
    abstractGenericScanFilter.setFilterData(genericFilterData);
    abstractGenericScanFilter.setFilterCriteria(FilterCriteria.EXCLUDE);
    Set<String> values = new HashSet<>();
    values.add("Dummy");
    // When
    FilterResult filterResult = abstractGenericScanFilter.isFiltered(values);
    // Then
    assertThat(filterResult.isFiltered(), is(true));
}
Also used : ArrayList(java.util.ArrayList) FilterResult(org.zaproxy.zap.extension.ascan.filters.FilterResult) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Example 10 with FilterResult

use of org.zaproxy.zap.extension.ascan.filters.FilterResult in project zaproxy by zaproxy.

the class GenericFilterUtilityTest method testShouldPassForValuesAndFilterValuesMismatchInExcludeCriteria.

@Test
void testShouldPassForValuesAndFilterValuesMismatchInExcludeCriteria() {
    // Given
    List<String> genericFilterData = new ArrayList<>();
    genericFilterData.add("Dummy");
    abstractGenericScanFilter.setFilterData(genericFilterData);
    abstractGenericScanFilter.setFilterCriteria(FilterCriteria.EXCLUDE);
    Set<String> values = new HashSet<>();
    values.add("Dummy1");
    // When
    FilterResult filterResult = abstractGenericScanFilter.isFiltered(values);
    // Then
    assertThat(filterResult.isFiltered(), is(false));
}
Also used : ArrayList(java.util.ArrayList) FilterResult(org.zaproxy.zap.extension.ascan.filters.FilterResult) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) WithConfigsTest(org.zaproxy.zap.WithConfigsTest)

Aggregations

FilterResult (org.zaproxy.zap.extension.ascan.filters.FilterResult)13 Test (org.junit.jupiter.api.Test)11 ArrayList (java.util.ArrayList)10 HashSet (java.util.HashSet)10 WithConfigsTest (org.zaproxy.zap.WithConfigsTest)10 HttpMessage (org.parosproxy.paros.network.HttpMessage)2 ScanFilter (org.zaproxy.zap.extension.ascan.filters.ScanFilter)2 IOException (java.io.IOException)1 DatabaseException (org.parosproxy.paros.db.DatabaseException)1 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)1 FilterCriteria (org.zaproxy.zap.extension.ascan.filters.FilterCriteria)1 StructuralNode (org.zaproxy.zap.model.StructuralNode)1