Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
8 changes: 8 additions & 0 deletions .changes/a9deee4f-8f15-472c-906f-492066275178.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "a9deee4f-8f15-472c-906f-492066275178",
"type": "bugfix",
"description": "Remove Route53 InvalidChangeBatch error response customization",
"issues": [
"https://github.com/awslabs/aws-sdk-kotlin/issues/1433"
]
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ aws.sdk.kotlin.codegen.customization.glacier.GlacierBodyChecksum
aws.sdk.kotlin.codegen.customization.polly.PollyPresigner
aws.sdk.kotlin.codegen.customization.machinelearning.MachineLearningEndpointCustomization
aws.sdk.kotlin.codegen.customization.route53.TrimResourcePrefix
aws.sdk.kotlin.codegen.customization.route53.ChangeResourceRecordSetsUnmarshallingIntegration
aws.sdk.kotlin.codegen.customization.ec2.EC2MakePrimitivesOptional
aws.sdk.kotlin.codegen.customization.RemoveDefaults
aws.sdk.kotlin.codegen.customization.s3.UnsupportedSigningAlgorithmIntegration
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

74 changes: 74 additions & 0 deletions services/route53/e2eTest/src/InvalidChangeBatchTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
package aws.sdk.kotlin.services.route53

import aws.sdk.kotlin.services.route53.model.*
import aws.smithy.kotlin.runtime.util.Uuid
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertContains
import kotlin.test.assertFailsWith
import kotlin.test.assertNotNull

// https://github.com/awslabs/aws-sdk-kotlin/issues/1433
class InvalidChangeBatchTest {
@Test
fun testMessageIsPopulated() = runTest {
Route53Client {
region = "us-east-1"
}.use { client ->
val createHostedZoneResp = client.createHostedZone {
this.callerReference = Uuid.random().toString()
this.name = "this-is-a-test-hosted-zone-for-aws-sdk-kotlin.com"
}

val hostedZoneId = checkNotNull(createHostedZoneResp.hostedZone?.id) { "Hosted zone is unexpectedly null" }

val exception = assertFailsWith<InvalidChangeBatch> {
client.changeResourceRecordSets {
this.hostedZoneId = hostedZoneId
this.changeBatch = ChangeBatch {
this.changes = listOf(
Change {
this.action = ChangeAction.Delete
this.resourceRecordSet = ResourceRecordSet {
this.name = "test.blerg.com"
this.type = RrType.Cname
this.ttl = 300
this.resourceRecords = listOf(
ResourceRecord {
value = "test.blerg.com"
},
)
}
},
Change {
this.action = ChangeAction.Create
this.resourceRecordSet = ResourceRecordSet {
this.name = "test.blerg.com"
this.type = RrType.Cname
this.ttl = 300
this.resourceRecords = listOf(
ResourceRecord {
value = "test.blerg.com"
},
)
}
},
)
this.comment = "testing..."
}
}
}

client.deleteHostedZone {
id = hostedZoneId
}

assertNotNull(exception.message)
assertContains(exception.message, "[Tried to delete resource record set [name='test.blerg.com.', type='CNAME'] but it was not found, RRSet with DNS name test.blerg.com. is not permitted in zone this-is-a-test-hosted-zone-for-aws-sdk-kotlin.com., RRSet of type CNAME with DNS name test.blerg.com. is not permitted as it creates a CNAME loop in the zone.]")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Asserting on specific exception messages which we do not control is brittle and prone to breakage. Simply deserializing the correct exception should be sufficient for our testing. Users should be catching/handling exceptions based on type anyways—not based on message.

}
}
}
Loading