Skip to content

Commit bb591fe

Browse files
committed
enhance test to verify non null doc doesnt match null query
Signed-off-by: Surya Sashank Nistala <[email protected]>
1 parent 26aa316 commit bb591fe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/test/java/org/opensearch/securityanalytics/DetectorThreatIntelIT.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ public void testCreateDetectorForSigmaRuleWithNullCondition() throws IOException
215215
String workflowId = ((List<String>) detectorMap.get("workflow_ids")).get(0);
216216

217217
indexDoc(index, "1", randomDocWithNullField());
218+
indexDoc(index, "2", randomDoc());
218219

219220
Response executeResponse = executeAlertingWorkflow(workflowId, Collections.emptyMap());
220221

@@ -227,6 +228,17 @@ public void testCreateDetectorForSigmaRuleWithNullCondition() throws IOException
227228
String queryId = docLevelQueryResults.keySet().stream().findAny().get();
228229
ArrayList<String> docs = (ArrayList<String>) docLevelQueryResults.get(queryId);
229230
assertEquals(docs.size(), 1);
231+
232+
indexDoc(index, "3", randomDoc());
233+
Response executeResponse1 = executeAlertingWorkflow(workflowId, Collections.emptyMap());
234+
235+
List<Map<String, Object>> monitorRunResults1 = (List<Map<String, Object>>) entityAsMap(executeResponse1).get("monitor_run_results");
236+
assertEquals(1, monitorRunResults1.size());
237+
238+
Map<String, Object> docLevelQueryResults1 = ((List<Map<String, Object>>) ((Map<String, Object>) monitorRunResults1.get(0).get("input_results")).get("results")).get(0);
239+
int noOfSigmaRuleMatches1 = docLevelQueryResults1.size();
240+
assertEquals(0, noOfSigmaRuleMatches1);
241+
230242
}
231243

232244
public void testCreateDetectorWithThreatIntelDisabled_updateDetectorWithThreatIntelEnabled() throws IOException {

0 commit comments

Comments
 (0)