diff --git a/notifications/build.gradle b/notifications/build.gradle index aac84e35..588d39db 100644 --- a/notifications/build.gradle +++ b/notifications/build.gradle @@ -79,7 +79,7 @@ configurations { } dependencies { - add("ktlint", "com.pinterest:ktlint:0.44.0") { + add("ktlint", "com.pinterest:ktlint:0.47.1") { attributes { attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) } diff --git a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/ChimeDestination.kt b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/ChimeDestination.kt index a1b5c5f7..8d167381 100644 --- a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/ChimeDestination.kt +++ b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/ChimeDestination.kt @@ -9,5 +9,5 @@ package org.opensearch.notifications.spi.model.destination * This class holds the contents of a Chime destination */ class ChimeDestination( - url: String, + url: String ) : WebhookDestination(url, DestinationType.CHIME) diff --git a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/MicrosoftTeamsDestination.kt b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/MicrosoftTeamsDestination.kt index 7200795f..3d3b4d42 100644 --- a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/MicrosoftTeamsDestination.kt +++ b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/MicrosoftTeamsDestination.kt @@ -9,5 +9,5 @@ package org.opensearch.notifications.spi.model.destination * This class holds the contents of a Microsoft Teams destination */ class MicrosoftTeamsDestination( - url: String, + url: String ) : WebhookDestination(url, DestinationType.MICROSOFT_TEAMS) diff --git a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SlackDestination.kt b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SlackDestination.kt index eb99e83c..bd9a3e76 100644 --- a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SlackDestination.kt +++ b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SlackDestination.kt @@ -9,5 +9,5 @@ package org.opensearch.notifications.spi.model.destination * This class holds the contents of a Slack destination */ class SlackDestination( - url: String, + url: String ) : WebhookDestination(url, DestinationType.SLACK) diff --git a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SnsDestination.kt b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SnsDestination.kt index 5b2ca208..d9b3ba36 100644 --- a/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SnsDestination.kt +++ b/notifications/core-spi/src/main/kotlin/org/opensearch/notifications/spi/model/destination/SnsDestination.kt @@ -9,7 +9,7 @@ package org.opensearch.notifications.spi.model.destination */ data class SnsDestination( val topicArn: String, - val roleArn: String? = null, + val roleArn: String? = null ) : BaseDestination(DestinationType.SNS) { // sample topic arn -> arn:aws:sns:us-west-2:075315751589:test-notification val region: String = topicArn.split(":".toRegex()).toTypedArray()[3] diff --git a/notifications/core-spi/src/test/kotlin/org/opensearch/notifications/spi/utils/ValidationHelpersTests.kt b/notifications/core-spi/src/test/kotlin/org/opensearch/notifications/spi/utils/ValidationHelpersTests.kt index 57f4e129..bfc0290b 100644 --- a/notifications/core-spi/src/test/kotlin/org/opensearch/notifications/spi/utils/ValidationHelpersTests.kt +++ b/notifications/core-spi/src/test/kotlin/org/opensearch/notifications/spi/utils/ValidationHelpersTests.kt @@ -100,6 +100,7 @@ internal class ValidationHelpersTests { fun `validator identifies chime url as valid`() { assert(isValidUrl(CHIME_URL)) } + @Test fun `validator identifies microsoft teams url as valid`() { assert(isValidUrl(MICROSOFT_TEAMS_WEBHOOK_URL)) diff --git a/notifications/core/src/main/kotlin/org/opensearch/notifications/core/NotificationCorePlugin.kt b/notifications/core/src/main/kotlin/org/opensearch/notifications/core/NotificationCorePlugin.kt index cfffb924..ada97fc1 100644 --- a/notifications/core/src/main/kotlin/org/opensearch/notifications/core/NotificationCorePlugin.kt +++ b/notifications/core/src/main/kotlin/org/opensearch/notifications/core/NotificationCorePlugin.kt @@ -41,6 +41,7 @@ class NotificationCorePlugin : ReloadablePlugin, Plugin(), ExtensiblePlugin { const val PLUGIN_NAME = "opensearch-notifications-core" const val LOG_PREFIX = "notifications-core" } + /** * {@inheritDoc} */ diff --git a/notifications/core/src/main/kotlin/org/opensearch/notifications/core/client/DestinationHttpClient.kt b/notifications/core/src/main/kotlin/org/opensearch/notifications/core/client/DestinationHttpClient.kt index ba3bd35d..c039a392 100644 --- a/notifications/core/src/main/kotlin/org/opensearch/notifications/core/client/DestinationHttpClient.kt +++ b/notifications/core/src/main/kotlin/org/opensearch/notifications/core/client/DestinationHttpClient.kt @@ -49,6 +49,7 @@ class DestinationHttpClient { constructor() { this.httpClient = createHttpClient() } + @OpenForTesting constructor(httpClient: CloseableHttpClient) { this.httpClient = httpClient @@ -56,15 +57,20 @@ class DestinationHttpClient { companion object { private val log by logger(DestinationHttpClient::class.java) + /** * all valid response status */ private val VALID_RESPONSE_STATUS = Collections.unmodifiableSet( HashSet( listOf( - RestStatus.OK.status, RestStatus.CREATED.status, RestStatus.ACCEPTED.status, - RestStatus.NON_AUTHORITATIVE_INFORMATION.status, RestStatus.NO_CONTENT.status, - RestStatus.RESET_CONTENT.status, RestStatus.PARTIAL_CONTENT.status, + RestStatus.OK.status, + RestStatus.CREATED.status, + RestStatus.ACCEPTED.status, + RestStatus.NON_AUTHORITATIVE_INFORMATION.status, + RestStatus.NO_CONTENT.status, + RestStatus.RESET_CONTENT.status, + RestStatus.PARTIAL_CONTENT.status, RestStatus.MULTI_STATUS.status ) ) diff --git a/notifications/core/src/main/kotlin/org/opensearch/notifications/core/setting/PluginSettings.kt b/notifications/core/src/main/kotlin/org/opensearch/notifications/core/setting/PluginSettings.kt index 75bbeb1b..bd32ead3 100644 --- a/notifications/core/src/main/kotlin/org/opensearch/notifications/core/setting/PluginSettings.kt +++ b/notifications/core/src/main/kotlin/org/opensearch/notifications/core/setting/PluginSettings.kt @@ -294,71 +294,83 @@ internal object PluginSettings { EMAIL_SIZE_LIMIT_KEY, defaultSettings[EMAIL_SIZE_LIMIT_KEY]!!.toInt(), MINIMUM_EMAIL_SIZE_LIMIT, - NodeScope, Dynamic + NodeScope, + Dynamic ) val EMAIL_MINIMUM_HEADER_LENGTH: Setting = Setting.intSetting( EMAIL_MINIMUM_HEADER_LENGTH_KEY, defaultSettings[EMAIL_MINIMUM_HEADER_LENGTH_KEY]!!.toInt(), - NodeScope, Dynamic + NodeScope, + Dynamic ) val MAX_CONNECTIONS: Setting = Setting.intSetting( MAX_CONNECTIONS_KEY, defaultSettings[MAX_CONNECTIONS_KEY]!!.toInt(), - NodeScope, Dynamic + NodeScope, + Dynamic ) val MAX_CONNECTIONS_PER_ROUTE: Setting = Setting.intSetting( MAX_CONNECTIONS_PER_ROUTE_KEY, defaultSettings[MAX_CONNECTIONS_PER_ROUTE_KEY]!!.toInt(), - NodeScope, Dynamic + NodeScope, + Dynamic ) val CONNECTION_TIMEOUT_MILLISECONDS: Setting = Setting.intSetting( CONNECTION_TIMEOUT_MILLISECONDS_KEY, defaultSettings[CONNECTION_TIMEOUT_MILLISECONDS_KEY]!!.toInt(), - NodeScope, Dynamic + NodeScope, + Dynamic ) val SOCKET_TIMEOUT_MILLISECONDS: Setting = Setting.intSetting( SOCKET_TIMEOUT_MILLISECONDS_KEY, defaultSettings[SOCKET_TIMEOUT_MILLISECONDS_KEY]!!.toInt(), - NodeScope, Dynamic + NodeScope, + Dynamic ) val ALLOWED_CONFIG_TYPES: Setting> = Setting.listSetting( ALLOWED_CONFIG_TYPE_KEY, DEFAULT_ALLOWED_CONFIG_TYPES, { it }, - NodeScope, Dynamic + NodeScope, + Dynamic ) val TOOLTIP_SUPPORT: Setting = Setting.boolSetting( TOOLTIP_SUPPORT_KEY, defaultSettings[TOOLTIP_SUPPORT_KEY]!!.toBoolean(), - NodeScope, Dynamic + NodeScope, + Dynamic ) val LEGACY_ALERTING_HOST_DENY_LIST: Setting> = Setting.listSetting( LEGACY_ALERTING_HOST_DENY_LIST_KEY, DEFAULT_HOST_DENY_LIST, { it }, - NodeScope, Final, Deprecated + NodeScope, + Final, + Deprecated ) val ALERTING_HOST_DENY_LIST: Setting> = Setting.listSetting( ALERTING_HOST_DENY_LIST_KEY, LEGACY_ALERTING_HOST_DENY_LIST, { it }, - NodeScope, Final + NodeScope, + Final ) val HOST_DENY_LIST: Setting> = Setting.listSetting( HOST_DENY_LIST_KEY, ALERTING_HOST_DENY_LIST, { it }, - NodeScope, Dynamic + NodeScope, + Dynamic ) private val LEGACY_EMAIL_USERNAME: Setting.AffixSetting = Setting.affixKeySetting( @@ -415,6 +427,7 @@ internal object PluginSettings { EMAIL_PASSWORD ) } + /** * Update the setting variables to setting values from local settings * @param clusterService cluster service instance diff --git a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt index 55456eee..45fae9f7 100644 --- a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt +++ b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/ChimeDestinationTests.kt @@ -43,7 +43,7 @@ internal class ChimeDestinationTests { Arguments.of("\t", """\t"""), Arguments.of("\b", """\b"""), Arguments.of("\r", """\r"""), - Arguments.of("\"", """\""""), + Arguments.of("\"", """\"""") ) } diff --git a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/CustomWebhookDestinationTests.kt b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/CustomWebhookDestinationTests.kt index c354a2c4..618392eb 100644 --- a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/CustomWebhookDestinationTests.kt +++ b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/CustomWebhookDestinationTests.kt @@ -46,6 +46,7 @@ internal class CustomWebhookDestinationTests { Arguments.of("PUT", HttpPut::class.java), Arguments.of("PATCH", HttpPatch::class.java) ) + @JvmStatic fun escapeSequenceToRaw(): Stream = Stream.of( @@ -53,7 +54,7 @@ internal class CustomWebhookDestinationTests { Arguments.of("\t", """\t"""), Arguments.of("\b", """\b"""), Arguments.of("\r", """\r"""), - Arguments.of("\"", """\""""), + Arguments.of("\"", """\"""") ) } diff --git a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/MicrosoftTeamsDestinationTests.kt b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/MicrosoftTeamsDestinationTests.kt index 92037707..2c89a6e4 100644 --- a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/MicrosoftTeamsDestinationTests.kt +++ b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/MicrosoftTeamsDestinationTests.kt @@ -43,7 +43,7 @@ internal class MicrosoftTeamsDestinationTests { Arguments.of("\t", """\t"""), Arguments.of("\b", """\b"""), Arguments.of("\r", """\r"""), - Arguments.of("\"", """\""""), + Arguments.of("\"", """\"""") ) } diff --git a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/SlackDestinationTests.kt b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/SlackDestinationTests.kt index 8902ae50..0ab0e66f 100644 --- a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/SlackDestinationTests.kt +++ b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/destinations/SlackDestinationTests.kt @@ -43,7 +43,7 @@ internal class SlackDestinationTests { Arguments.of("\t", """\t"""), Arguments.of("\b", """\b"""), Arguments.of("\r", """\r"""), - Arguments.of("\"", """\""""), + Arguments.of("\"", """\"""") ) } diff --git a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/smtp/SmtpEmailTests.kt b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/smtp/SmtpEmailTests.kt index c3bd0e91..ecf40bf8 100644 --- a/notifications/core/src/test/kotlin/org/opensearch/notifications/core/smtp/SmtpEmailTests.kt +++ b/notifications/core/src/test/kotlin/org/opensearch/notifications/core/smtp/SmtpEmailTests.kt @@ -47,7 +47,7 @@ class SmtpEmailTests { "opensearch.data", "base64", "VGVzdCBtZXNzYWdlCgo=", - "application/octet-stream", + "application/octet-stream" ) DestinationTransportProvider.destinationTransportMap = mapOf(DestinationType.SMTP to SmtpDestinationTransport()) val response = NotificationCoreImpl.sendMessage(smtpDestination, message, "ref") @@ -72,7 +72,7 @@ class SmtpEmailTests { "opensearch.data", "base64", "VGVzdCBtZXNzYWdlCgo=", - "application/octet-stream", + "application/octet-stream" ) DestinationTransportProvider.destinationTransportMap = mapOf(DestinationType.SMTP to SmtpDestinationTransport()) val response = NotificationCoreImpl.sendMessage(smtpDestination, message, "ref") diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt index f52de1b5..b27cd353 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/metrics/Metrics.kt @@ -34,7 +34,8 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { RollingCounter() ), NOTIFICATIONS_EXCEPTIONS_VERSION_CONFLICT_ENGINE_EXCEPTION( - "exception.version_conflict_engine", RollingCounter() + "exception.version_conflict_engine", + RollingCounter() ), NOTIFICATIONS_EXCEPTIONS_INDEX_NOT_FOUND_EXCEPTION( "exception.index_not_found", @@ -84,20 +85,24 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { RollingCounter() ), NOTIFICATIONS_CONFIG_UPDATE_USER_ERROR_INVALID_CONFIG_ID( - "notifications_config.update.user_error.invalid_config_id", RollingCounter() + "notifications_config.update.user_error.invalid_config_id", + RollingCounter() ), NOTIFICATIONS_CONFIG_UPDATE_SYSTEM_ERROR( "notifications_config.update.system_error", RollingCounter() ), // Notification config general user error NOTIFICATIONS_CONFIG_USER_ERROR_INVALID_EMAIL_ACCOUNT_ID( - "notifications_config.user_error.invalid_email_account_id", RollingCounter() + "notifications_config.user_error.invalid_email_account_id", + RollingCounter() ), NOTIFICATIONS_CONFIG_USER_ERROR_INVALID_EMAIL_GROUP_ID( - "notifications_config.user_error.invalid_email_group_id", RollingCounter() + "notifications_config.user_error.invalid_email_group_id", + RollingCounter() ), NOTIFICATIONS_CONFIG_USER_ERROR_NEITHER_EMAIL_NOR_GROUP( - "notifications_config.user_error.neither_email_nor_group", RollingCounter() + "notifications_config.user_error.neither_email_nor_group", + RollingCounter() ), // DELETE _plugins/_notifications/configs/{configId}, Delete a notification config NOTIFICATIONS_CONFIG_DELETE_TOTAL( "notifications_config.delete.total", @@ -108,10 +113,12 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { RollingCounter() ), NOTIFICATIONS_CONFIG_DELETE_USER_ERROR_INVALID_CONFIG_ID( - "notifications_config.delete.user_error.invalid_config_id", RollingCounter() + "notifications_config.delete.user_error.invalid_config_id", + RollingCounter() ), NOTIFICATIONS_CONFIG_DELETE_USER_ERROR_SET_NOT_FOUND( - "notifications_config.delete.user_error.set_not_found", RollingCounter() + "notifications_config.delete.user_error.set_not_found", + RollingCounter() ), NOTIFICATIONS_CONFIG_DELETE_SYSTEM_ERROR( "notifications_config.delete.system_error", @@ -126,11 +133,14 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { RollingCounter() ), // add specific user errors for config GET operations NOTIFICATIONS_CONFIG_INFO_USER_ERROR_INVALID_CONFIG_ID( - "notifications_config.info.user_error.invalid_config_id", RollingCounter() + "notifications_config.info.user_error.invalid_config_id", + RollingCounter() ), NOTIFICATIONS_CONFIG_INFO_USER_ERROR_SET_NOT_FOUND( - "notifications_config.info.user_error.set_not_found", RollingCounter() + "notifications_config.info.user_error.set_not_found", + RollingCounter() ), + // Feature Channels Endpoints // GET _plugins/_notifications/channels NOTIFICATIONS_CHANNELS_INFO_TOTAL( @@ -138,8 +148,10 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { BasicCounter() ), NOTIFICATIONS_CHANNELS_INFO_INTERVAL_COUNT( - "notifications_channels.info.count", RollingCounter() + "notifications_channels.info.count", + RollingCounter() ), + // Features Endpoints // GET _plugins/_notifications/features NOTIFICATIONS_FEATURES_INFO_TOTAL( @@ -150,6 +162,7 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { "notifications_features.info.count", RollingCounter() ), + // Send Message Endpoints // POST _plugins/_notifications/send NOTIFICATIONS_SEND_MESSAGE_TOTAL( @@ -161,7 +174,8 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { RollingCounter() ), // user errors for send message? NOTIFICATIONS_SEND_MESSAGE_USER_ERROR_NOT_FOUND( - "notifications.send_message.user_error.not_found", RollingCounter() + "notifications.send_message.user_error.not_found", + RollingCounter() ), NOTIFICATIONS_MESSAGE_DESTINATION_SLACK( "notifications.message_destination.slack", @@ -184,18 +198,22 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { BasicCounter() ), NOTIFICATIONS_MESSAGE_DESTINATION_SES_ACCOUNT( - "notifications.message_destination.ses_account", BasicCounter() + "notifications.message_destination.ses_account", + BasicCounter() ), NOTIFICATIONS_MESSAGE_DESTINATION_SMTP_ACCOUNT( - "notifications.message_destination.smtp_account", BasicCounter() + "notifications.message_destination.smtp_account", + BasicCounter() ), NOTIFICATIONS_MESSAGE_DESTINATION_EMAIL_GROUP( - "notifications.message_destination.email_group", BasicCounter() + "notifications.message_destination.email_group", + BasicCounter() ), // TODO: add after implementation added NOTIFICATIONS_MESSAGE_DESTINATION_SNS( "notifications.message_destination.sns", BasicCounter() ), + // Send Test Message Endpoints // GET _plugins/_notifications/feature/test/{configId} NOTIFICATIONS_SEND_TEST_MESSAGE_TOTAL( @@ -203,7 +221,8 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) { BasicCounter() ), NOTIFICATIONS_SEND_TEST_MESSAGE_INTERVAL_COUNT( - "notifications.send_test_message.interval_count", RollingCounter() + "notifications.send_test_message.interval_count", + RollingCounter() ), // Send test message exceptions are thrown by the Send Message Action NOTIFICATIONS_SECURITY_USER_ERROR( "security_user_error", diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt index 083c01b0..5fdc3813 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/send/SendMessageActionHelper.kt @@ -603,6 +603,7 @@ object SendMessageActionHelper { DestinationMessageResponse(RestStatus.FAILED_DEPENDENCY.status, "Failed to send notification") } } + /** * Collects all child configs of the channel configurations (like email) * @param channels list of NotificationConfigDocInfo diff --git a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/settings/PluginSettings.kt b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/settings/PluginSettings.kt index c457ea99..3bd05ab1 100644 --- a/notifications/notifications/src/main/kotlin/org/opensearch/notifications/settings/PluginSettings.kt +++ b/notifications/notifications/src/main/kotlin/org/opensearch/notifications/settings/PluginSettings.kt @@ -123,32 +123,38 @@ internal object PluginSettings { OPERATION_TIMEOUT_MS_KEY, defaultSettings[OPERATION_TIMEOUT_MS_KEY]!!.toLong(), MINIMUM_OPERATION_TIMEOUT_MS, - NodeScope, Dynamic + NodeScope, + Dynamic ) val DEFAULT_ITEMS_QUERY_COUNT: Setting = Setting.intSetting( DEFAULT_ITEMS_QUERY_COUNT_KEY, defaultSettings[DEFAULT_ITEMS_QUERY_COUNT_KEY]!!.toInt(), MINIMUM_ITEMS_QUERY_COUNT, - NodeScope, Dynamic + NodeScope, + Dynamic ) val LEGACY_ALERTING_FILTER_BY_BACKEND_ROLES: Setting = Setting.boolSetting( LEGACY_ALERTING_FILTER_BY_BACKEND_ROLES_KEY, false, - NodeScope, Dynamic, Deprecated, + NodeScope, + Dynamic, + Deprecated ) val ALERTING_FILTER_BY_BACKEND_ROLES: Setting = Setting.boolSetting( ALERTING_FILTER_BY_BACKEND_ROLES_KEY, LEGACY_ALERTING_FILTER_BY_BACKEND_ROLES, - NodeScope, Dynamic + NodeScope, + Dynamic ) val FILTER_BY_BACKEND_ROLES: Setting = Setting.boolSetting( FILTER_BY_BACKEND_ROLES_KEY, ALERTING_FILTER_BY_BACKEND_ROLES, - NodeScope, Dynamic + NodeScope, + Dynamic ) fun isRbacEnabled(): Boolean { 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 a897381a..fefc8a61 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/IntegTestHelpers.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/IntegTestHelpers.kt @@ -179,8 +179,12 @@ class NotificationsJsonEntity( var jsonEntityString: String = "" private constructor(builder: Builder) : this( - builder.refTag, builder.recipients, builder.title, - builder.textDescription, builder.htmlDescription, builder.attachment + builder.refTag, + builder.recipients, + builder.title, + builder.textDescription, + builder.htmlDescription, + builder.attachment ) fun getJsonEntityAsString(): String { 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 c6814d4c..57c6503f 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/SecurityNotificationIT.kt @@ -24,7 +24,8 @@ class SecurityNotificationIT : PluginRestTestCase() { companion object { @BeforeClass - @JvmStatic fun setup() { + @JvmStatic + fun setup() { // things to execute once and keep around for the class org.junit.Assume.assumeTrue(System.getProperty("https", "false")!!.toBoolean()) } @@ -36,7 +37,6 @@ class SecurityNotificationIT : PluginRestTestCase() { @Before fun create() { - if (userClient == null) { createUser(user, password, arrayOf()) userClient = SecureRestClientBuilder(clusterHosts.toTypedArray(), isHttps(), user, password).setSocketTimeout(60000).build() @@ -45,7 +45,6 @@ class SecurityNotificationIT : PluginRestTestCase() { @After fun cleanup() { - userClient?.close() } 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 3cd638c2..aed06e9f 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 @@ -715,7 +715,6 @@ class EmailNotificationConfigCrudIT : PluginRestTestCase() { } fun `test Create email notification config wit email_group IDs put as email account id should fail`() { - // Create email group notification config val createEmailGroupRequestJsonString = """ { 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..4cdf4994 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 @@ -46,6 +46,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { val error = sendResponse.get("error").asJsonObject Assert.assertNotNull(error.get("reason").asString) } + @Suppress("EmptyFunctionBlock") fun `test send test slack message`() { // Create webhook notification config @@ -78,6 +79,7 @@ internal class SendTestMessageRestHandlerIT : PluginRestTestCase() { val error = sendResponse.get("error").asJsonObject Assert.assertNotNull(error.get("reason").asString) } + @Suppress("EmptyFunctionBlock") fun `test send test microsoft teams message`() { // Create webhook notification config diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageWithMockServerIT.kt b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageWithMockServerIT.kt index 74ed2d94..29a90714 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageWithMockServerIT.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/integtest/send/SendTestMessageWithMockServerIT.kt @@ -46,7 +46,10 @@ internal class SendTestMessageWithMockServerIT : PluginRestTestCase() { // send test message val sendResponse = executeRequest( - RestRequest.Method.POST.name, "$PLUGIN_BASE_URI/feature/test/$configId", "", RestStatus.OK.status + RestRequest.Method.POST.name, + "$PLUGIN_BASE_URI/feature/test/$configId", + "", + RestStatus.OK.status ) logger.info(sendResponse) diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/ConfigIndexingActionsTests.kt b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/ConfigIndexingActionsTests.kt index d2c6b0ee..41b1bd0d 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/ConfigIndexingActionsTests.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/ConfigIndexingActionsTests.kt @@ -36,7 +36,9 @@ class ConfigIndexingActionsTests { fun initialize() { /* use reflection to get private method */ validateMicrosoftTeamsConfig = ConfigIndexingActions::class.java.getDeclaredMethod( - "validateMicrosoftTeamsConfig", MicrosoftTeams::class.java, User::class.java + "validateMicrosoftTeamsConfig", + MicrosoftTeams::class.java, + User::class.java ) validateMicrosoftTeamsConfig.isAccessible = true diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/NotificationConfigIndexTests.kt b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/NotificationConfigIndexTests.kt index 6cb8c60a..51bf4251 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/NotificationConfigIndexTests.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/index/NotificationConfigIndexTests.kt @@ -62,7 +62,8 @@ class NotificationConfigIndexTests { fun initialize() { /* use reflection to get private method */ getSchemaVersionFromIndexMapping = NotificationConfigIndex::class.java.getDeclaredMethod( - "getSchemaVersionFromIndexMapping", Map::class.java + "getSchemaVersionFromIndexMapping", + Map::class.java ) getSchemaVersionFromIndexMapping.isAccessible = true diff --git a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/settings/PluginSettingsTests.kt b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/settings/PluginSettingsTests.kt index 96c84898..951ad96d 100644 --- a/notifications/notifications/src/test/kotlin/org/opensearch/notifications/settings/PluginSettingsTests.kt +++ b/notifications/notifications/src/test/kotlin/org/opensearch/notifications/settings/PluginSettingsTests.kt @@ -79,7 +79,7 @@ internal class PluginSettingsTests { clusterSettings, setOf( PluginSettings.OPERATION_TIMEOUT_MS, - PluginSettings.DEFAULT_ITEMS_QUERY_COUNT, + PluginSettings.DEFAULT_ITEMS_QUERY_COUNT ) ) )