Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ data class Sns(val topicArn: String, val roleArn: String?) : BaseConfigData {
private val log by logger(Sns::class.java)

private val SNS_ARN_REGEX =
Pattern.compile("^arn:aws(-[^:]+)?:sns:([a-zA-Z0-9-]+):([0-9]{12}):([a-zA-Z0-9-_]+)$")
Pattern.compile("^arn:aws(-[^:]+)?:sns:([a-zA-Z0-9-]+):([0-9]{12}):([a-zA-Z_0-9+=,.@\\-_/]+)$")

/**
* reader to create instance of class from writable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.opensearch.commons.notifications.model
import com.fasterxml.jackson.core.JsonParseException
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Assertions.fail
import org.junit.jupiter.api.Test
import org.opensearch.commons.utils.createObjectFromJsonString
import org.opensearch.commons.utils.getJsonString
Expand Down Expand Up @@ -49,6 +50,18 @@ internal class SnsTests {
}
}

@Test
fun `test SNS correctly validates SNS FIFO topic ARN`() {
try {
Sns(
"arn:aws:sns:ap-southeast-2:333654771707:sns-fifo-alerting.fifo",
"arn:aws:iam::012345678912:role/iam-test"
)
} catch (e: Exception) {
fail("Expected fifo sns topic ARN to be validated successfully", e)
}
}

@Test
fun `SNS serialize and deserialize transport object should be equal`() {
val sampleSns = Sns("arn:aws:sns:us-east-1:012345678912:topic-test", "arn:aws:iam::012345678912:role/iam-test")
Expand Down