From 17f2f6843bdef6bbb72ec0dde70e922f83a0dd2e Mon Sep 17 00:00:00 2001 From: Megha Goyal Date: Sun, 18 Feb 2024 23:26:27 -0800 Subject: [PATCH] Add expected error messages in integ tests Signed-off-by: Megha Goyal --- .../securityanalytics/resthandler/RuleRestApiIT.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java b/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java index 5c834c245..55301d37c 100644 --- a/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java +++ b/src/test/java/org/opensearch/securityanalytics/resthandler/RuleRestApiIT.java @@ -106,11 +106,15 @@ public void testCreatingARule() throws IOException { public void testCreatingARule_withExceptions() throws IOException { String rule = randomRuleWithCxErrors(); - - assertThrows(ResponseException.class, () -> { + try { makeRequest(client(), "POST", SecurityAnalyticsPlugin.RULE_BASE_URI, Collections.singletonMap("category", randomDetectorType()), new StringEntity(rule), new BasicHeader("Content-Type", "application/json")); - }); + } catch (ResponseException e) { + assertEquals(HttpStatus.SC_BAD_REQUEST, e.getResponse().getStatusLine().getStatusCode()); + Assert.assertTrue(e.getMessage().contains("Sigma rule identifier must be an UUID")); + Assert.assertTrue(e.getMessage().contains("Value of status not correct")); + Assert.assertTrue(e.getMessage().contains("Value of level not correct")); + } } public void testCreatingARule_custom_category() throws IOException {