From b3fb15fc54b30d46807a7b70b1636d9368b0e1a2 Mon Sep 17 00:00:00 2001 From: notshivansh Date: Wed, 1 Jan 2025 16:53:35 +0530 Subject: [PATCH] clean up --- .../java/com/akto/testing/TestExecutor.java | 22 +------------------ .../java/com/akto/dto/traffic/SampleData.java | 1 - .../java/com/akto/testing/ApiExecutor.java | 6 ++--- .../src/main/java/com/akto/testing/Utils.java | 1 - 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java index 3ed4a0a2fa..8477cf6b95 100644 --- a/apps/testing/src/main/java/com/akto/testing/TestExecutor.java +++ b/apps/testing/src/main/java/com/akto/testing/TestExecutor.java @@ -225,7 +225,7 @@ public void apiWiseInit(TestingRun testingRun, ObjectId summaryId, boolean debug try { currentTime = Context.now(); loggerMaker.infoAndAddToDb("Starting StatusCodeAnalyser at: " + currentTime, LogDb.TESTING); - // StatusCodeAnalyser.run(sampleDataMapForStatusCodeAnalyser, sampleMessageStore , authMechanismStore, testingRun.getTestingRunConfig(), hosts); + StatusCodeAnalyser.run(sampleDataMapForStatusCodeAnalyser, sampleMessageStore , authMechanismStore, testingRun.getTestingRunConfig(), hosts); loggerMaker.infoAndAddToDb("Completing StatusCodeAnalyser in: " + (Context.now() - currentTime) + " at: " + Context.now(), LogDb.TESTING); } catch (Exception e) { loggerMaker.errorAndAddToDb("Error while running status code analyser " + e.getMessage(), LogDb.TESTING); @@ -891,26 +891,6 @@ public TestingRunResult runTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testR List customAuthTypes = testingUtil.getCustomAuthTypes(); // TestingUtil -> authMechanism // TestingConfig -> auth - - System.out.println("reached here Test Executor:855..."); - - if(testingRunConfig != null && testingRunConfig.getConfigsAdvancedSettings() != null && !testingRunConfig.getConfigsAdvancedSettings().isEmpty()){ - ApiExecutor.calculateFinalRequestFromAdvancedSettings(rawApi.getRequest(), testingRunConfig.getConfigsAdvancedSettings()); - // try { - // OriginalHttpResponse response = ApiExecutor.sendRequest(rawApi.getRequest(), false, testingRunConfig, false, new ArrayList<>()); - // if (response.getStatusCode() < 300) { - // rawApi = new RawApi(rawApi.getRequest(), response, ""); - // rawApi.fillOriginalMessage(0, 0, "", ""); - // } - // } catch (Exception e) { - // System.out.println("exception while making initial req: " + e.getMessage()); - // e.printStackTrace(); - // } - } - - - - com.akto.test_editor.execution.Executor executor = new Executor(); executor.overrideTestUrl(rawApi, testingRunConfig); YamlTestTemplate yamlTestTemplate = new YamlTestTemplate(apiInfoKey,filterNode, validatorNode, executorNode, diff --git a/libs/dao/src/main/java/com/akto/dto/traffic/SampleData.java b/libs/dao/src/main/java/com/akto/dto/traffic/SampleData.java index dc1f170d23..6fa212bf60 100644 --- a/libs/dao/src/main/java/com/akto/dto/traffic/SampleData.java +++ b/libs/dao/src/main/java/com/akto/dto/traffic/SampleData.java @@ -2,7 +2,6 @@ import java.util.Arrays; import java.util.List; - import com.akto.util.Util; public class SampleData { diff --git a/libs/utils/src/main/java/com/akto/testing/ApiExecutor.java b/libs/utils/src/main/java/com/akto/testing/ApiExecutor.java index 2443385e47..fd9a6bedde 100644 --- a/libs/utils/src/main/java/com/akto/testing/ApiExecutor.java +++ b/libs/utils/src/main/java/com/akto/testing/ApiExecutor.java @@ -37,6 +37,7 @@ public class ApiExecutor { private static Map testScriptMap = new HashMap<>(); private static OriginalHttpResponse common(Request request, boolean followRedirects, boolean debug, List testLogs, boolean skipSSRFCheck, String requestProtocol) throws Exception { + Integer accountId = Context.accountId.get(); if (accountId != null) { int i = 0; @@ -387,7 +388,7 @@ public void writeTo(BufferedSink sink) throws IOException { } - public static void calculateFinalRequestFromAdvancedSettings(OriginalHttpRequest originalHttpRequest, List advancedSettings){ + private static void calculateFinalRequestFromAdvancedSettings(OriginalHttpRequest originalHttpRequest, List advancedSettings){ Map> headerConditions = new HashMap<>(); Map> payloadConditions = new HashMap<>(); @@ -414,7 +415,6 @@ public static void calculateFinalRequestFromAdvancedSettings(OriginalHttpRequest } private static OriginalHttpResponse sendWithRequestBody(OriginalHttpRequest request, Request.Builder builder, boolean followRedirects, boolean debug, List testLogs, boolean skipSSRFCheck, String requestProtocol) throws Exception { - Map> headers = request.getHeaders(); if (headers == null) { headers = new HashMap<>(); @@ -465,7 +465,6 @@ private static OriginalHttpResponse sendWithRequestBody(OriginalHttpRequest requ } if (payload == null) payload = ""; - if (body == null) {// body not created by GRPC block yet if (request.getHeaders().containsKey("charset")) { body = RequestBody.create(payload, null); @@ -474,7 +473,6 @@ private static OriginalHttpResponse sendWithRequestBody(OriginalHttpRequest requ body = RequestBody.create(payload, MediaType.parse(contentType)); } } - builder = builder.method(request.getMethod(), body); Request okHttpRequest = builder.build(); return common(okHttpRequest, followRedirects, debug, testLogs, skipSSRFCheck, requestProtocol); diff --git a/libs/utils/src/main/java/com/akto/testing/Utils.java b/libs/utils/src/main/java/com/akto/testing/Utils.java index a228dfa437..77913061df 100644 --- a/libs/utils/src/main/java/com/akto/testing/Utils.java +++ b/libs/utils/src/main/java/com/akto/testing/Utils.java @@ -395,7 +395,6 @@ public static void modifyBodyOperations(OriginalHttpRequest httpRequest, List