From 1a7bcfaa6eb47de9710287d42d62b865bfbf494d Mon Sep 17 00:00:00 2001 From: Aniruddh Srivastava Date: Mon, 20 Nov 2023 01:30:35 -0500 Subject: [PATCH] Update tests for new Chime webhook regex. Signed-off-by: Aniruddh Srivastava --- .../org/opensearch/integtest/IntegTestHelpers.kt | 2 +- .../config/ChimeNotificationConfigCrudIT.kt | 12 ++++++------ .../integtest/config/CreateNotificationConfigIT.kt | 2 +- .../config/MicrosoftTeamsNotificationConfigCrudIT.kt | 2 +- .../integtest/config/QueryNotificationConfigIT.kt | 6 +++--- .../config/SlackNotificationConfigCrudIT.kt | 2 +- .../integtest/config/SnsNotificationConfigCrudIT.kt | 2 +- .../integtest/send/SendTestMessageRestHandlerIT.kt | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/IntegTestHelpers.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/IntegTestHelpers.kt index da8e44ed..b942d401 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/IntegTestHelpers.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/IntegTestHelpers.kt @@ -119,7 +119,7 @@ fun getCreateNotificationRequestJsonString( "slack":{"url":"https://hooks.slack.com/services/sample_slack_url#$randomString"} """.trimIndent() ConfigType.CHIME -> """ - "chime":{"url":"https://chime.domain.com/sample_chime_url#$randomString"} + "chime":{"url":"https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=$randomString"} """.trimIndent() ConfigType.MICROSOFT_TEAMS -> """ "microsoft_teams":{"url":"https://microsoftTeams.domain.webhook.office.com/sample_microsoft_teams_url#$randomString"} 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 744429ef..b12e364e 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 @@ -18,7 +18,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { fun `test Create, Get, Update, Delete chime notification config using REST client`() { // Create sample config request reference - val sampleChime = Chime("https://domain.com/sample_chime_url#1234567890") + val sampleChime = Chime("https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456") val referenceObject = NotificationConfig( "this is a sample config name", "this is a sample config description", @@ -66,7 +66,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { Thread.sleep(100) // Updated notification config object - val updatedChime = Chime("https://updated.domain.com/updated_chime_url#0987654321") + val updatedChime = Chime("https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=654321") val updatedObject = NotificationConfig( "this is a updated config name", "this is a updated config description", @@ -125,7 +125,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { fun `test BAD Request for multiple config data for Chime using REST Client`() { // Create sample config request reference - val sampleChime = Chime("https://domain.com/sample_chime_url#1234567890") + val sampleChime = Chime("https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456") val referenceObject = NotificationConfig( "this is a sample config name", "this is a sample config description", @@ -157,7 +157,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { fun `test update existing config to different config type`() { // Create sample config request reference - val sampleChime = Chime("https://domain.com/sample_chime_url#1234567890") + val sampleChime = Chime("https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456") val referenceObject = NotificationConfig( "this is a sample config name", "this is a sample config description", @@ -245,7 +245,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { fun `test update Chime webhook URL`() { // Create sample config request reference - val sampleChime = Chime("https://domain.com/sample_chime_url#1234567890") + val sampleChime = Chime("https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456") val referenceObject = NotificationConfig( "this is a sample config name", "this is a sample config description", @@ -278,7 +278,7 @@ class ChimeNotificationConfigCrudIT : PluginRestTestCase() { "description":"this is a updated config description", "config_type":"chime", "is_enabled":"true", - "chime":{"url":"https://updated.domain.com/updated_chime_url#0987654321"} + "chime":{"url":"https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=654321"} } } """.trimIndent() 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 163388c7..be7a8cfe 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 @@ -66,7 +66,7 @@ class CreateNotificationConfigIT : PluginRestTestCase() { fun `test Create chime notification config with ID`() { // Create sample config request reference val configId = "sample_config_id" - val sampleChime = Chime("https://domain.com/sample_chime_url#1234567890") + val sampleChime = Chime("https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456") val referenceObject = NotificationConfig( "this is a sample config name", "this is a sample config description", diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/MicrosoftTeamsNotificationConfigCrudIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/MicrosoftTeamsNotificationConfigCrudIT.kt index f830ece4..90094c04 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/MicrosoftTeamsNotificationConfigCrudIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/config/MicrosoftTeamsNotificationConfigCrudIT.kt @@ -184,7 +184,7 @@ class MicrosoftTeamsNotificationConfigCrudIT : PluginRestTestCase() { "description":"${referenceObject.description}", "config_type":"microsoft_teams", "is_enabled":${referenceObject.isEnabled}, - "chime":{"url":"https://dummy.com"}, + "chime":{"url":"https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456"}, "microsoft_teams":{"url":"${(referenceObject.configData as MicrosoftTeams).url}"} } } 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 6a8451ed..c16a9da1 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 @@ -627,7 +627,7 @@ class QueryNotificationConfigIT : PluginRestTestCase() { val urlIds = setOf(slackId, chimeId, microsoftTeamsId, webhookId) val recipientIds = setOf(emailGroupId) val fromIds = setOf(emailGroupId, smtpAccountId) - val domainIds = setOf(chimeId, microsoftTeamsId, webhookId, smtpAccountId) + val domainIds = setOf(microsoftTeamsId, webhookId, smtpAccountId) Thread.sleep(1000) // Get notification configs using query=slack @@ -702,7 +702,7 @@ class QueryNotificationConfigIT : PluginRestTestCase() { val urlIds = setOf(slackId, chimeId, microsoftTeamsId, webhookId) val recipientIds = setOf(emailGroupId) val fromIds = setOf(emailGroupId, smtpAccountId) - val domainIds = setOf(chimeId, microsoftTeamsId, webhookId, smtpAccountId) + val domainIds = setOf(microsoftTeamsId, webhookId, smtpAccountId) Thread.sleep(1000) // Get notification configs using text_query=slack should not return any item @@ -780,7 +780,7 @@ class QueryNotificationConfigIT : PluginRestTestCase() { Thread.sleep(1000) // Create sample config request reference - val sampleChime = Chime("https://domain.com/sample_chime_url#1234567890") + val sampleChime = Chime("https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456") val referenceObject = NotificationConfig( "this is a sample config name", "this is a sample config description", 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 5bbac40c..8a906204 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 @@ -148,7 +148,7 @@ class SlackNotificationConfigCrudIT : PluginRestTestCase() { "description":"${referenceObject.description}", "config_type":"slack", "is_enabled":${referenceObject.isEnabled}, - "chime":{"url":"https://dummy.com"} + "chime":{"url":"https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456"} "slack":{"url":"${(referenceObject.configData as Slack).url} } } 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 10b09f3a..27b880ba 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 @@ -143,7 +143,7 @@ class SnsNotificationConfigCrudIT : PluginRestTestCase() { "description":"${referenceObject.description}", "config_type":"sns", "is_enabled":${referenceObject.isEnabled}, - "chime":{"url":"https://dummy.com"} + "chime":{"url":"https://hooks.chime.aws/incomingwebhooks/sample_chime_url?token=123456"} "sns":{"topic_arn":"${(referenceObject.configData as Sns).topicArn}","role_arn":"${(referenceObject.configData as Sns).roleArn}"} } } 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 c36e2666..9754494a 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 @@ -25,7 +25,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { "config_type":"chime", "is_enabled":true, "chime":{ - "url":"https://hooks.chime.aws/incomingwebhooks/xxxx" + "url":"https://hooks.chime.aws/incomingwebhooks/xxxx?token=xxxx" } } }