Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
notshivansh committed Jan 1, 2025
1 parent 8c55b2f commit b3fb15f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 27 deletions.
22 changes: 1 addition & 21 deletions apps/testing/src/main/java/com/akto/testing/TestExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -891,26 +891,6 @@ public TestingRunResult runTestNew(ApiInfo.ApiInfoKey apiInfoKey, ObjectId testR
List<CustomAuthType> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.Arrays;
import java.util.List;

import com.akto.util.Util;

public class SampleData {
Expand Down
6 changes: 2 additions & 4 deletions libs/utils/src/main/java/com/akto/testing/ApiExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class ApiExecutor {
private static Map<Integer, TestScript> testScriptMap = new HashMap<>();

private static OriginalHttpResponse common(Request request, boolean followRedirects, boolean debug, List<TestingRunResult.TestLog> testLogs, boolean skipSSRFCheck, String requestProtocol) throws Exception {

Integer accountId = Context.accountId.get();
if (accountId != null) {
int i = 0;
Expand Down Expand Up @@ -387,7 +388,7 @@ public void writeTo(BufferedSink sink) throws IOException {

}

public static void calculateFinalRequestFromAdvancedSettings(OriginalHttpRequest originalHttpRequest, List<TestConfigsAdvancedSettings> advancedSettings){
private static void calculateFinalRequestFromAdvancedSettings(OriginalHttpRequest originalHttpRequest, List<TestConfigsAdvancedSettings> advancedSettings){
Map<String,List<ConditionsType>> headerConditions = new HashMap<>();
Map<String,List<ConditionsType>> payloadConditions = new HashMap<>();

Expand All @@ -414,7 +415,6 @@ public static void calculateFinalRequestFromAdvancedSettings(OriginalHttpRequest
}

private static OriginalHttpResponse sendWithRequestBody(OriginalHttpRequest request, Request.Builder builder, boolean followRedirects, boolean debug, List<TestingRunResult.TestLog> testLogs, boolean skipSSRFCheck, String requestProtocol) throws Exception {

Map<String,List<String>> headers = request.getHeaders();
if (headers == null) {
headers = new HashMap<>();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion libs/utils/src/main/java/com/akto/testing/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ public static void modifyBodyOperations(OriginalHttpRequest httpRequest, List<Co
}



httpRequest.setBody(payloadStr);
}

Expand Down

0 comments on commit b3fb15f

Please sign in to comment.