From eb5cfe7e872ef7f117bf8954525e1033593fe951 Mon Sep 17 00:00:00 2001 From: Ankush Jain Date: Mon, 20 Nov 2023 13:58:06 +0530 Subject: [PATCH] fix id --- .../akto/action/testing/StartTestAction.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java b/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java index 8b6a4101be..e59e0dc211 100644 --- a/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java +++ b/apps/dashboard/src/main/java/com/akto/action/testing/StartTestAction.java @@ -37,13 +37,7 @@ import org.bson.conversions.Bson; import org.bson.types.ObjectId; -import java.util.HashMap; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; public class StartTestAction extends UserAction { @@ -139,7 +133,8 @@ private TestingRun createTestingRun(int scheduleTimestamp, int periodInSeconds) return null; } if (this.selectedTests != null) { - TestingRunConfig testingRunConfig = new TestingRunConfig(Context.now(), null, this.selectedTests,authMechanism.getId(), this.overriddenTestAppUrl); + int id = UUID.randomUUID().hashCode(); + TestingRunConfig testingRunConfig = new TestingRunConfig(id, null, this.selectedTests,authMechanism.getId(), this.overriddenTestAppUrl); this.testIdConfig = testingRunConfig.getId(); TestingRunConfigDao.instance.insertOne(testingRunConfig); } @@ -193,9 +188,12 @@ public String startTest() { Updates.set(TestingRun.SCHEDULE_TIMESTAMP,scheduleTimestamp) )); - TestingRunConfig testingRunConfig = new TestingRunConfig(Context.now(), null, this.selectedTests, null, this.overriddenTestAppUrl); - this.testIdConfig = testingRunConfig.getId(); - TestingRunConfigDao.instance.insertOne(testingRunConfig); + if (this.overriddenTestAppUrl != null || this.selectedTests != null) { + int id = UUID.randomUUID().hashCode(); + TestingRunConfig testingRunConfig = new TestingRunConfig(id, null, this.selectedTests, null, this.overriddenTestAppUrl); + this.testIdConfig = testingRunConfig.getId(); + TestingRunConfigDao.instance.insertOne(testingRunConfig); + } }