forked from opensearch-project/common-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BugFix: Allow null values for role_arn in json parsing (opensearch-pr…
- Loading branch information
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,14 @@ internal class SesAccountTests { | |
assertEquals(sesAccount, recreatedObject) | ||
} | ||
|
||
@Test | ||
fun `SES serialize and deserialize using json object should be equal with null roleArn`() { | ||
val sesAccount = SesAccount("us-east-1", null, "[email protected]") | ||
val jsonString = getJsonString(sesAccount) | ||
val recreatedObject = createObjectFromJsonString(jsonString) { SesAccount.parse(it) } | ||
assertEquals(sesAccount, recreatedObject) | ||
} | ||
|
||
@Test | ||
fun `SES should deserialize json object using parser`() { | ||
val sesAccount = SesAccount("us-east-1", "arn:aws:iam::012345678912:role/iam-test", "[email protected]") | ||
|
@@ -96,6 +104,33 @@ internal class SesAccountTests { | |
assertEquals(sesAccount, recreatedObject) | ||
} | ||
|
||
@Test | ||
fun `SES should deserialize json object will null role_arn using parser`() { | ||
val sesAccount = SesAccount("us-east-1", null, "[email protected]") | ||
val jsonString = """ | ||
{ | ||
"region":"${sesAccount.awsRegion}", | ||
"role_arn":null, | ||
"from_address":"${sesAccount.fromAddress}" | ||
} | ||
""".trimIndent() | ||
val recreatedObject = createObjectFromJsonString(jsonString) { SesAccount.parse(it) } | ||
assertEquals(sesAccount, recreatedObject) | ||
} | ||
|
||
@Test | ||
fun `SES should deserialize json object will missing role_arn using parser`() { | ||
val sesAccount = SesAccount("us-east-1", null, "[email protected]") | ||
val jsonString = """ | ||
{ | ||
"region":"${sesAccount.awsRegion}", | ||
"from_address":"${sesAccount.fromAddress}" | ||
} | ||
""".trimIndent() | ||
val recreatedObject = createObjectFromJsonString(jsonString) { SesAccount.parse(it) } | ||
assertEquals(sesAccount, recreatedObject) | ||
} | ||
|
||
@Test | ||
fun `SES should throw exception when invalid json object is passed`() { | ||
val jsonString = "sample message" | ||
|