Skip to content

Commit

Permalink
Add expected error messages in integ tests
Browse files Browse the repository at this point in the history
Signed-off-by: Megha Goyal <[email protected]>
  • Loading branch information
goyamegh committed Feb 19, 2024
1 parent b945e64 commit 17f2f68
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 17f2f68

Please sign in to comment.