Skip to content

Commit

Permalink
chore: Remove unused paramete from beforeFuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
en-milie committed Jun 8, 2024
1 parent c875228 commit e9b57a2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/endava/cats/command/CatsCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ private void runFuzzers(List<FuzzingData> fuzzingDataListWithHttpMethodsFiltered
logger.start("Starting Fuzzer {}, http method {}, path {}", ansi().fgGreen().a(fuzzer.toString()).reset(), data.getMethod(), data.getPath());
logger.debug("Fuzzing payload: {}", data.getPayload());
if (!(fuzzer instanceof FunctionalFuzzer)) {
testCaseListener.beforeFuzz(fuzzer.getClass(), data.getContractPath(), data.getMethod().name());
testCaseListener.beforeFuzz(fuzzer.getClass(), data.getContractPath());
}
fuzzer.fuzz(data);
if (!(fuzzer instanceof FunctionalFuzzer)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import com.endava.cats.dsl.CatsDSLParser;
import com.endava.cats.fuzzer.special.TemplateFuzzer;
import com.endava.cats.http.HttpMethod;
import com.endava.cats.util.JsonUtils;
import com.endava.cats.model.CatsHeader;
import com.endava.cats.model.FuzzingData;
import com.endava.cats.report.TestCaseListener;
import com.endava.cats.util.ConsoleUtils;
import com.endava.cats.util.JsonUtils;
import com.endava.cats.util.VersionProvider;
import com.google.common.net.HttpHeaders;
import io.github.ludovicianul.prettylogger.PrettyLogger;
Expand Down Expand Up @@ -191,7 +191,7 @@ private void afterFuzz(String path, String method) {

private void beforeFuzz(String path, String method) throws IOException {
testCaseListener.initReportingPath();
testCaseListener.beforeFuzz(templateFuzzer.getClass(), path, method);
testCaseListener.beforeFuzz(templateFuzzer.getClass(), path);
}

private Set<CatsHeader> getHeaders() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void executeCustomFuzzerTests() {
for (Map.Entry<String, Map<String, Object>> entry : filesArguments.getCustomFuzzerDetails().entrySet()) {
executions.stream().filter(customFuzzerExecution -> customFuzzerExecution.getFuzzingData().getContractPath().equalsIgnoreCase(entry.getKey()))
.forEach(customFuzzerExecution -> {
testCaseListener.beforeFuzz(this.getClass(), customFuzzerExecution.getFuzzingData().getContractPath(), customFuzzerExecution.getFuzzingData().getMethod().name());
testCaseListener.beforeFuzz(this.getClass(), customFuzzerExecution.getFuzzingData().getContractPath());
customFuzzerUtil.executeTestCases(customFuzzerExecution.getFuzzingData(), customFuzzerExecution.getTestId(),
customFuzzerExecution.getTestEntry(), this);
testCaseListener.afterFuzz(customFuzzerExecution.getFuzzingData().getContractPath(), customFuzzerExecution.getFuzzingData().getMethod().name());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/endava/cats/report/TestCaseListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private String getKeyDefault() {
*
* @param fuzzer the class representing the fuzzer
*/
public void beforeFuzz(Class<?> fuzzer, String path, String method) {
public void beforeFuzz(Class<?> fuzzer, String path) {
String clazz = ConsoleUtils.removeTrimSanitize(fuzzer.getSimpleName()).replaceAll("[a-z]", "");
MDC.put(FUZZER, ConsoleUtils.centerWithAnsiColor(clazz, getKeyDefault().length(), Ansi.Color.MAGENTA));
MDC.put(FUZZER_KEY, ConsoleUtils.removeTrimSanitize(fuzzer.getSimpleName()));
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/endava/cats/command/CatsCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void givenContractAndServerParameter_whenStartingCats_thenParametersAreProcessed
Mockito.verify(testCaseListener, Mockito.times(1)).startSession();
Mockito.verify(testCaseListener, Mockito.times(1)).endSession();
Mockito.verify(testCaseListener, Mockito.times(20)).afterFuzz(Mockito.any(), Mockito.any());
Mockito.verify(testCaseListener, Mockito.times(10)).beforeFuzz(Mockito.eq(PathTagsLinterFuzzer.class), Mockito.any(), Mockito.any());
Mockito.verify(testCaseListener, Mockito.times(10)).beforeFuzz(Mockito.eq(PathTagsLinterFuzzer.class), Mockito.any());

ReflectionTestUtils.setField(apiArguments, "contract", "empty");
ReflectionTestUtils.setField(apiArguments, "server", "empty");
Expand Down Expand Up @@ -170,8 +170,8 @@ void givenAnOpenApiContract_whenStartingCats_thenTheContractIsCorrectlyParsed()
Mockito.verify(fuzzingDataFactory).fromPathItem(Mockito.eq("/pet"), Mockito.any(), Mockito.any());
Mockito.verify(fuzzingDataFactory, Mockito.times(0)).fromPathItem(Mockito.eq("/petss"), Mockito.any(), Mockito.any());
Mockito.verify(testCaseListener, Mockito.times(13)).afterFuzz(Mockito.any(), Mockito.any());
Mockito.verify(testCaseListener, Mockito.times(9)).beforeFuzz(Mockito.eq(PathTagsLinterFuzzer.class), Mockito.anyString(), Mockito.anyString());
Mockito.verify(testCaseListener, Mockito.times(4)).beforeFuzz(Mockito.eq(CheckDeletedResourcesNotAvailableFuzzer.class), Mockito.any(), Mockito.any());
Mockito.verify(testCaseListener, Mockito.times(9)).beforeFuzz(Mockito.eq(PathTagsLinterFuzzer.class), Mockito.anyString());
Mockito.verify(testCaseListener, Mockito.times(4)).beforeFuzz(Mockito.eq(CheckDeletedResourcesNotAvailableFuzzer.class), Mockito.any());

ReflectionTestUtils.setField(apiArguments, "contract", "empty");
ReflectionTestUtils.setField(apiArguments, "server", "empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ void shouldReturnCurrentTestNumber() {

@Test
void shouldReturnCurrentFuzzer() {
testCaseListener.beforeFuzz(RandomResourcesFuzzer.class, "test", "post");
testCaseListener.beforeFuzz(RandomResourcesFuzzer.class, "test");
String currentFuzzer = testCaseListener.getCurrentFuzzer();
Assertions.assertThat(currentFuzzer).isEqualTo("RandomResources");
}
Expand All @@ -814,7 +814,7 @@ void shouldStartUnknownProgress() {
Mockito.when(reportingArguments.isSummaryInConsole()).thenReturn(true);
TestCaseListener testCaseListenerSpy = Mockito.spy(testCaseListener);
testCaseListenerSpy.updateUnknownProgress(data);
Mockito.verify(testCaseListenerSpy).notifySummaryObservers(Mockito.eq("/test"));
Mockito.verify(testCaseListenerSpy).notifySummaryObservers("/test");
}

private void prepareTestCaseListenerSimpleSetup(CatsResponse build, Runnable runnable) {
Expand Down

0 comments on commit e9b57a2

Please sign in to comment.