use of com.endava.cats.dsl.CatsDSLParser in project cats by Endava.
the class CatsUtilTest method shouldNotAddTopElement.
@Test
void shouldNotAddTopElement() {
CatsUtil catsUtil = new CatsUtil(new CatsDSLParser());
String payload = "{\"field\":\"value\", \"anotherField\":{\"subfield\": \"otherValue\"}}";
Map<String, String> currentPathValues = Collections.singletonMap("additionalProperties", "{mapValues={test1=value1,test2=value2}}");
String updatedPayload = catsUtil.setAdditionalPropertiesToPayload(currentPathValues, payload);
Assertions.assertThat(updatedPayload).doesNotContain("metadata").contains("test1");
}
use of com.endava.cats.dsl.CatsDSLParser in project cats by Endava.
the class CatsUtilTest method shouldReturnEmptyFuzzingResultWhenEmptyJson.
@Test
void shouldReturnEmptyFuzzingResultWhenEmptyJson() {
CatsUtil catsUtil = new CatsUtil(new CatsDSLParser());
FuzzingStrategy strategy = FuzzingStrategy.replace().withData("fuzzed");
FuzzingResult result = catsUtil.replaceField("", "test", strategy);
Assertions.assertThat(result.getFuzzedValue()).isEmpty();
Assertions.assertThat(result.getJson()).isEmpty();
}
use of com.endava.cats.dsl.CatsDSLParser in project cats by Endava.
the class SecurityFuzzerTest method setup.
@BeforeEach
void setup() {
catsDSLParser = new CatsDSLParser();
catsUtil = new CatsUtil(catsDSLParser);
serviceCaller = Mockito.mock(ServiceCaller.class);
filesArguments = new FilesArguments(catsUtil);
customFuzzerUtil = new CustomFuzzerUtil(serviceCaller, catsUtil, testCaseListener, catsDSLParser);
securityFuzzer = new SecurityFuzzer(filesArguments, customFuzzerUtil);
ReflectionTestUtils.setField(testCaseListener, "testCaseExporter", Mockito.mock(TestCaseExporter.class));
}
use of com.endava.cats.dsl.CatsDSLParser in project cats by Endava.
the class FunctionalFuzzerTest method setup.
@BeforeEach
void setup() {
catsDSLParser = new CatsDSLParser();
catsUtil = new CatsUtil(catsDSLParser);
serviceCaller = Mockito.mock(ServiceCaller.class);
filesArguments = new FilesArguments(catsUtil);
customFuzzerUtil = new CustomFuzzerUtil(serviceCaller, catsUtil, testCaseListener, catsDSLParser);
functionalFuzzer = new FunctionalFuzzer(filesArguments, customFuzzerUtil);
filesArguments.getCustomFuzzerDetails().clear();
ReflectionTestUtils.setField(testCaseListener, "testCaseExporter", Mockito.mock(TestCaseExporter.class));
}
use of com.endava.cats.dsl.CatsDSLParser in project cats by Endava.
the class CatsUtilTest method givenAPayloadAndAFuzzingStrategy_whenReplacingTheFuzzedValue_thenThePayloadIsProperlyFuzzed.
@ParameterizedTest
@CsvSource(value = { "{\"field\":\"value\", \"anotherField\":\"otherValue\"}|field", "{\"field\": 2, \"anotherField\":\"otherValue\"}|field", "[{\"field\": 2, \"anotherField\":\"otherValue\"},{\"field\": 2, \"anotherField\":\"otherValue\"}]|field", "{\"field\": {\"subField\":\"value\"}, \"anotherField\":\"otherValue\"}|field#subField", "{\"field\": [{\"subField\":\"value\"},{\"subField\":\"value\"}], \"anotherField\":\"otherValue\"}|field[*]#subField" }, delimiter = '|')
void givenAPayloadAndAFuzzingStrategy_whenReplacingTheFuzzedValue_thenThePayloadIsProperlyFuzzed(String json, String path) {
CatsUtil catsUtil = new CatsUtil(new CatsDSLParser());
FuzzingStrategy strategy = FuzzingStrategy.replace().withData("fuzzed");
FuzzingResult result = catsUtil.replaceField(json, path, strategy);
Assertions.assertThat(result.getFuzzedValue()).isEqualTo("fuzzed");
Assertions.assertThat(result.getJson()).contains("fuzzed");
}
Aggregations