From 3fe48a93fde13d86c59f488c6e406c4cea207684 Mon Sep 17 00:00:00 2001 From: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> Date: Fri, 16 Dec 2022 16:29:12 -0800 Subject: [PATCH 1/5] Add refresh to config creation in tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> --- .../integtest/PluginRestTestCase.kt | 1 + .../config/DeleteNotificationConfigIT.kt | 27 +++++++------- .../config/QueryNotificationConfigIT.kt | 35 ++++++++++--------- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt index c7651a0d..851d3859 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt @@ -287,6 +287,7 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { RestStatus.OK.status, client ) + refreshAllIndices() val configId = createResponse.get("config_id").asString Assert.assertNotNull(configId) Thread.sleep(100) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt index d42a5f9f..3d6f9d3f 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt @@ -36,19 +36,20 @@ class DeleteNotificationConfigIT : PluginRestTestCase() { """.trimIndent() } - private fun createConfig(): String { - val createRequestJsonString = getCreateRequestJsonString() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString - Assert.assertNotNull(configId) - Thread.sleep(100) - return configId - } +// private fun createConfig(): String { +// val createRequestJsonString = getCreateRequestJsonString() +// val createResponse = executeRequest( +// RestRequest.Method.POST.name, +// "$PLUGIN_BASE_URI/configs", +// createRequestJsonString, +// RestStatus.OK.status +// ) +// refreshAllIndices() +// val configId = createResponse.get("config_id").asString +// Assert.assertNotNull(configId) +// Thread.sleep(100) +// return configId +// } fun `test Delete single notification config`() { val configId = createConfig() diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt index a7937f88..013edc2e 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt @@ -74,23 +74,24 @@ class QueryNotificationConfigIT : PluginRestTestCase() { """.trimIndent() } - private fun createConfig( - nameSubstring: String = "", - configType: ConfigType = ConfigType.SLACK, - isEnabled: Boolean = true - ): String { - val createRequestJsonString = getCreateRequestJsonString(nameSubstring, configType, isEnabled) - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString - Assert.assertNotNull(configId) - Thread.sleep(100) - return configId - } +// private fun createConfig( +// nameSubstring: String = "", +// configType: ConfigType = ConfigType.SLACK, +// isEnabled: Boolean = true +// ): String { +// val createRequestJsonString = getCreateRequestJsonString(nameSubstring, configType, isEnabled) +// val createResponse = executeRequest( +// RestRequest.Method.POST.name, +// "$PLUGIN_BASE_URI/configs", +// createRequestJsonString, +// RestStatus.OK.status +// ) +// refreshAllIndices() +// val configId = createResponse.get("config_id").asString +// Assert.assertNotNull(configId) +// Thread.sleep(100) +// return configId +// } fun `test Get single notification config as part of path`() { val configId = createConfig() From 68ef04beebd15ce358c608aafe743f4e8714d8d3 Mon Sep 17 00:00:00 2001 From: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> Date: Fri, 16 Dec 2022 16:50:54 -0800 Subject: [PATCH 2/5] Remove duplicate createConfig utility methods for tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> --- .../config/DeleteNotificationConfigIT.kt | 35 --------- .../config/QueryNotificationConfigIT.kt | 71 ------------------- 2 files changed, 106 deletions(-) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt index 3d6f9d3f..5d862d07 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt @@ -12,45 +12,10 @@ import org.opensearch.notifications.verifyMultiConfigIdEquals import org.opensearch.notifications.verifySingleConfigIdEquals import org.opensearch.rest.RestRequest import org.opensearch.rest.RestStatus -import kotlin.random.Random class DeleteNotificationConfigIT : PluginRestTestCase() { private val charPool: List = ('a'..'z') + ('A'..'Z') + ('0'..'9') - private fun getCreateRequestJsonString(): String { - val randomString = (1..20) - .map { Random.nextInt(0, charPool.size) } - .map(charPool::get) - .joinToString("") - return """ - { - "config_id":"$randomString", - "config":{ - "name":"this is a sample config name $randomString", - "description":"this is a sample config description $randomString", - "config_type":"slack", - "is_enabled":true, - "slack":{"url":"https://domain.com/sample_slack_url#$randomString"} - } - } - """.trimIndent() - } - -// private fun createConfig(): String { -// val createRequestJsonString = getCreateRequestJsonString() -// val createResponse = executeRequest( -// RestRequest.Method.POST.name, -// "$PLUGIN_BASE_URI/configs", -// createRequestJsonString, -// RestStatus.OK.status -// ) -// refreshAllIndices() -// val configId = createResponse.get("config_id").asString -// Assert.assertNotNull(configId) -// Thread.sleep(100) -// return configId -// } - fun `test Delete single notification config`() { val configId = createConfig() Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt index 013edc2e..b854979a 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt @@ -18,81 +18,10 @@ import org.opensearch.notifications.verifySingleConfigIdEquals import org.opensearch.rest.RestRequest import org.opensearch.rest.RestStatus import java.time.Instant -import kotlin.random.Random class QueryNotificationConfigIT : PluginRestTestCase() { private val charPool: List = ('a'..'z') + ('A'..'Z') + ('0'..'9') - private fun getCreateRequestJsonString( - nameSubstring: String, - configType: ConfigType, - isEnabled: Boolean - ): String { - val randomString = (1..20) - .map { Random.nextInt(0, charPool.size) } - .map(charPool::get) - .joinToString("") - val configObjectString = when (configType) { - ConfigType.SLACK -> """ - "slack":{"url":"https://slack.domain.com/sample_slack_url#$randomString"} - """.trimIndent() - ConfigType.CHIME -> """ - "chime":{"url":"https://chime.domain.com/sample_chime_url#$randomString"} - """.trimIndent() - ConfigType.WEBHOOK -> """ - "webhook":{"url":"https://web.domain.com/sample_web_url#$randomString"} - """.trimIndent() - ConfigType.SMTP_ACCOUNT -> """ - "smtp_account":{ - "host":"smtp.domain.com", - "port":"4321", - "method":"ssl", - "from_address":"$randomString@from.com" - } - """.trimIndent() - ConfigType.EMAIL_GROUP -> """ - "email_group":{ - "recipient_list":[ - {"recipient":"$randomString+recipient1@from.com"}, - {"recipient":"$randomString+recipient2@from.com"} - ] - } - """.trimIndent() - else -> throw IllegalArgumentException("Unsupported configType=$configType") - } - return """ - { - "config_id":"$randomString", - "config":{ - "name":"$nameSubstring:this is a sample config name $randomString", - "description":"this is a sample config description $randomString", - "config_type":"$configType", - "is_enabled":$isEnabled, - $configObjectString - } - } - """.trimIndent() - } - -// private fun createConfig( -// nameSubstring: String = "", -// configType: ConfigType = ConfigType.SLACK, -// isEnabled: Boolean = true -// ): String { -// val createRequestJsonString = getCreateRequestJsonString(nameSubstring, configType, isEnabled) -// val createResponse = executeRequest( -// RestRequest.Method.POST.name, -// "$PLUGIN_BASE_URI/configs", -// createRequestJsonString, -// RestStatus.OK.status -// ) -// refreshAllIndices() -// val configId = createResponse.get("config_id").asString -// Assert.assertNotNull(configId) -// Thread.sleep(100) -// return configId -// } - fun `test Get single notification config as part of path`() { val configId = createConfig() Thread.sleep(1000) From fe14159298eab697ca41d45bb225f32fe88ee3e1 Mon Sep 17 00:00:00 2001 From: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> Date: Thu, 5 Jan 2023 12:59:34 -0800 Subject: [PATCH 3/5] Replace delete config calls in tests with helper method with indices refresh Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> --- .../integtest/PluginRestTestCase.kt | 30 +++++++++++++++++++ .../integtest/SecurityNotificationIT.kt | 8 +---- .../config/ChimeNotificationConfigCrudIT.kt | 7 +---- .../config/DeleteNotificationConfigIT.kt | 21 ++----------- .../config/EmailNotificationConfigCrudIT.kt | 14 ++------- .../config/SlackNotificationConfigCrudIT.kt | 7 +---- .../config/SnsNotificationConfigCrudIT.kt | 7 +---- .../config/WebhookNotificationConfigCrudIT.kt | 7 +---- 8 files changed, 40 insertions(+), 61 deletions(-) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt index 851d3859..5796b895 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt @@ -294,6 +294,36 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { return configId } + fun deleteConfig( + configId: String, + client: RestClient = client() + ): JsonObject { + val deleteResponse = executeRequest( + RestRequest.Method.DELETE.name, + "${NotificationPlugin.PLUGIN_BASE_URI}/configs/$configId", + "", + RestStatus.OK.status, + client + ) + refreshAllIndices() + return deleteResponse + } + + fun deleteConfigs( + configIds: Set, + client: RestClient = client() + ): JsonObject { + val deleteResponse = executeRequest( + RestRequest.Method.DELETE.name, + "${NotificationPlugin.PLUGIN_BASE_URI}/configs?config_id_list=${configIds.joinToString(separator = ",")}", + "", + RestStatus.OK.status, + client + ) + refreshAllIndices() + return deleteResponse + } + @After open fun wipeAllSettings() { wipeAllClusterSettings() diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt index 47ab2b5e..89423d09 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt @@ -351,13 +351,7 @@ class SecurityNotificationIT : PluginRestTestCase() { Thread.sleep(1000) // Delete Slack notification config - executeRequest( - RestRequest.Method.DELETE.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs/$configId", - "", - RestStatus.OK.status, - userClient!! - ) + deleteConfig(configId, userClient!!) // Should not be able to find config executeRequest( diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt index 6fac691b..3eb6258c 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt @@ -114,12 +114,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { Thread.sleep(100) // Delete chime notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs/$configId", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfig(configId) Assert.assertEquals("OK", deleteResponse.get("delete_response_list").asJsonObject.get(configId).asString) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt index 5d862d07..12d84ef4 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/DeleteNotificationConfigIT.kt @@ -31,12 +31,7 @@ class DeleteNotificationConfigIT : PluginRestTestCase() { Thread.sleep(100) // Delete notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs/$configId", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfig(configId) Assert.assertEquals("OK", deleteResponse.get("delete_response_list").asJsonObject.get(configId).asString) Thread.sleep(100) @@ -88,12 +83,7 @@ class DeleteNotificationConfigIT : PluginRestTestCase() { Thread.sleep(100) // Delete notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs?config_id_list=${configIds.joinToString(separator = ",")}", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfigs(configIds) val deletedObject = deleteResponse.get("delete_response_list").asJsonObject configIds.forEach { Assert.assertEquals("OK", deletedObject.get(it).asString) @@ -169,12 +159,7 @@ class DeleteNotificationConfigIT : PluginRestTestCase() { val remainingIds = partitions.second.toSet() // Delete notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs?config_id_list=${deletedIds.joinToString(separator = ",")}", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfigs(deletedIds) val deletedObject = deleteResponse.get("delete_response_list").asJsonObject deletedIds.forEach { Assert.assertEquals("OK", deletedObject.get(it).asString) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt index bae9c455..27161c09 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt @@ -268,12 +268,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { Thread.sleep(100) // Delete email notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs/$emailConfigId", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfig(emailConfigId) Assert.assertEquals("OK", deleteResponse.get("delete_response_list").asJsonObject.get(emailConfigId).asString) Thread.sleep(1000) @@ -527,12 +522,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { Thread.sleep(100) // Delete email notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs/$emailConfigId", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfig(emailConfigId) Assert.assertEquals("OK", deleteResponse.get("delete_response_list").asJsonObject.get(emailConfigId).asString) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt index fb645e81..15665dbd 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt @@ -115,12 +115,7 @@ class SlackNotificationConfigCrudIT : PluginRestTestCase() { Thread.sleep(100) // Delete slack notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs/$configId", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfig(configId) Assert.assertEquals("OK", deleteResponse.get("delete_response_list").asJsonObject.get(configId).asString) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt index 33138f67..51a6da78 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt @@ -115,12 +115,7 @@ class SnsNotificationConfigCrudIT : PluginRestTestCase() { Thread.sleep(100) // Delete SNS notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs/$configId", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfig(configId) Assert.assertEquals("OK", deleteResponse.get("delete_response_list").asJsonObject.get(configId).asString) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt index 9203d788..06fac168 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt @@ -131,12 +131,7 @@ class WebhookNotificationConfigCrudIT : PluginRestTestCase() { Thread.sleep(100) // Delete webhook notification config - val deleteResponse = executeRequest( - RestRequest.Method.DELETE.name, - "$PLUGIN_BASE_URI/configs/$configId", - "", - RestStatus.OK.status - ) + val deleteResponse = deleteConfig(configId) Assert.assertEquals("OK", deleteResponse.get("delete_response_list").asJsonObject.get(configId).asString) Thread.sleep(1000) From 4d5f930debba0b2a4125dc122e4fb1871db9341b Mon Sep 17 00:00:00 2001 From: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> Date: Thu, 5 Jan 2023 15:31:25 -0800 Subject: [PATCH 4/5] Replace creating config from JSON string calls with helper method that refreshes indices Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> --- .../integtest/PluginRestTestCase.kt | 16 +++ .../integtest/SecurityNotificationIT.kt | 57 ++-------- .../NotificationsBackwardsCompatibilityIT.kt | 8 +- .../config/ChimeNotificationConfigCrudIT.kt | 24 +--- .../config/CreateNotificationConfigIT.kt | 17 +-- .../config/EmailNotificationConfigCrudIT.kt | 104 +++--------------- .../config/QueryNotificationConfigIT.kt | 9 +- .../config/SlackNotificationConfigCrudIT.kt | 8 +- .../config/SnsNotificationConfigCrudIT.kt | 8 +- .../config/WebhookNotificationConfigCrudIT.kt | 8 +- .../send/SendTestMessageRestHandlerIT.kt | 40 +------ 11 files changed, 53 insertions(+), 246 deletions(-) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt index 5796b895..9ecdb35c 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/PluginRestTestCase.kt @@ -294,6 +294,22 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() { return configId } + fun createConfigWithRequestJsonString( + createRequestJsonString: String, + client: RestClient = client() + ): String { + val createResponse = executeRequest( + RestRequest.Method.POST.name, + "${NotificationPlugin.PLUGIN_BASE_URI}/configs", + createRequestJsonString, + RestStatus.OK.status, + client + ) + refreshAllIndices() + Thread.sleep(100) + return createResponse.get("config_id").asString + } + fun deleteConfig( configId: String, client: RestClient = client() diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt index 89423d09..677c5963 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt @@ -74,14 +74,7 @@ class SecurityNotificationIT : PluginRestTestCase() { } """.trimIndent() try { - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - createRequestJsonString, - RestStatus.OK.status, - userClient!! - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString, userClient!!) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -159,13 +152,7 @@ class SecurityNotificationIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -243,13 +230,7 @@ class SecurityNotificationIT : PluginRestTestCase() { } """.trimIndent() - executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - createRequestJsonString, - RestStatus.FORBIDDEN.status, - userClient!! - ) + createConfigWithRequestJsonString(createRequestJsonString, userClient!!) deleteUserWithCustomRole(user, NOTIFICATION_NO_ACCESS_ROLE) } @@ -278,13 +259,7 @@ class SecurityNotificationIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -340,13 +315,7 @@ class SecurityNotificationIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -471,13 +440,7 @@ class SecurityNotificationIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -515,13 +478,7 @@ class SecurityNotificationIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/bwc/NotificationsBackwardsCompatibilityIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/bwc/NotificationsBackwardsCompatibilityIT.kt index f1976c93..76f0e183 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/bwc/NotificationsBackwardsCompatibilityIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/bwc/NotificationsBackwardsCompatibilityIT.kt @@ -104,13 +104,7 @@ class NotificationsBackwardsCompatibilityIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "${NotificationPlugin.PLUGIN_BASE_URI}/configs", - requestJsonString, - RestStatus.OK.status - ) - val createdConfigId = createResponse.get("config_id").asString + val createdConfigId = createConfigWithRequestJsonString(requestJsonString) assertNotNull(createdConfigId) Thread.sleep(100) } diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt index 3eb6258c..f708a6d2 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/ChimeNotificationConfigCrudIT.kt @@ -39,13 +39,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -184,13 +178,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -278,13 +266,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/CreateNotificationConfigIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/CreateNotificationConfigIT.kt index a8fe39fc..2d86dfe6 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/CreateNotificationConfigIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/CreateNotificationConfigIT.kt @@ -44,13 +44,7 @@ class CreateNotificationConfigIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -90,13 +84,8 @@ class CreateNotificationConfigIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - Assert.assertEquals(configId, createResponse.get("config_id").asString) + val createdConfigId = createConfigWithRequestJsonString(createRequestJsonString) + Assert.assertEquals(configId, createdConfigId) Thread.sleep(1000) // Get chime notification config diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt index 27161c09..fb9b7912 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/EmailNotificationConfigCrudIT.kt @@ -58,13 +58,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createSmtpAccountResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createSmtpAccountRequestJsonString, - RestStatus.OK.status - ) - val smtpAccountConfigId = createSmtpAccountResponse.get("config_id").asString + val smtpAccountConfigId = createConfigWithRequestJsonString(createSmtpAccountRequestJsonString) Assert.assertNotNull(smtpAccountConfigId) Thread.sleep(100) @@ -95,13 +89,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createEmailGroupResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createEmailGroupRequestJsonString, - RestStatus.OK.status - ) - val emailGroupConfigId = createEmailGroupResponse.get("config_id").asString + val emailGroupConfigId = createConfigWithRequestJsonString(createEmailGroupRequestJsonString) Assert.assertNotNull(emailGroupConfigId) Thread.sleep(100) @@ -140,13 +128,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createEmailResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createEmailRequestJsonString, - RestStatus.OK.status - ) - val emailConfigId = createEmailResponse.get("config_id").asString + val emailConfigId = createConfigWithRequestJsonString(createEmailRequestJsonString) Assert.assertNotNull(emailConfigId) Thread.sleep(1000) @@ -314,13 +296,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createSesAccountResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createSesAccountRequestJsonString, - RestStatus.OK.status - ) - val sesAccountConfigId = createSesAccountResponse.get("config_id").asString + val sesAccountConfigId = createConfigWithRequestJsonString(createSesAccountRequestJsonString) Assert.assertNotNull(sesAccountConfigId) Thread.sleep(100) @@ -351,13 +327,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createEmailGroupResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createEmailGroupRequestJsonString, - RestStatus.OK.status - ) - val emailGroupConfigId = createEmailGroupResponse.get("config_id").asString + val emailGroupConfigId = createConfigWithRequestJsonString(createEmailGroupRequestJsonString) Assert.assertNotNull(emailGroupConfigId) Thread.sleep(100) @@ -396,13 +366,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createEmailResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createEmailRequestJsonString, - RestStatus.OK.status - ) - val emailConfigId = createEmailResponse.get("config_id").asString + val emailConfigId = createConfigWithRequestJsonString(createEmailRequestJsonString) Assert.assertNotNull(emailConfigId) Thread.sleep(1000) @@ -555,13 +519,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createSmtpAccountResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createSmtpAccountRequestJsonString, - RestStatus.OK.status - ) - val smtpAccountConfigId = createSmtpAccountResponse.get("config_id").asString + val smtpAccountConfigId = createConfigWithRequestJsonString(createSmtpAccountRequestJsonString) Assert.assertNotNull(smtpAccountConfigId) Thread.sleep(100) @@ -598,13 +556,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createEmailResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createEmailRequestJsonString, - RestStatus.OK.status - ) - val emailConfigId = createEmailResponse.get("config_id").asString + val emailConfigId = createConfigWithRequestJsonString(createEmailRequestJsonString) Assert.assertNotNull(emailConfigId) Thread.sleep(1000) @@ -704,13 +656,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createSmtpAccountResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createSmtpAccountRequestJsonString, - RestStatus.OK.status - ) - val smtpAccountConfigId = createSmtpAccountResponse.get("config_id").asString + val smtpAccountConfigId = createConfigWithRequestJsonString(createSmtpAccountRequestJsonString) Assert.assertNotNull(smtpAccountConfigId) Thread.sleep(100) @@ -784,13 +730,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createEmailGroupResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createEmailGroupRequestJsonString, - RestStatus.OK.status - ) - val emailGroupConfigId = createEmailGroupResponse.get("config_id").asString + val emailGroupConfigId = createConfigWithRequestJsonString(createEmailGroupRequestJsonString) Assert.assertNotNull(emailGroupConfigId) Thread.sleep(100) @@ -847,13 +787,7 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createSmtpAccountResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createSmtpAccountRequestJsonString, - RestStatus.OK.status - ) - val smtpAccountConfigId = createSmtpAccountResponse.get("config_id").asString + val smtpAccountConfigId = createConfigWithRequestJsonString(createSmtpAccountRequestJsonString) Assert.assertNotNull(smtpAccountConfigId) Thread.sleep(100) val createEmailRequestJsonString = """ @@ -908,24 +842,12 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createSmtpAccountResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createSmtpAccountRequestJsonString, - RestStatus.OK.status - ) - val smtpAccountConfigId = createSmtpAccountResponse.get("config_id").asString + val smtpAccountConfigId = createConfigWithRequestJsonString(createSmtpAccountRequestJsonString) Assert.assertNotNull(smtpAccountConfigId) Thread.sleep(100) // Create another smtp account - val anotherAccountResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createSmtpAccountRequestJsonString, - RestStatus.OK.status - ) - val anotherAccountConfigId = anotherAccountResponse.get("config_id").asString + val anotherAccountConfigId = createConfigWithRequestJsonString(createSmtpAccountRequestJsonString) Assert.assertNotNull(anotherAccountConfigId) Thread.sleep(100) val createEmailRequestJsonString = """ diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt index b854979a..e15bc1b2 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/QueryNotificationConfigIT.kt @@ -787,13 +787,8 @@ class QueryNotificationConfigIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - Assert.assertEquals(absentId, createResponse.get("config_id").asString) + val createdConfigId = createConfigWithRequestJsonString(createRequestJsonString) + Assert.assertEquals(absentId, createdConfigId) Thread.sleep(1000) // Get chime notification config diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt index 15665dbd..9fbcdfbb 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SlackNotificationConfigCrudIT.kt @@ -40,13 +40,7 @@ class SlackNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt index 51a6da78..2300dbcf 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/SnsNotificationConfigCrudIT.kt @@ -40,13 +40,7 @@ class SnsNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt index 06fac168..939a1647 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/WebhookNotificationConfigCrudIT.kt @@ -48,13 +48,7 @@ class WebhookNotificationConfigCrudIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageRestHandlerIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageRestHandlerIT.kt index 5545c6c3..bcbde29f 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageRestHandlerIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageRestHandlerIT.kt @@ -30,13 +30,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -69,13 +63,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -111,13 +99,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - createRequestJsonString, - RestStatus.OK.status - ) - val configId = createResponse.get("config_id").asString + val configId = createConfigWithRequestJsonString(createRequestJsonString) Assert.assertNotNull(configId) Thread.sleep(1000) @@ -159,13 +141,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { } } """.trimIndent() - val createResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - smtpAccountCreateRequestJsonString, - RestStatus.OK.status - ) - val smtpAccountConfigId = createResponse.get("config_id").asString + val smtpAccountConfigId = createConfigWithRequestJsonString(smtpAccountCreateRequestJsonString) Assert.assertNotNull(smtpAccountConfigId) Thread.sleep(1000) @@ -187,13 +163,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { } """.trimIndent() - val emailCreateResponse = executeRequest( - RestRequest.Method.POST.name, - "$PLUGIN_BASE_URI/configs", - emailCreateRequestJsonString, - RestStatus.OK.status - ) - val emailConfigId = emailCreateResponse.get("config_id").asString + val emailConfigId = createConfigWithRequestJsonString(emailCreateRequestJsonString) Assert.assertNotNull(emailConfigId) Thread.sleep(1000) From 6c81a4c34cb76be0602b88700f4b281c6ceb62dc Mon Sep 17 00:00:00 2001 From: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> Date: Fri, 6 Jan 2023 09:40:54 -0800 Subject: [PATCH 5/5] Update security test back to correct request with expected response assertion Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> --- .../org/opensearch/integtest/SecurityNotificationIT.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt index 677c5963..ecda9fc3 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt @@ -230,7 +230,13 @@ class SecurityNotificationIT : PluginRestTestCase() { } """.trimIndent() - createConfigWithRequestJsonString(createRequestJsonString, userClient!!) + executeRequest( + RestRequest.Method.POST.name, + "${NotificationPlugin.PLUGIN_BASE_URI}/configs", + createRequestJsonString, + RestStatus.FORBIDDEN.status, + userClient!! + ) deleteUserWithCustomRole(user, NOTIFICATION_NO_ACCESS_ROLE) }