From 63ed99ded64df28cba5e8909ef63bc502ed67a95 Mon Sep 17 00:00:00 2001 From: Surya Sashank Nistala Date: Tue, 8 Oct 2024 15:43:07 -0700 Subject: [PATCH] fix test Signed-off-by: Surya Sashank Nistala --- .../SecurityAnalyticsRestTestCase.java | 2 +- .../opensearch/securityanalytics/TestHelpers.java | 12 +++++++----- .../securityanalytics/resthandler/RuleRestApiIT.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java b/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java index 52fd0b512..394607163 100644 --- a/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java +++ b/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java @@ -1470,7 +1470,7 @@ protected void tryDeletingRole(String name) throws IOException { @Override protected boolean preserveIndicesUponCompletion() { - return true; + return false; } boolean preserveODFEIndicesAfterTest() { diff --git a/src/test/java/org/opensearch/securityanalytics/TestHelpers.java b/src/test/java/org/opensearch/securityanalytics/TestHelpers.java index a50ebb319..e250218a2 100644 --- a/src/test/java/org/opensearch/securityanalytics/TestHelpers.java +++ b/src/test/java/org/opensearch/securityanalytics/TestHelpers.java @@ -54,8 +54,10 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; +import static org.opensearch.test.OpenSearchTestCase.randomAlphaOfLength; import static org.opensearch.test.OpenSearchTestCase.randomInt; public class TestHelpers { @@ -259,7 +261,7 @@ public static CorrelationRule randomCorrelationRuleWithTrigger(String name) { public static String randomRule() { return "title: Remote Encrypting File System Abuse\n" + - "id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n" + + "id: " + UUID.randomUUID() + "\n" + "description: Detects remote RPC calls to possibly abuse remote encryption service via MS-EFSR\n" + "references:\n" + " - https://attack.mitre.org/tactics/TA0008/\n" + @@ -380,7 +382,7 @@ public static String randomRuleWithNotCondition() { public static String randomRuleWithCriticalSeverity() { return "title: Remote Encrypting File System Abuse\n" + - "id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n" + + "id: " + UUID.randomUUID() + "\n" + "description: Detects remote RPC calls to possibly abuse remote encryption service via MS-EFSR\n" + "references:\n" + " - https://attack.mitre.org/tactics/TA0008/\n" + @@ -471,7 +473,7 @@ public static String randomNullRule() { } public static String randomCloudtrailRuleForCorrelations(String value) { - return "id: 5f92fff9-82e2-48ab-8fc1-8b133556a551\n" + + return "id: " + UUID.randomUUID() + "\n" + "logsource:\n" + " product: cloudtrail\n" + "title: AWS User Created\n" + @@ -524,7 +526,7 @@ public static String randomRuleForMappingView(String field) { public static String randomRuleForCustomLogType() { return "title: Remote Encrypting File System Abuse\n" + - "id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n" + + "id: " + UUID.randomUUID() + "\n" + "description: Detects remote RPC calls to possibly abuse remote encryption service via MS-EFSR\n" + "references:\n" + " - https://attack.mitre.org/tactics/TA0008/\n" + @@ -1104,7 +1106,7 @@ public static String randomAggregationRule(String aggFunction, String signAndVal public static String randomAggregationRule(String aggFunction, String signAndValue, String opCode) { String rule = "title: Remote Encrypting File System Abuse\n" + - "id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n" + + "id: " + UUID.randomUUID() + "\n" + "description: Detects remote RPC calls to possibly abuse remote encryption service via MS-EFSR\n" + "references:\n" + " - https://attack.mitre.org/tactics/TA0008/\n" + diff --git a/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java index cad330e14..154232594 100644 --- a/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java @@ -796,7 +796,7 @@ public void testDeletingNonExistingCustomRule() throws IOException { public void testCustomRuleValidation() throws IOException { String rule1 = "title: Remote Encrypting File System Abuse\n" + - "id: 5f92fff9-82e2-48eb-8fc1-8b133556a551\n" + + "id: " + UUID.randomUUID() + "\n" + "description: Detects remote RPC calls to possibly abuse remote encryption service via MS-EFSR\n" + "references:\n" + " - https://attack.mitre.org/tactics/TA0008/\n" +