From c0de31a0e99bfc3ab8201706e4d8d74db8a0f4e6 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:36:29 -0700 Subject: [PATCH] pass integ tests (#1082) (#1084) Signed-off-by: Subhobrata Dey --- .../SecurityAnalyticsRestTestCase.java | 4 +- .../securityanalytics/alerts/AlertsIT.java | 10 ++-- .../alerts/SecureAlertsRestApiIT.java | 2 +- .../securityanalytics/findings/FindingIT.java | 16 +++---- .../findings/SecureFindingRestApiIT.java | 2 +- .../mapper/MapperRestApiIT.java | 48 +++++++++---------- 6 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java b/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java index d2216415d..59e4ba9f0 100644 --- a/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java +++ b/src/test/java/org/opensearch/securityanalytics/SecurityAnalyticsRestTestCase.java @@ -1579,8 +1579,8 @@ protected void createNetflowLogIndex(String indexName) throws IOException { Response response = client().performRequest(indexRequest); assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode()); // Refresh everything - response = client().performRequest(new Request("POST", "_refresh")); - assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + //response = client().performRequest(new Request("POST", "_refresh")); + //assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); } diff --git a/src/test/java/org/opensearch/securityanalytics/alerts/AlertsIT.java b/src/test/java/org/opensearch/securityanalytics/alerts/AlertsIT.java index f8de613da..77b54dbde 100644 --- a/src/test/java/org/opensearch/securityanalytics/alerts/AlertsIT.java +++ b/src/test/java/org/opensearch/securityanalytics/alerts/AlertsIT.java @@ -357,7 +357,7 @@ public void testAckAlerts_WithInvalidDetectorAlertsCombination() throws IOExcept indexDoc(index, "1", randomDoc()); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); Response executeResponse = null; @@ -565,7 +565,7 @@ public void testGetAlerts_byDetectorType_success() throws IOException, Interrupt indexDoc(index, "1", randomDoc()); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); Response executeResponse = executeAlertingMonitor(monitorId, Collections.emptyMap()); Map executeResults = entityAsMap(executeResponse); @@ -681,7 +681,7 @@ public void testGetAlerts_byDetectorType_multipleDetectors_success() throws IOEx noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(1, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); request = "{\n" + " \"query\" : {\n" + @@ -699,7 +699,7 @@ public void testGetAlerts_byDetectorType_multipleDetectors_success() throws IOEx hits = executeSearch(DetectorMonitorConfig.getAlertsIndex("network"), request); } - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Call GetAlerts API for WINDOWS detector Map params = new HashMap<>(); @@ -1080,7 +1080,7 @@ public void testAlertHistoryRollover_maxDocs() throws IOException, InterruptedEx indexDoc(index, "1", randomDoc()); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); Response executeResponse = executeAlertingMonitor(monitorId, Collections.emptyMap()); Map executeResults = entityAsMap(executeResponse); diff --git a/src/test/java/org/opensearch/securityanalytics/alerts/SecureAlertsRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/alerts/SecureAlertsRestApiIT.java index 28172037c..07e576f84 100644 --- a/src/test/java/org/opensearch/securityanalytics/alerts/SecureAlertsRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/alerts/SecureAlertsRestApiIT.java @@ -257,7 +257,7 @@ public void testGetAlerts_byDetectorType_success() throws IOException, Interrupt indexDoc(index, "1", randomDoc()); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); Response executeResponse = executeAlertingMonitor(monitorId, Collections.emptyMap()); Map executeResults = entityAsMap(executeResponse); diff --git a/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java b/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java index db282ec2c..90b008581 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/FindingIT.java @@ -265,7 +265,7 @@ public void testGetFindings_byDetectorType_success() throws IOException { noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(1, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Call GetFindings API for first detector Map params = new HashMap<>(); @@ -375,7 +375,7 @@ public void testGetAllFindings_success() throws IOException { noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); // Assert.assertEquals(1, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Call GetFindings API for all the detectors Map params = new HashMap<>(); @@ -594,7 +594,7 @@ public void testGetFindings_bySeverity_success() throws IOException { noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(1, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Call GetFindings API for first detector by severity Map params = new HashMap<>(); @@ -715,7 +715,7 @@ public void testGetFindings_bySearchString_success() throws IOException { noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(1, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Call GetFindings API for first detector by searchString 'high' Map params = new HashMap<>(); @@ -831,7 +831,7 @@ public void testGetFindings_byStartTimeAndEndTime_success() throws IOException { int noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(1, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Call GetFindings API for first detector by startTime and endTime Map params = new HashMap<>(); params.put("startTime", String.valueOf(startTime1.toEpochMilli())); @@ -842,7 +842,7 @@ public void testGetFindings_byStartTimeAndEndTime_success() throws IOException { Map getFindingsBody = entityAsMap(getFindingsResponse); Assert.assertEquals(1, getFindingsBody.get("total_findings")); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); Instant startTime2 = Instant.now(); // execute monitor 2 executeResponse = executeAlertingMonitor(monitorId2, Collections.emptyMap()); @@ -1343,7 +1343,7 @@ public void testGetFindings_rolloverByMaxDoc_short_retention_success() throws IO // Call GetFindings API Map params = new HashMap<>(); params.put("detector_id", detectorId); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); Response getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); Map getFindingsBody = entityAsMap(getFindingsResponse); Assert.assertEquals(1, getFindingsBody.get("total_findings")); @@ -1372,7 +1372,7 @@ public void testGetFindings_rolloverByMaxDoc_short_retention_success() throws IO noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(5, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); getFindingsResponse = makeRequest(client(), "GET", SecurityAnalyticsPlugin.FINDINGS_BASE_URI + "/_search", params, null); getFindingsBody = entityAsMap(getFindingsResponse); Assert.assertEquals(1, getFindingsBody.get("total_findings")); diff --git a/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java index c24b344bd..b5eb8ede2 100644 --- a/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/findings/SecureFindingRestApiIT.java @@ -263,7 +263,7 @@ public void testGetFindings_byDetectorType_success() throws IOException { noOfSigmaRuleMatches = ((List>) ((Map) executeResults.get("input_results")).get("results")).get(0).size(); Assert.assertEquals(5, noOfSigmaRuleMatches); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // try to do get finding as a user with read access diff --git a/src/test/java/org/opensearch/securityanalytics/mapper/MapperRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/mapper/MapperRestApiIT.java index 7389550c9..67eb3a313 100644 --- a/src/test/java/org/opensearch/securityanalytics/mapper/MapperRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/mapper/MapperRestApiIT.java @@ -722,7 +722,7 @@ public void testCreateMappings_withIndexPattern_differentMappings_indexTemplateC createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample docs String sampleDoc1 = "{" + @@ -737,7 +737,7 @@ public void testCreateMappings_withIndexPattern_differentMappings_indexTemplateC indexDoc(indexName1, "1", sampleDoc1); indexDoc(indexName2, "1", sampleDoc2); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Execute CreateMappingsAction to add alias mapping for index createMappingsAPI(indexPattern, "netflow"); @@ -800,7 +800,7 @@ public void testCreateMappings_withIndexPattern_indexTemplate_createAndUpdate_su createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample doc String sampleDoc1 = "{" + @@ -811,7 +811,7 @@ public void testCreateMappings_withIndexPattern_indexTemplate_createAndUpdate_su indexDoc(indexName1, "1", sampleDoc1); indexDoc(indexName2, "1", sampleDoc1); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Execute CreateMappingsAction to add alias mapping for index createMappingsAPI(indexPattern, "netflow"); @@ -887,7 +887,7 @@ public void testCreateMappings_withIndexPattern_oneNoMappings_failure() throws I createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample docs String sampleDoc1 = "{" + @@ -897,7 +897,7 @@ public void testCreateMappings_withIndexPattern_oneNoMappings_failure() throws I "}"; indexDoc(indexName1, "1", sampleDoc1); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Execute CreateMappingsAction to add alias mapping for index try { @@ -1111,7 +1111,7 @@ public void testCreateMappings_withIndexPattern_success() throws IOException { createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample doc String sampleDoc = "{" + @@ -1124,7 +1124,7 @@ public void testCreateMappings_withIndexPattern_success() throws IOException { indexDoc(indexName1, "1", sampleDoc); indexDoc(indexName2, "1", sampleDoc); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Execute CreateMappingsAction to add alias mapping for index Request request = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); @@ -1150,7 +1150,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_success() t createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample doc String sampleDoc = "{" + @@ -1161,7 +1161,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_success() t indexDoc(indexName1, "1", sampleDoc); indexDoc(indexName2, "1", sampleDoc); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Execute CreateMappingsAction with first index pattern createMappingsAPI(indexPattern1, "netflow"); @@ -1205,7 +1205,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_1() createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample doc String sampleDoc = "{" + @@ -1216,7 +1216,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_1() indexDoc(indexName1, "1", sampleDoc); indexDoc(indexName2, "1", sampleDoc); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Execute CreateMappingsAction with first index pattern createMappingsAPI(indexPattern1, "netflow"); @@ -1244,7 +1244,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_2() createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample doc String sampleDoc = "{" + @@ -1255,7 +1255,7 @@ public void testCreateMappings_withIndexPattern_conflictingTemplates_failure_2() indexDoc(indexName1, "1", sampleDoc); indexDoc(indexName2, "1", sampleDoc); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // User-create template with conflicting pattern but higher priority @@ -1279,7 +1279,7 @@ public void testCreateMappings_withIndexPattern_oneNoMatches_success() throws IO createIndex(indexName1, Settings.EMPTY, null); createIndex(indexName2, Settings.EMPTY, null); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Insert sample docs String sampleDoc1 = "{" + @@ -1294,7 +1294,7 @@ public void testCreateMappings_withIndexPattern_oneNoMatches_success() throws IO indexDoc(indexName1, "1", sampleDoc1); indexDoc(indexName2, "1", sampleDoc2); - client().performRequest(new Request("POST", "_refresh")); + // client().performRequest(new Request("POST", "_refresh")); // Execute CreateMappingsAction to add alias mapping for index Request request = new Request("POST", SecurityAnalyticsPlugin.MAPPER_BASE_URI); @@ -1381,8 +1381,8 @@ private void createSampleIndex(String indexName, Settings settings, String alias Response response = client().performRequest(indexRequest); assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode()); // Refresh everything - response = client().performRequest(new Request("POST", "_refresh")); - assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + //response = client().performRequest(new Request("POST", "_refresh")); + //assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); } private void createSampleWindex(String indexName) throws IOException { @@ -1444,8 +1444,8 @@ private void createSampleWindex(String indexName, Settings settings, String alia Response response = client().performRequest(indexRequest); assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode()); // Refresh everything - response = client().performRequest(new Request("POST", "_refresh")); - assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + //response = client().performRequest(new Request("POST", "_refresh")); + //assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); } private void createSampleDatastream(String datastreamName) throws IOException { @@ -1533,8 +1533,8 @@ private void createSampleDatastream(String datastreamName) throws IOException { response = client().performRequest(indexRequest); assertEquals(HttpStatus.SC_CREATED, response.getStatusLine().getStatusCode()); // Refresh everything - response = client().performRequest(new Request("POST", "_refresh")); - assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + //response = client().performRequest(new Request("POST", "_refresh")); + //assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); } private void deleteDatastream(String datastreamName) throws IOException { @@ -1613,8 +1613,8 @@ public void testCreateDNSMapping() throws IOException{ }); // Refresh everything - response = client().performRequest(new Request("POST", "_refresh")); - assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); + //response = client().performRequest(new Request("POST", "_refresh")); + //assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode()); }