Skip to content

Commit 10abbf9

Browse files
committed
Added tests for only exclusion case
Signed-off-by: Tarun-kishore <[email protected]>
1 parent a1466c9 commit 10abbf9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/kotlin/org/opensearch/indexmanagement/indexstatemanagement/resthandler/ISMTemplateRestAPIIT.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,19 @@ class ISMTemplateRestAPIIT : IndexStateManagementRestTestCase() {
286286
assertEquals(expectedReason, actualMessage["reason"])
287287
}
288288
}
289+
290+
@Suppress("UNCHECKED_CAST")
291+
fun `test add template with only exclusion patterns`() {
292+
try {
293+
// Test exclusion pattern without any inclusion patterns
294+
val ismTemp = ISMTemplate(listOf("-log-test-*", "-log-debug-*"), 100, randomInstant())
295+
createPolicy(randomPolicy(ismTemplate = listOf(ismTemp)), "${testIndexName}_only_exclusion")
296+
fail("Expect a failure")
297+
} catch (e: ResponseException) {
298+
assertEquals("Unexpected RestStatus", RestStatus.BAD_REQUEST, e.response.restStatus())
299+
val actualMessage = e.response.asMap()["error"] as Map<String, Any>
300+
val expectedReason = "Validation Failed: 1: index_patterns must contain at least one inclusion pattern (patterns cannot be all exclusions);"
301+
assertEquals(expectedReason, actualMessage["reason"])
302+
}
303+
}
289304
}

0 commit comments

Comments
 (0)