From 1e83047c57092758fb279033afd2963e08d2143e Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Mon, 16 Oct 2023 14:27:23 +0800 Subject: [PATCH 1/6] bump bwc version to 2.12 (#793) Signed-off-by: Hailong Cui --- notifications/notifications/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications/notifications/build.gradle b/notifications/notifications/build.gradle index 0024ef0c..0db0b393 100644 --- a/notifications/notifications/build.gradle +++ b/notifications/notifications/build.gradle @@ -265,7 +265,7 @@ testClusters.integTest { } // Always be minimumCompatibilityVersion of current opensearch version(3.0.0) -def bwcVersionShort = "2.11.0" +def bwcVersionShort = "2.12.0" def bwcVersion = bwcVersionShort + ".0" def bwcOpenSearchVesion= bwcVersionShort + "-SNAPSHOT" def bwcPluginVersion = bwcVersion + "-SNAPSHOT" From 48e05afb1c48ad51488927a7845d79fe00a2f479 Mon Sep 17 00:00:00 2001 From: gaobinlong Date: Tue, 17 Oct 2023 11:34:49 +0800 Subject: [PATCH 2/6] Update dependency org.json:json to v20231013 (#795) Signed-off-by: gaobinlong --- notifications/notifications/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifications/notifications/build.gradle b/notifications/notifications/build.gradle index 0db0b393..14f686ce 100644 --- a/notifications/notifications/build.gradle +++ b/notifications/notifications/build.gradle @@ -100,7 +100,7 @@ dependencies { } // ${kotlin_version} does not work for coroutines implementation "${group}:common-utils:${common_utils_version}" // TODO: change compile to implementation when the _local/stats API is supported - compileOnly "org.json:json:20230227" + compileOnly "org.json:json:20231013" compileOnly "com.github.wnameless.json:json-flattener:0.13.0" // TODO: uncomment when the _local/stats API is supported // implementation "com.github.wnameless.json:json-base:2.0.0" From 0e55d38cbaa372265e444ca9107b6519b8b75c44 Mon Sep 17 00:00:00 2001 From: Aniruddh <63553175+Noir01@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:32:33 -0400 Subject: [PATCH 3/6] Re-enable detekt (#796) Bumped version of `io.gitlab.arturbosch.detekt:detekt-gradle-plugin` to `1.23.0` Signed-off-by: Aniruddh <63553175+Noir01@users.noreply.github.com> Co-authored-by: Hailong Cui --- notifications/build.gradle | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/notifications/build.gradle b/notifications/build.gradle index 7c9b7741..899d50d4 100644 --- a/notifications/build.gradle +++ b/notifications/build.gradle @@ -38,16 +38,14 @@ buildscript { classpath "org.opensearch.gradle:build-tools:${opensearch_version}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}" classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlin_version}" -// TODO: enable detekt only when snakeyaml vulnerability is fixed -// classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.17.1" + classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.23.0" classpath "org.jacoco:org.jacoco.agent:0.8.7" } } apply plugin: 'base' apply plugin: 'jacoco' -// TODO: enable detekt only when snakeyaml vulnerability is fixed -//apply plugin: 'io.gitlab.arturbosch.detekt' +apply plugin: 'io.gitlab.arturbosch.detekt' apply from: 'build-tools/merged-coverage.gradle' allprojects { @@ -100,12 +98,11 @@ task ktlintFormat(type: JavaExec, group: "formatting") { jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED" } -// TODO: enable detekt only when snakeyaml vulnerability is fixed -//detekt { -// config = files("detekt.yml") -// buildUponDefaultConfig = true -// parallel = true -//} +detekt { + config = files("detekt.yml") + buildUponDefaultConfig = true + parallel = true +} check.dependsOn ktlint From e0ba777fea267c58c3f39852612c6c53b6d7ddf1 Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Thu, 19 Oct 2023 23:10:27 +0800 Subject: [PATCH 4/6] Impove security plugin enabling check (#792) Signed-off-by: Hailong Cui --- .../workflows/security-notifications-test-workflow.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/security-notifications-test-workflow.yml b/.github/workflows/security-notifications-test-workflow.yml index 0d77cf7a..31352b76 100644 --- a/.github/workflows/security-notifications-test-workflow.yml +++ b/.github/workflows/security-notifications-test-workflow.yml @@ -79,10 +79,10 @@ jobs: - name: Run Notification Test for security enabled test cases if: env.imagePresent == 'true' run: | - cluster_running=`curl -XGET https://localhost:9200/_cat/plugins -u admin:admin --insecure` - echo $cluster_running - security=`curl -XGET https://localhost:9200/_cat/plugins -u admin:admin --insecure |grep opensearch-security|wc -l` - echo $security + container_id=`docker ps -q` + plugins=`docker exec $container_id /usr/share/opensearch/bin/opensearch-plugin list` + echo "plugins: $plugins" + security=`echo $plugins | grep opensearch-security | wc -l` if [ $security -gt 0 ] then echo "Security plugin is available" @@ -91,4 +91,4 @@ jobs: else echo "Security plugin is NOT available skipping this run as tests without security have already been run" exit 1 - fi \ No newline at end of file + fi From eda85eb5add3e1d4ae18b852ce99a4c0c3195f7b Mon Sep 17 00:00:00 2001 From: Hailong Cui Date: Fri, 20 Oct 2023 11:27:20 +0800 Subject: [PATCH 5/6] Add github workflow to auto bump bwc version (#799) * Adding bump bwc version github workflow Signed-off-by: Hailong Cui * revert app id Signed-off-by: Hailong Cui --------- Signed-off-by: Hailong Cui --- .github/workflows/bump-bwc.yml | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/bump-bwc.yml diff --git a/.github/workflows/bump-bwc.yml b/.github/workflows/bump-bwc.yml new file mode 100644 index 00000000..dfdec028 --- /dev/null +++ b/.github/workflows/bump-bwc.yml @@ -0,0 +1,66 @@ +name: Bump bwc version + +on: + workflow_dispatch: + inputs: + tag: + type: string + required: true + push: + tags: + - '*.*.*.*' + +permissions: {} +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: GitHub App token + id: github_app_token + uses: tibdex/github-app-token@v1.5.0 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + installation_id: 22958780 + + - uses: actions/checkout@v4 + - name: Fetch Tag and Version Information + run: | + if [ -n ${{ inputs.tag }} ]; then + TAG=${{ inputs.tag }} + else + TAG=$(echo "${GITHUB_REF#refs/*/}") + fi + CURRENT_VERSION_ARRAY=($(echo "$TAG" | tr . '\n')) + CURRENT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") + CURRENT_VERSION_ARRAY[1]=$((CURRENT_VERSION_ARRAY[1]+1)) + NEXT_VERSION=$(IFS=. ; echo "${CURRENT_VERSION_ARRAY[*]:0:3}") + echo "TAG=$TAG" >> $GITHUB_ENV + echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV + echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV + + - uses: actions/checkout@v4 + with: + ref: main + token: ${{ steps.github_app_token.outputs.token }} + + - name: Bump bwc version for main branch + run: | + echo Bumping bwc version to $NEXT_VERSION + sed -i "s/def bwcVersionShort = \"$CURRENT_VERSION\"/def bwcVersionShort = \"$NEXT_VERSION\"/g" notifications/notifications/build.gradle + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ steps.github_app_token.outputs.token }} + base: main + branch: 'create-pull-request/patch-main' + commit-message: Bump bwc version to ${{ env.NEXT_VERSION }} + signoff: true + delete-branch: true + labels: | + autocut + title: '[AUTO] [main] Bump bwc version to ${{ env.NEXT_VERSION }}.' + body: | + I've noticed that a new tag ${{ env.TAG }} was pushed, and bump bwc version to ${{ env.NEXT_VERSION }}. + From 76ddcd47820df976121dadeb8323632a546271b5 Mon Sep 17 00:00:00 2001 From: Rachana Dani <36135368+rachana-dani@users.noreply.github.com> Date: Mon, 23 Oct 2023 08:35:30 +0530 Subject: [PATCH 6/6] Replace the TestMailServer to GreenMail server (#801) * Add 2.11 release notes (#774) Signed-off-by: yuye-aws Signed-off-by: rdani * Fix integration test failure by allowing direct access to system index warning (#784) * Fix integration test failure by allowing direct access to system index warning Signed-off-by: gaobinlong * Fix bwc test failure of throwing direct access to system index when getting mapping Signed-off-by: gaobinlong --------- Signed-off-by: gaobinlong Signed-off-by: rdani * Replace the TestMailServer to GreenMail server Signed-off-by: rdani * bump bwc version to 2.12 (#793) Signed-off-by: Hailong Cui Signed-off-by: rdani * Update dependency org.json:json to v20231013 (#795) Signed-off-by: gaobinlong Signed-off-by: rdani * Re-enable detekt (#796) Bumped version of `io.gitlab.arturbosch.detekt:detekt-gradle-plugin` to `1.23.0` Signed-off-by: Aniruddh <63553175+Noir01@users.noreply.github.com> Co-authored-by: Hailong Cui Signed-off-by: rdani * Add assertion for retrieval of notification Signed-off-by: rdani * Update to stable version Signed-off-by: rdani * Update to stable version Signed-off-by: rdani * Update to suggested version Signed-off-by: rdani --------- Signed-off-by: yuye-aws Signed-off-by: rdani Signed-off-by: gaobinlong Signed-off-by: Hailong Cui Signed-off-by: Aniruddh <63553175+Noir01@users.noreply.github.com> Co-authored-by: Yuye Zhu Co-authored-by: gaobinlong Co-authored-by: rdani Co-authored-by: Hailong Cui Co-authored-by: Aniruddh <63553175+Noir01@users.noreply.github.com> --- notifications/core/build.gradle | 2 ++ .../notifications/core/smtp/SmtpEmailTests.kt | 27 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/notifications/core/build.gradle b/notifications/core/build.gradle index a00ccf60..1cef6633 100644 --- a/notifications/core/build.gradle +++ b/notifications/core/build.gradle @@ -161,6 +161,8 @@ dependencies { 'io.mockk:mockk-agent-jvm:1.11.0' ) testImplementation 'org.springframework.integration:spring-integration-mail:5.5.0' + // https://mvnrepository.com/artifact/com.icegreen/greenmail + testImplementation group: 'com.icegreen', name: 'greenmail', version: '1.6.14' testImplementation 'org.springframework.integration:spring-integration-test-support:5.5.0' testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.6.2') testImplementation "org.jetbrains.kotlin:kotlin-test:${kotlin_version}" 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..66f400c6 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 @@ -5,7 +5,10 @@ package org.opensearch.notifications.core.smtp -import org.junit.After +import com.icegreen.greenmail.util.GreenMail +import com.icegreen.greenmail.util.ServerSetupTest +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.opensearch.core.rest.RestStatus import org.opensearch.notifications.core.NotificationCoreImpl @@ -14,20 +17,21 @@ import org.opensearch.notifications.core.transport.SmtpDestinationTransport import org.opensearch.notifications.spi.model.MessageContent import org.opensearch.notifications.spi.model.destination.DestinationType import org.opensearch.notifications.spi.model.destination.SmtpDestination -import org.springframework.integration.test.mail.TestMailServer import kotlin.test.assertEquals class SmtpEmailTests { - internal companion object { - private const val smtpPort = 10255 // use non-standard port > 1024 to avoid permission issue - private val smtpServer = TestMailServer.smtp(smtpPort) + private lateinit var greenMail: GreenMail + + @BeforeEach + fun setUpServer() { + greenMail = GreenMail(ServerSetupTest.SMTP) + greenMail.start() } - @After + @AfterEach fun tearDownServer() { - smtpServer.stop() - smtpServer.resetServer() + greenMail.stop() } @Test @@ -35,7 +39,7 @@ class SmtpEmailTests { val smtpDestination = SmtpDestination( "testAccountName", "localhost", - smtpPort, + ServerSetupTest.SMTP.port, "none", "from@email.com", "test@localhost.com" @@ -53,6 +57,7 @@ class SmtpEmailTests { val response = NotificationCoreImpl.sendMessage(smtpDestination, message, "ref") assertEquals("Success", response.statusText) assertEquals(RestStatus.OK.status, response.statusCode) + assertEquals(1, greenMail.receivedMessages.size) // Indicates retrieval of notification. } @Test @@ -60,7 +65,7 @@ class SmtpEmailTests { val smtpDestination = SmtpDestination( "testAccountName", "invalidHost", - smtpPort, + ServerSetupTest.SMTP.port, "none", "from@email.com", "test@localhost.com" @@ -77,7 +82,7 @@ class SmtpEmailTests { DestinationTransportProvider.destinationTransportMap = mapOf(DestinationType.SMTP to SmtpDestinationTransport()) val response = NotificationCoreImpl.sendMessage(smtpDestination, message, "ref") assertEquals( - "sendEmail Error, status:Couldn't connect to host, port: invalidHost, $smtpPort; timeout -1", + "sendEmail Error, status:Couldn't connect to host, port: invalidHost, ${ServerSetupTest.SMTP.port}; timeout -1", response.statusText ) assertEquals(RestStatus.SERVICE_UNAVAILABLE.status, response.statusCode)