test(ses): build v2-only SES test requests with SesV2Requests.v2() (#9274)

This commit is contained in:
Kenshin Okinaka authored and GitHub committed 2026-11-23 11:01:41 -04:00
1 parent 86ef90b99c
commit da661523ae
26 files changed
+527 -1154

No files matched your search

@@ -13,7 +13,7 @@ import org.junit.jupiter.params.provider.MethodSource;
import java.util.List;
import java.util.stream.Stream;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.everyItem;
@@ -39,18 +39,14 @@ class SesBulkV2IntegrationTest {
@Order(1)
void createTemplate() {
for (String sender : SENDERS) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\": \"" + sender + "\"}")
.when()
.post("/v2/email/identities")
.then()
.statusCode(200);
}
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "v2-bulk-welcome",
@@ -70,9 +66,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(2)
void sendBulkEmail_storedTemplate_perEntryReplacement() {
String firstId = given()
.contentType("application/json")
.header("Authorization", AUTH)
String firstId = v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -113,9 +107,7 @@ class SesBulkV2IntegrationTest {
.body("BulkEmailEntryResults[1].MessageId", notNullValue())
.extract().path("BulkEmailEntryResults[0].MessageId");
String secondId = given()
.contentType("application/json")
.header("Authorization", AUTH)
String secondId = v2()
.body("""
{
"FromEmailAddress": "bulk-v2-second@floci.test",
@@ -166,9 +158,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(3)
void sendBulkEmail_inlineTemplateContent() {
String messageId = given()
.contentType("application/json")
.header("Authorization", AUTH)
String messageId = v2()
.body("""
{
"FromEmailAddress": "bulk-v2-inline@floci.test",
@@ -213,9 +203,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(4)
void sendBulkEmail_unknownTemplate_returns404() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -237,9 +225,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(5)
void sendBulkEmail_emptyEntries_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -260,9 +246,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(6)
void sendBulkEmail_missingTemplate_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -282,9 +266,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(7)
void sendBulkEmail_entriesExceeds50_returnsBadRequest() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -305,9 +287,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(10)
void sendBulkEmail_perEntryMissingVariable_mapsToInvalidParameter() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -336,9 +316,7 @@ class SesBulkV2IntegrationTest {
@MethodSource("malformedSendBulkEmailBodies")
@Order(11)
void sendBulkEmail_malformedShape_returns400(String label, String body) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-bulk-emails")
@@ -351,9 +329,7 @@ class SesBulkV2IntegrationTest {
@MethodSource("io.floci.aws.services.ses.SesV2SerializationErrors#nonObjectBodies")
@Order(12)
void sendBulkEmail_nonObjectBody_isASerializationException(String body, String message) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-bulk-emails")
@@ -367,9 +343,7 @@ class SesBulkV2IntegrationTest {
@MethodSource("wrongTypeSendBulkEmailBodies")
@Order(13)
void sendBulkEmail_wrongMemberType_returnsSerializationException(String label, String body) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-bulk-emails")
@@ -489,9 +463,7 @@ class SesBulkV2IntegrationTest {
if (i > 1) addrs.append(",");
addrs.append("\"user").append(i).append("@example.com\"");
}
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -513,9 +485,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(14)
void sendBulkEmail_fiftyEntries_sendsEachEntry() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2@floci.test",
@@ -540,9 +510,7 @@ class SesBulkV2IntegrationTest {
@MethodSource("missingEntriesMembers")
@Order(15)
void sendBulkEmail_missingEntries_isAModelViolation(String label, String entriesMember) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk@example.com",
@@ -572,9 +540,7 @@ class SesBulkV2IntegrationTest {
@MethodSource("countBeforeLookupBodies")
@Order(16)
void sendBulkEmail_entryCountIsCheckedBeforeLookups(String label, String body) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-bulk-emails")
@@ -616,9 +582,7 @@ class SesBulkV2IntegrationTest {
@MethodSource("checkedBeforeCountBodies")
@Order(17)
void sendBulkEmail_earlierChecksWinOverEntryCount(String label, String body, String message) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-bulk-emails")
@@ -646,9 +610,7 @@ class SesBulkV2IntegrationTest {
@Test
@Order(18)
void sendBulkEmail_emptyEntryBesideRecipients_failsOnlyThatEntry() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "bulk-v2-inline@floci.test",
@@ -11,6 +11,7 @@ import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
@@ -39,9 +40,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
"ed-a-updated"}) {
SnsTopicFixture.create("us-east-1", topic);
}
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"" + CS + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -52,9 +51,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(2)
void createEventDestination() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-sns",
@@ -92,9 +89,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(4)
void createEventDestination_duplicateRejected() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-sns",
@@ -116,9 +111,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(5)
void createEventDestination_unknownConfigSetReturns404() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-x",
@@ -139,9 +132,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(6)
void createEventDestination_emptyMatchingEventTypes_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-empty",
@@ -161,9 +152,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(7)
void createEventDestination_noDestination_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-nodest",
@@ -182,9 +171,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(8)
void updateEventDestination_replacesDefinition() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestination": {
@@ -216,9 +203,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(9)
void updateEventDestination_unknownReturns404() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestination": {
@@ -285,9 +270,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Test
@Order(13)
void updateEventDestination_invalidName_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestination": {
@@ -323,9 +306,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Order(15)
void updateEventDestination_preservesOrderAmongMultiple() {
String cs = "v2-cs-ed-multi";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"" + cs + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -333,9 +314,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
.statusCode(200);
for (String n : new String[]{"ed-a", "ed-b"}) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "%s",
@@ -352,9 +331,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
.statusCode(200);
}
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestination": {
@@ -387,9 +364,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Order(16)
void createEventBridgeConfigurationSet() {
String cs = "v2-cs-ed-ebus";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"" + cs + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -401,9 +376,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Order(17)
void createEventDestination_eventBridgeCustomBusRejected() {
String cs = "v2-cs-ed-ebus";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-eb-custom",
@@ -440,9 +413,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
String defaultBusArn = "arn:aws:events:us-east-1:000000000000:event-bus/default";
// Seed a destination on the default event bus.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-eb-default",
@@ -459,9 +430,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
.statusCode(200);
// An otherwise identical ARN naming a custom event bus must be rejected.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestination": {
@@ -542,9 +511,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
@Order(20)
void createEventDestination_eventBridgeBlankBusArnRejected() {
String cs = "v2-cs-ed-ebus";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-eb-blank",
@@ -577,9 +544,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
void createEventDestination_eventBridgeInvalidArnRejected(String caseName, String busArn) {
String cs = "v2-cs-ed-ebus";
String destinationName = "ed-eb-invalid-create-" + caseName;
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "%s",
@@ -622,9 +587,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
String cs = "v2-cs-ed-ebus";
String destinationName = "ed-eb-invalid-update-" + caseName;
String defaultBusArn = "arn:aws:events:us-east-1:000000000000:event-bus/default";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "%s",
@@ -641,9 +604,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
.statusCode(200);
try {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestination": {
@@ -756,25 +717,19 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
""";
String message = "SNS topic <arn:aws:sns:us-east-1:000000000000:never-created> not found.";
String set = "v2-cs-sns-check";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"" + set + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body.replace("never-created", "x"))
.when()
.post("/v2/email/configuration-sets/" + set + "/event-destinations")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/configuration-sets/" + set + "/event-destinations")
@@ -782,18 +737,14 @@ class SesConfigurationSetEventDestinationV2IntegrationTest {
.statusCode(400)
.body("__type", equalTo("BadRequestException"))
.body("message", equalTo(message));
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/configuration-sets/v2-cs-ghost/event-destinations")
.then()
.statusCode(400)
.body("message", equalTo(message));
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.put("/v2/email/configuration-sets/" + set + "/event-destinations/ed-sns")
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.anEmptyMap;
import static org.hamcrest.Matchers.equalTo;
@@ -187,13 +188,13 @@ class SesConfigurationSetMessageSecurityV2IntegrationTest {
}
private static ValidatableResponse create(String body) {
return given().contentType("application/json").header("Authorization", AUTH).body(body)
return v2().body(body)
.when().post("/v2/email/configuration-sets")
.then();
}
private static ValidatableResponse update(String body) {
return given().contentType("application/json").header("Authorization", AUTH).body(body)
return v2().body(body)
.when().post("/v2/email/update-configuration-sets")
.then();
}
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -47,9 +48,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
@Test
@Order(1)
void createConfigurationSet() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -79,9 +78,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
@Test
@Order(4)
void putSendingOptions_disableViaV2() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SendingEnabled\":false}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/sending")
@@ -189,9 +186,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
void putSendingOptions_emptyBody_treatsSendingEnabledAsFalse() {
// AWS treats an absent SendingEnabled as false: a true empty body succeeds (200) and
// disables sending (verified against real AWS). Sending is enabled here from @Order(9).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.put("/v2/email/configuration-sets/" + CS + "/sending")
.then()
@@ -211,9 +206,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
void putSendingOptions_stringSendingEnabled_coercesToTrue() {
// Real AWS coerces "yes" to true (200), matching CreateConfigurationSet. Verify the
// persisted value, not just the status — CS was disabled by @Order(12).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SendingEnabled\":\"yes\"}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/sending")
@@ -234,9 +227,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
void putSendingOptions_nullSendingEnabled_returnsSerializationException() {
// Real AWS rejects an explicit JSON null for the boolean field with SerializationException,
// matching CreateConfigurationSet's deserialization.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SendingEnabled\":null}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/sending")
@@ -248,9 +239,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
@Test
@Order(15)
void putSendingOptions_unknownConfigSet_returns404_NotFoundException() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SendingEnabled\":false}")
.when()
.put("/v2/email/configuration-sets/does-not-exist/sending")
@@ -281,9 +270,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest {
}
private static Response sendEmail(String configSet) {
return given()
.contentType("application/json")
.header("Authorization", AUTH)
return v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -12,6 +12,7 @@ import org.junit.jupiter.api.TestMethodOrder;
import java.util.List;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
@@ -46,9 +47,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Test
@Order(1)
void createConfigurationSet() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -72,9 +71,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Test
@Order(3)
void putSuppressionOptions_bounceOnly() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SuppressedReasons\":[\"BOUNCE\"]}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
@@ -98,9 +95,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Test
@Order(5)
void putSuppressionOptions_emptyList_explicitlyDisablesFiltering() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SuppressedReasons\":[]}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
@@ -119,9 +114,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Test
@Order(6)
void putSuppressionOptions_bothReasons() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SuppressedReasons\":[\"BOUNCE\",\"COMPLAINT\"]}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
@@ -142,9 +135,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
void putSuppressionOptions_invalidReason_rejected() {
// Message verified against real AWS V2 SES on 2026-06-03:
// "Reason INVALID is invalid, must be one of [BOUNCE, COMPLAINT]."
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SuppressedReasons\":[\"BOUNCE\",\"INVALID\"]}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
@@ -158,9 +149,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Test
@Order(8)
void putSuppressionOptions_nonArrayReasons_rejected() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SuppressedReasons\":\"BOUNCE\"}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
@@ -171,9 +160,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Test
@Order(9)
void putSuppressionOptions_unknownConfigSet_returns404() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SuppressedReasons\":[\"BOUNCE\"]}")
.when()
.put("/v2/email/configuration-sets/does-not-exist/suppression-options")
@@ -184,9 +171,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Test
@Order(10)
void putSuppressionOptions_omittedSuppressedReasons_treatedAsEmptyList() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
@@ -208,9 +193,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
// Start from a non-empty override so an ignored null would leave BOUNCE behind.
configSetService.putSuppressionOptions(CS, List.of("BOUNCE"), REGION);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"SuppressedReasons\":null}")
.when()
.put("/v2/email/configuration-sets/" + CS + "/suppression-options")
@@ -232,9 +215,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Order(20)
void effectiveReasons_csWithoutOverride_fallsBackToAccountLevel() {
String csNoOverride = "cs-suppression-no-override";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csNoOverride + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -252,9 +233,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Order(21)
void effectiveReasons_csWithBounceOverride_returnsBounceOnly() {
String csBounceOnly = "cs-suppression-bounce-only";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csBounceOnly + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -271,9 +250,7 @@ class SesConfigurationSetSuppressionOptionsV2IntegrationTest {
@Order(22)
void effectiveReasons_csWithEmptyOverride_explicitlyDisablesFiltering() {
String csEmpty = "cs-suppression-empty";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csEmpty + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
@@ -23,9 +24,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(1)
void createConfigurationSet() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-alpha",
@@ -41,9 +40,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(2)
void createConfigurationSet_duplicateRejected() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "v2-cs-alpha"}
""")
@@ -57,9 +54,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(4)
void createConfigurationSet_missingName() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{}")
.when()
.post("/v2/email/configuration-sets")
@@ -97,9 +92,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(7)
void listConfigurationSets() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "v2-cs-beta"}
""")
@@ -151,9 +144,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(10)
void createConfigurationSet_invalidNameCharacters() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "bad name!"}
""")
@@ -168,9 +159,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(11)
void createConfigurationSet_nameTooLong() {
String longName = "a".repeat(65);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "%s"}
""".formatted(longName))
@@ -184,9 +173,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(12)
void createConfigurationSet_tagWithMissingValue_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-tag-no-value",
@@ -205,9 +192,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(13)
void createConfigurationSet_tagWithMissingKey_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-bad-tag-key",
@@ -225,9 +210,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(14)
void createConfigurationSet_tagKeyTooLong() {
String longKey = "k".repeat(129);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-long-tag-key",
@@ -245,9 +228,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(15)
void createConfigurationSet_tagValueTooLong() {
String longValue = "v".repeat(257);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-long-tag-value",
@@ -266,9 +247,7 @@ class SesConfigurationSetV2IntegrationTest {
void listTagsForResource_returnsTagsSetAtCreation() {
// Tags supplied to CreateConfigurationSet must also be reachable through
// the ListTagsForResource endpoint, not just GET configuration-sets/{name}.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-tag-roundtrip",
@@ -301,9 +280,7 @@ class SesConfigurationSetV2IntegrationTest {
void createConfigurationSet_inlineOptions_echoedOnGet() {
// AWS echoes inline options set at create time verbatim
// (verified against real AWS SES V2 on 2026-06-12).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-inline-options",
@@ -334,9 +311,7 @@ class SesConfigurationSetV2IntegrationTest {
// constraint-style validation message on this endpoint, even for
// multiple invalid values (verified against real AWS SES V2 on
// 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-bad-reason",
@@ -368,9 +343,7 @@ class SesConfigurationSetV2IntegrationTest {
void createConfigurationSet_stringSendingEnabled_coercesToTrue() {
// AWS accepts "yes" for SendingEnabled and stores true
// (verified against real AWS SES V2 on 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-string-sending",
@@ -397,9 +370,7 @@ class SesConfigurationSetV2IntegrationTest {
// AWS treats a missing SendingEnabled member inside a present
// SendingOptions block as false, unlike a fully absent block which
// defaults to true (verified against real AWS SES V2 on 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-empty-sending",
@@ -425,9 +396,7 @@ class SesConfigurationSetV2IntegrationTest {
void createConfigurationSet_nullSendingEnabled_serializationError() {
// Explicit null fails AWS deserialization with a null message and the
// set is not created (verified against real AWS SES V2 on 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-null-sending",
@@ -452,9 +421,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(22)
void createConfigurationSet_numberSendingEnabled_serializationError() {
// Verified against real AWS SES V2 on 2026-06-13.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-number-sending",
@@ -476,9 +443,7 @@ class SesConfigurationSetV2IntegrationTest {
// present without SuppressedReasons, and the set is not created;
// reproduced faithfully (verified against real AWS SES V2 on
// 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-empty-suppression",
@@ -504,9 +469,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(24)
void createConfigurationSet_nonArraySuppressedReasons_serializationError() {
// Verified against real AWS SES V2 on 2026-06-13.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-string-reasons",
@@ -526,9 +489,7 @@ class SesConfigurationSetV2IntegrationTest {
void createConfigurationSet_emptySuppressedReasonsList_echoedOnGet() {
// An explicit empty list is stored and echoed as-is
// (verified against real AWS SES V2 on 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-empty-reasons",
@@ -556,9 +517,7 @@ class SesConfigurationSetV2IntegrationTest {
// and fails value validation with the natural-language sentence, not
// the constraint-style message used for invalid non-null values
// (verified against real AWS SES V2 on 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-null-reason",
@@ -584,9 +543,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(27)
void createConfigurationSet_booleanSuppressedReason_serializationError() {
// Verified against real AWS SES V2 on 2026-06-13.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-boolean-reason",
@@ -607,9 +564,7 @@ class SesConfigurationSetV2IntegrationTest {
// "Expected null" looks odd but is the verbatim AWS response for a
// non-object option block (verified against real AWS SES V2 on
// 2026-06-13).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-string-suppression",
@@ -623,9 +578,7 @@ class SesConfigurationSetV2IntegrationTest {
.body("__type", equalTo("SerializationException"))
.body("message", equalTo("Expected null"));
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"ConfigurationSetName": "v2-cs-string-options",
@@ -657,7 +610,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(31)
void putReputationOptions_disables_andEchoes() {
putConfigSet("v2-cs-rep");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ReputationMetricsEnabled\": false}")
.when().put("/v2/email/configuration-sets/v2-cs-rep/reputation-options")
.then().statusCode(200);
@@ -670,7 +623,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(32)
void createConfigurationSet_inlineReputation_echoed() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "v2-cs-rep-inline",
"ReputationOptions": {"ReputationMetricsEnabled": false}}
@@ -686,7 +639,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(33)
void putDeliveryOptions_echoed() {
putConfigSet("v2-cs-delivery");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TlsPolicy\": \"REQUIRE\", \"MaxDeliverySeconds\": 300}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery/delivery-options")
.then().statusCode(200);
@@ -701,7 +654,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(34)
void putDeliveryOptions_nonexistentPool_returns400() {
putConfigSet("v2-cs-delivery-pool");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TlsPolicy\": \"OPTIONAL\", \"SendingPoolName\": \"ghost-pool\"}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-pool/delivery-options")
.then().statusCode(400)
@@ -714,7 +667,7 @@ class SesConfigurationSetV2IntegrationTest {
void putArchivingOptions_validArn_echoed() {
putConfigSet("v2-cs-archiving");
String arn = "arn:aws:ses:us-east-1:123456789012:mailmanager-archive/a-abcdefghijklmnopqrstuvwx";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ArchiveArn\": \"" + arn + "\"}")
.when().put("/v2/email/configuration-sets/v2-cs-archiving/archiving-options")
.then().statusCode(200);
@@ -732,7 +685,7 @@ class SesConfigurationSetV2IntegrationTest {
// behaviour of other local AWS emulators).
String arn = "not-an-arn";
putConfigSet("v2-cs-archiving-any");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ArchiveArn\": \"" + arn + "\"}")
.when().put("/v2/email/configuration-sets/v2-cs-archiving-any/archiving-options")
.then().statusCode(200);
@@ -747,7 +700,7 @@ class SesConfigurationSetV2IntegrationTest {
void putTrackingOptions_verifiedDomain_echoed() {
SesDomainIdentityTestHelper.createVerified("track.floci.test", AUTH);
putConfigSet("v2-cs-tracking");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"track.floci.test\", \"HttpsPolicy\": \"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking/tracking-options")
.then().statusCode(200);
@@ -762,7 +715,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(38)
void putTrackingOptions_unverifiedDomain_returns400() {
putConfigSet("v2-cs-tracking-unverified");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"never-verified.example.com\", \"HttpsPolicy\": \"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-unverified/tracking-options")
.then().statusCode(400)
@@ -777,7 +730,7 @@ class SesConfigurationSetV2IntegrationTest {
// presence and verification, so the domain must be verified to reach it.
SesDomainIdentityTestHelper.createVerified("track-enum.floci.test", AUTH);
putConfigSet("v2-cs-tracking-enum");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"track-enum.floci.test\", \"HttpsPolicy\": \"BOGUS\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-enum/tracking-options")
.then().statusCode(400)
@@ -790,11 +743,11 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(100)
void putTrackingOptions_pendingDomain_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\": \"track-pending.floci.test\"}")
.when().post("/v2/email/identities").then().statusCode(200);
putConfigSet("v2-cs-tracking-pending");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"track-pending.floci.test\", \"HttpsPolicy\": \"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-pending/tracking-options")
.then().statusCode(400)
@@ -809,7 +762,7 @@ class SesConfigurationSetV2IntegrationTest {
// ReputationMetricsEnabled member as "false" (verified against real AWS
// SES V2 on 2026-06-17) — it is not required and does not error.
putConfigSet("v2-cs-rep-empty");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/configuration-sets/v2-cs-rep-empty/reputation-options")
.then().statusCode(200);
@@ -823,7 +776,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(41)
void putDeliveryOptions_invalidTlsPolicy_returns400() {
putConfigSet("v2-cs-delivery-tls");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TlsPolicy\": \"MAYBE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-tls/delivery-options")
.then().statusCode(400)
@@ -837,7 +790,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(42)
void putDeliveryOptions_nonNumericMaxDeliverySeconds_returns400() {
putConfigSet("v2-cs-delivery-max");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TlsPolicy\": \"REQUIRE\", \"MaxDeliverySeconds\": \"soon\"}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-max/delivery-options")
.then().statusCode(400)
@@ -849,7 +802,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(43)
void putTrackingOptions_nonStringHttpsPolicy_returns400() {
putConfigSet("v2-cs-tracking-type");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"HttpsPolicy\": 123}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-type/tracking-options")
.then().statusCode(400)
@@ -861,7 +814,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(44)
void putArchivingOptions_nonStringArn_returns400() {
putConfigSet("v2-cs-archiving-type");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ArchiveArn\": true}")
.when().put("/v2/email/configuration-sets/v2-cs-archiving-type/archiving-options")
.then().statusCode(400)
@@ -875,7 +828,7 @@ class SesConfigurationSetV2IntegrationTest {
// MaxDeliverySeconds is an integer; a fractional value must not be
// silently truncated.
putConfigSet("v2-cs-delivery-frac");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TlsPolicy\": \"REQUIRE\", \"MaxDeliverySeconds\": 1.5}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-frac/delivery-options")
.then().statusCode(400)
@@ -889,7 +842,7 @@ class SesConfigurationSetV2IntegrationTest {
// AWS requires CustomRedirectDomain whenever HttpsPolicy is set
// (verified against real AWS 2026-06-17); an empty body is accepted.
putConfigSet("v2-cs-tracking-nodomain");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"HttpsPolicy\": \"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-nodomain/tracking-options")
.then().statusCode(400)
@@ -903,7 +856,7 @@ class SesConfigurationSetV2IntegrationTest {
// AWS checks domain verification before the HttpsPolicy enum, so an
// unverified domain wins over an invalid enum value.
putConfigSet("v2-cs-tracking-order");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"unverified-order.example.com\", \"HttpsPolicy\": \"BOGUS\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-order/tracking-options")
.then().statusCode(400)
@@ -916,11 +869,11 @@ class SesConfigurationSetV2IntegrationTest {
void putTrackingOptions_verifiedEmailIdentityAsDomain_returns400() {
// CustomRedirectDomain must be a verified *domain* identity; a verified
// email-address identity does not qualify.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\": \"redirect@floci.test\"}")
.when().post("/v2/email/identities").then().statusCode(200);
putConfigSet("v2-cs-tracking-email-id");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"redirect@floci.test\", \"HttpsPolicy\": \"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-email-id/tracking-options")
.then().statusCode(400)
@@ -935,7 +888,7 @@ class SesConfigurationSetV2IntegrationTest {
// storing it (verified against real AWS 2026-06-17), even with no
// HttpsPolicy set.
putConfigSet("v2-cs-tracking-blank");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \" \"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-blank/tracking-options")
.then().statusCode(400)
@@ -948,7 +901,7 @@ class SesConfigurationSetV2IntegrationTest {
void putTrackingOptions_unverifiedDomainWithoutHttpsPolicy_returns400() {
// AWS verifies CustomRedirectDomain even when HttpsPolicy is omitted.
putConfigSet("v2-cs-tracking-nopolicy");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"never-verified-nopolicy.example.com\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-nopolicy/tracking-options")
.then().statusCode(400)
@@ -963,14 +916,14 @@ class SesConfigurationSetV2IntegrationTest {
// empty block that GetConfigurationSet would echo as {}.
SesDomainIdentityTestHelper.createVerified("clear.floci.test", AUTH);
putConfigSet("v2-cs-tracking-clear");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"CustomRedirectDomain\": \"clear.floci.test\", \"HttpsPolicy\": \"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-clear/tracking-options")
.then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/v2-cs-tracking-clear")
.then().statusCode(200).body("TrackingOptions.HttpsPolicy", equalTo("REQUIRE"));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/configuration-sets/v2-cs-tracking-clear/tracking-options")
.then().statusCode(200);
@@ -983,14 +936,14 @@ class SesConfigurationSetV2IntegrationTest {
@Order(52)
void putDeliveryOptions_emptyBody_clears() {
putConfigSet("v2-cs-delivery-clear");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TlsPolicy\": \"REQUIRE\"}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-clear/delivery-options")
.then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/v2-cs-delivery-clear")
.then().statusCode(200).body("DeliveryOptions.TlsPolicy", equalTo("REQUIRE"));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-clear/delivery-options")
.then().statusCode(200);
@@ -1005,7 +958,7 @@ class SesConfigurationSetV2IntegrationTest {
// AWS rejects a blank SendingPoolName with a distinct message (verified
// against real AWS 2026-06-17), separate from the non-existent-pool case.
putConfigSet("v2-cs-delivery-blankpool");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"SendingPoolName\": \" \"}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-blankpool/delivery-options")
.then().statusCode(400)
@@ -1017,7 +970,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(54)
void putDeliveryOptions_maxDeliverySecondsBelowMinimum_returns400() {
putConfigSet("v2-cs-delivery-min");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"MaxDeliverySeconds\": 5}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-min/delivery-options")
.then().statusCode(400)
@@ -1031,7 +984,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(55)
void putDeliveryOptions_maxDeliverySecondsAboveMaximum_returns400() {
putConfigSet("v2-cs-delivery-overmax");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"MaxDeliverySeconds\": 999999}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-overmax/delivery-options")
.then().statusCode(400)
@@ -1045,7 +998,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(56)
void putVdmOptions_echoed() {
putConfigSet("v2-cs-vdm");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"ENABLED\"}, "
+ "\"GuardianOptions\": {\"OptimizedSharedDelivery\": \"DISABLED\"}}}")
.when().put("/v2/email/configuration-sets/v2-cs-vdm/vdm-options")
@@ -1061,7 +1014,7 @@ class SesConfigurationSetV2IntegrationTest {
@Order(57)
void putVdmOptions_invalidEngagementMetrics_returns400() {
putConfigSet("v2-cs-vdm-bad");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"NONSENSE\"}}}")
.when().put("/v2/email/configuration-sets/v2-cs-vdm-bad/vdm-options")
.then().statusCode(400)
@@ -1074,7 +1027,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(58)
void createConfigurationSet_inlineVdm_echoed() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"v2-cs-vdm-inline\", "
+ "\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"DISABLED\"}}}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
@@ -1088,14 +1041,14 @@ class SesConfigurationSetV2IntegrationTest {
@Order(59)
void putVdmOptions_emptyBody_clears() {
putConfigSet("v2-cs-vdm-clear");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"ENABLED\"}}}")
.when().put("/v2/email/configuration-sets/v2-cs-vdm-clear/vdm-options")
.then().statusCode(200);
given().header("Authorization", AUTH)
.when().get("/v2/email/configuration-sets/v2-cs-vdm-clear")
.then().statusCode(200).body("VdmOptions.DashboardOptions.EngagementMetrics", equalTo("ENABLED"));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/configuration-sets/v2-cs-vdm-clear/vdm-options")
.then().statusCode(200);
@@ -1107,7 +1060,7 @@ class SesConfigurationSetV2IntegrationTest {
@Test
@Order(60)
void createConfigurationSet_invalidInlineVdm_returns400_andDoesNotCreate() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"v2-cs-vdm-inline-bad\", "
+ "\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"NONSENSE\"}}}")
.when().post("/v2/email/configuration-sets")
@@ -1130,11 +1083,11 @@ class SesConfigurationSetV2IntegrationTest {
// A SendingPoolName that refers to a dedicated IP pool created via
// CreateDedicatedIpPool is accepted and echoed (verified against real
// AWS 2026-06-18).
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": \"v2-cs-pool-ref\"}")
.when().post("/v2/email/dedicated-ip-pools").then().statusCode(200);
putConfigSet("v2-cs-delivery-poolref");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TlsPolicy\": \"REQUIRE\", \"SendingPoolName\": \"v2-cs-pool-ref\"}")
.when().put("/v2/email/configuration-sets/v2-cs-delivery-poolref/delivery-options")
.then().statusCode(200);
@@ -1150,7 +1103,7 @@ class SesConfigurationSetV2IntegrationTest {
// AWS restJson1 rejects a non-string tag member with SerializationException rather than
// coercing it (probe-confirmed: a numeric Key returns "NUMBER_VALUE can not be converted to a
// String"). Floci matches the type/status; its error body uses __type (project-wide).
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"v2-cs-nonstr-key\", \"Tags\": [{\"Key\": 123, \"Value\": \"v\"}]}")
.when().post("/v2/email/configuration-sets")
.then().statusCode(400).body("__type", equalTo("SerializationException"));
@@ -1160,12 +1113,12 @@ class SesConfigurationSetV2IntegrationTest {
@Order(63)
void createConfigurationSet_nonStringTagValue_returnsSerializationException() {
// A boolean value and an object value are both non-string members and rejected the same way.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"v2-cs-nonstr-val\", \"Tags\": [{\"Key\": \"k\", \"Value\": true}]}")
.when().post("/v2/email/configuration-sets")
.then().statusCode(400).body("__type", equalTo("SerializationException"));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"v2-cs-nonstr-obj\", \"Tags\": [{\"Key\": \"k\", \"Value\": {\"x\": 1}}]}")
.when().post("/v2/email/configuration-sets")
.then().statusCode(400).body("__type", equalTo("SerializationException"));
@@ -1179,7 +1132,7 @@ class SesConfigurationSetV2IntegrationTest {
// for a null element (a server-side bug); Floci normalizes all of them to 400
// SerializationException. Probe-confirmed against real AWS.
for (String badElement : new String[] {"true", "123", "\"k\"", "[\"k\",\"v\"]", "null"}) {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"v2-cs-bad-el\", \"Tags\": [" + badElement + "]}")
.when().post("/v2/email/configuration-sets")
.then().statusCode(400).body("__type", equalTo("SerializationException"));
@@ -1187,7 +1140,7 @@ class SesConfigurationSetV2IntegrationTest {
}
private static void putConfigSet(String name) {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\": \"" + name + "\"}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
}
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.DECIMAL_NUMBERS;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis;
import static io.restassured.RestAssured.given;
@@ -41,9 +42,7 @@ class SesContactListV2IntegrationTest {
@Test
@Order(1)
void createContactList() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(CREATE_BODY)
.when()
.post("/v2/email/contact-lists")
@@ -88,9 +87,7 @@ class SesContactListV2IntegrationTest {
@Test
@Order(4)
void createSecondContactList_rejectedByPerAccountLimit() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ContactListName\":\"second-list\"}")
.when()
.post("/v2/email/contact-lists")
@@ -105,9 +102,7 @@ class SesContactListV2IntegrationTest {
void createDuplicateName_alsoHitsPerAccountLimit() {
// A duplicate name hits the one-list-per-account limit before any "already exists" check,
// so AWS never returns AlreadyExistsException here.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ContactListName\":\"" + LIST + "\"}")
.when()
.post("/v2/email/contact-lists")
@@ -120,9 +115,7 @@ class SesContactListV2IntegrationTest {
@Test
@Order(6)
void createContactList_invalidTopicStatus_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ContactListName\":\"bad-list\",\"Topics\":["
+ "{\"TopicName\":\"t\",\"DisplayName\":\"T\","
+ "\"DefaultSubscriptionStatus\":\"MAYBE\"}]}")
@@ -139,9 +132,7 @@ class SesContactListV2IntegrationTest {
@Test
@Order(7)
void updateContactList_replacesTopicsAndDescription() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"Description\":\"updated\",\"Topics\":["
+ "{\"TopicName\":\"monthly\",\"DisplayName\":\"Monthly\","
+ "\"DefaultSubscriptionStatus\":\"OPT_IN\"}]}")
@@ -161,9 +152,7 @@ class SesContactListV2IntegrationTest {
.body("Topics[0].TopicName", equalTo("monthly"));
// An explicit-null Topics is treated as "not provided" and preserves existing topics.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"Topics\":null,\"Description\":\"kept-topics\"}")
.when()
.put("/v2/email/contact-lists/" + LIST)
@@ -181,9 +170,7 @@ class SesContactListV2IntegrationTest {
.body("Topics[0].TopicName", equalTo("monthly"));
// An empty body is accepted as a no-op update (200), matching real AWS.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.put("/v2/email/contact-lists/" + LIST)
.then()
@@ -206,9 +193,7 @@ class SesContactListV2IntegrationTest {
@Test
@Order(9)
void updateContactList_unknown_returns404() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"Description\":\"x\"}")
.when()
.put("/v2/email/contact-lists/does-not-exist")
@@ -243,9 +228,7 @@ class SesContactListV2IntegrationTest {
.body("ContactLists", hasSize(0));
// The single-list slot is freed, so a new list can be created.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ContactListName\":\"fresh-list\"}")
.when()
.post("/v2/email/contact-lists")
@@ -263,9 +246,7 @@ class SesContactListV2IntegrationTest {
@Test
@Order(11)
void createContactList_missingName_returnsSmithyValidationError() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{}")
.when()
.post("/v2/email/contact-lists")
@@ -279,9 +260,7 @@ class SesContactListV2IntegrationTest {
@Test
@Order(12)
void createContactList_topicMissingTopicName_returnsSmithyValidationError() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ContactListName\":\"x\",\"Topics\":["
+ "{\"DisplayName\":\"T\",\"DefaultSubscriptionStatus\":\"OPT_IN\"}]}")
.when()
@@ -420,9 +399,7 @@ class SesContactListV2IntegrationTest {
@Order(24)
void updateContactList_invalidNameAndInvalidTopicEnum_reportsSmithyEnumFirst() {
// Same two-phase order on update: the Smithy enum error wins over the invalid path name.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"Topics\":[{\"TopicName\":\"t\",\"DisplayName\":\"T\","
+ "\"DefaultSubscriptionStatus\":\"MAYBE\"}]}")
.when()
@@ -446,9 +423,7 @@ class SesContactListV2IntegrationTest {
}
private static Response post(String body) {
return given()
.contentType("application/json")
.header("Authorization", AUTH)
return v2()
.body(body)
.when()
.post("/v2/email/contact-lists");
@@ -9,6 +9,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.DECIMAL_NUMBERS;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis;
import static io.restassured.RestAssured.given;
@@ -30,14 +31,14 @@ class SesContactV2IntegrationTest {
private static final String CONTACTS = "/v2/email/contact-lists/" + LIST + "/contacts";
private static Response post(String path, String body) {
return given().contentType("application/json").header("Authorization", AUTH)
return v2()
.body(body).when().post(path);
}
@Test
@Order(1)
void setup_createContactList() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ContactListName\":\"" + LIST + "\",\"Topics\":["
+ "{\"TopicName\":\"weekly\",\"DisplayName\":\"Weekly\",\"DefaultSubscriptionStatus\":\"OPT_IN\"},"
+ "{\"TopicName\":\"promos\",\"DisplayName\":\"Promos\",\"DefaultSubscriptionStatus\":\"OPT_OUT\"}]}")
@@ -145,7 +146,7 @@ class SesContactV2IntegrationTest {
@Test
@Order(11)
void updateContact_unsubscribeAll_replacesAttributesKeepsPreferences() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"UnsubscribeAll\":true}")
.when().put(CONTACTS + "/" + EMAIL).then().statusCode(200);
@@ -162,7 +163,7 @@ class SesContactV2IntegrationTest {
@Test
@Order(12)
void updateContact_topicPreferences_mergeByTopicName() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TopicPreferences\":[{\"TopicName\":\"promos\",\"SubscriptionStatus\":\"OPT_IN\"}]}")
.when().put(CONTACTS + "/" + EMAIL).then().statusCode(200);
@@ -216,13 +217,13 @@ class SesContactV2IntegrationTest {
post(CONTACTS, "{\"EmailAddress\":\"carol@example.com\"}").then().statusCode(200);
given().header("Authorization", AUTH)
.when().delete("/v2/email/contact-lists/" + LIST).then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ContactListName\":\"" + LIST + "\",\"Topics\":["
+ "{\"TopicName\":\"weekly\",\"DisplayName\":\"Weekly\","
+ "\"DefaultSubscriptionStatus\":\"OPT_IN\"}]}")
.when().post("/v2/email/contact-lists").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH).body("{}")
v2().body("{}")
.when().post(CONTACTS + "/list")
.then().statusCode(200).body("Contacts", hasSize(0));
}
@@ -258,7 +259,7 @@ class SesContactV2IntegrationTest {
@Test
@Order(20)
void listContacts_nonObjectBody_returns400() {
given().contentType("application/json").header("Authorization", AUTH).body("[]")
v2().body("[]")
.when().post(CONTACTS + "/list")
.then().statusCode(400)
.body("__type", equalTo("SerializationException"))
@@ -305,7 +306,7 @@ class SesContactV2IntegrationTest {
.when().get(CONTACTS + "/type-d@example.com")
.then().statusCode(200).body("UnsubscribeAll", equalTo(true));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"UnsubscribeAll\":\"no\"}")
.when().put(CONTACTS + "/type-d@example.com")
.then().statusCode(200);
@@ -322,7 +323,7 @@ class SesContactV2IntegrationTest {
@Test
@Order(25)
void updateContact_attributesDataNumber_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"AttributesData\":123}")
.when().put(CONTACTS + "/" + EMAIL)
.then().statusCode(400)
@@ -375,7 +376,7 @@ class SesContactV2IntegrationTest {
.then().statusCode(404)
.body("__type", equalTo("NotFoundException"));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"UnsubscribeAll\":true}")
.when().put(CONTACTS + "/bob@example.com")
.then().statusCode(404)
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
@@ -44,7 +45,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
@Test
@Order(0)
void setup_verifyFromIdentity() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + FROM + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
}
@@ -52,7 +53,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
@Test
@Order(1)
void createThenGet() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body(body(NAME, FROM, "Verify your email", "https://example.com/ok"))
.when().post(BASE).then().statusCode(200);
@@ -81,7 +82,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
@Test
@Order(3)
void createDuplicate_throwsAlreadyExists() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body(body(NAME, FROM, "x", "https://example.com/ok"))
.when().post(BASE).then().statusCode(400)
.body("__type", equalTo("AlreadyExistsException"))
@@ -101,7 +102,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
@Test
@Order(5)
void update_replaces() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body(body(NAME, FROM, "Updated subject", "https://example.com/ok2"))
.when().put(BASE + "/" + NAME).then().statusCode(200);
@@ -115,7 +116,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
@Test
@Order(6)
void updateMissing_throwsNotFound() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body(body("nope", FROM, "x", "https://example.com/ok"))
.when().put(BASE + "/nope").then().statusCode(404)
.body("__type", equalTo("NotFoundException"))
@@ -143,7 +144,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
@Test
@Order(9)
void createWithUnverifiedFrom_throwsNotFound() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body(body("cvet-unverified", "nobody@unverified.test", "x", "https://example.com/ok"))
.when().post(BASE).then().statusCode(404)
.body("__type", equalTo("NotFoundException"))
@@ -153,7 +154,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
@Test
@Order(10)
void createWithInvalidRedirectUrl_throwsBadRequest() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body(body("cvet-badurl", FROM, "x", "not-a-url"))
.when().post(BASE).then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -166,7 +167,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
// The signature comes from the scanner so it never appears in test source; the JSON needs
// its one backslash escaped.
String content = SesTestSignature.value().replace("\\", "\\\\");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{"TemplateName": "cvet-v2-scan", "FromEmailAddress": "%s", "TemplateSubject": "scan",
"TemplateContent": "<p>%s</p>",
@@ -177,7 +178,7 @@ class SesCustomVerificationEmailTemplateV2IntegrationTest {
// Sending registers the recipient as a pending identity in the shared region, so it is
// removed again below; a domain other tests assert on must not be used here.
String messageId = given().contentType("application/json").header("Authorization", AUTH)
String messageId = v2()
.body("{\"EmailAddress\":\"scan-target@cvet-scan.floci.test\",\"TemplateName\":\"cvet-v2-scan\"}")
.when().post("/v2/email/outbound-custom-verification-emails").then().statusCode(200)
.extract().jsonPath().getString("MessageId");
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
@@ -22,7 +23,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
@Test
@Order(1)
void createDedicatedIpPool_defaultScalingMode() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": \"v2-pool-alpha\"}")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(200);
@@ -38,7 +39,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
@Test
@Order(2)
void createDedicatedIpPool_managedScalingMode() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": \"v2-pool-managed\", \"ScalingMode\": \"MANAGED\"}")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(200);
@@ -52,7 +53,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
@Test
@Order(3)
void createDedicatedIpPool_invalidScalingMode_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": \"v2-pool-bad\", \"ScalingMode\": \"NONSENSE\"}")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(400)
@@ -63,7 +64,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
@Test
@Order(4)
void createDedicatedIpPool_duplicate_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": \"v2-pool-alpha\"}")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(400)
@@ -116,7 +117,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
@Test
@Order(9)
void createDedicatedIpPool_emptyBody_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(400)
@@ -127,7 +128,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
@Test
@Order(10)
void createDedicatedIpPool_missingPoolName_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(400)
@@ -138,7 +139,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
@Test
@Order(11)
void createDedicatedIpPool_nullPoolName_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": null}")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(400)
@@ -151,7 +152,7 @@ class SesDedicatedIpPoolV2IntegrationTest {
void createDedicatedIpPool_nonTextualScalingMode_returns400() {
// A present-but-non-string ScalingMode must be rejected, not coerced to
// "" and silently defaulted to STANDARD.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": \"v2-pool-objsm\", \"ScalingMode\": {}}")
.when().post("/v2/email/dedicated-ip-pools")
.then().statusCode(400)
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
@@ -46,10 +47,10 @@ class SesDedicatedIpV2IntegrationTest {
@Order(3)
void putDedicatedIpInPool_ipNotFound() {
// Even with an existing destination pool, the IP is checked first.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"PoolName\": \"dip-scaling-pool\"}")
.when().post("/v2/email/dedicated-ip-pools").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"DestinationPoolName\": \"dip-scaling-pool\"}")
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/pool")
.then().statusCode(404)
@@ -60,7 +61,7 @@ class SesDedicatedIpV2IntegrationTest {
@Test
@Order(4)
void putDedicatedIpWarmupAttributes_ipNotFound() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"WarmupPercentage\": 50}")
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
.then().statusCode(404)
@@ -72,7 +73,7 @@ class SesDedicatedIpV2IntegrationTest {
@Order(5)
void putDedicatedIpPoolScalingAttributes_updatesPool() {
// The pool from Order 3 starts STANDARD; switch it to MANAGED.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ScalingMode\": \"MANAGED\"}")
.when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling")
.then().statusCode(200);
@@ -85,7 +86,7 @@ class SesDedicatedIpV2IntegrationTest {
@Test
@Order(6)
void putDedicatedIpPoolScalingAttributes_invalidMode_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ScalingMode\": \"NONSENSE\"}")
.when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling")
.then().statusCode(400)
@@ -96,7 +97,7 @@ class SesDedicatedIpV2IntegrationTest {
@Test
@Order(7)
void putDedicatedIpPoolScalingAttributes_unknownPool_returns404() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ScalingMode\": \"STANDARD\"}")
.when().put("/v2/email/dedicated-ip-pools/dip-ghost-pool/scaling")
.then().statusCode(404)
@@ -112,7 +113,7 @@ class SesDedicatedIpV2IntegrationTest {
.then().statusCode(200)
.body("DedicatedIpAutoWarmupEnabled", equalTo(true));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"AutoWarmupEnabled\": false}")
.when().put("/v2/email/account/dedicated-ips/warmup")
.then().statusCode(200);
@@ -127,7 +128,7 @@ class SesDedicatedIpV2IntegrationTest {
@Order(9)
void putDedicatedIpInPool_missingDestinationPoolName_returns400() {
// A missing required member is validated before the IP lookup.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/pool")
.then().statusCode(400)
@@ -140,7 +141,7 @@ class SesDedicatedIpV2IntegrationTest {
void putDedicatedIpPoolScalingAttributes_missingModeUnknownPool_returns400() {
// ScalingMode is validated before the pool-existence check, so a missing mode on an
// unknown pool is a BadRequestException, not NotFoundException.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/dedicated-ip-pools/dip-ghost-pool/scaling")
.then().statusCode(400)
@@ -152,7 +153,7 @@ class SesDedicatedIpV2IntegrationTest {
@Order(11)
void putDedicatedIpPoolScalingAttributes_managedToStandard_returns400() {
// dip-scaling-pool was switched to MANAGED in Order 5; AWS forbids downgrading to STANDARD.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ScalingMode\": \"STANDARD\"}")
.when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling")
.then().statusCode(400)
@@ -163,7 +164,7 @@ class SesDedicatedIpV2IntegrationTest {
@Test
@Order(12)
void putDedicatedIpWarmupAttributes_missingPercentage_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
.then().statusCode(400)
@@ -174,7 +175,7 @@ class SesDedicatedIpV2IntegrationTest {
@Test
@Order(13)
void putDedicatedIpWarmupAttributes_outOfRange_returns400() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"WarmupPercentage\": 150}")
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
.then().statusCode(400)
@@ -185,7 +186,7 @@ class SesDedicatedIpV2IntegrationTest {
@Test
@Order(14)
void putDedicatedIpWarmupAttributes_nonInteger_returnsSerializationException() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"WarmupPercentage\": \"abc\"}")
.when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup")
.then().statusCode(400)
@@ -196,7 +197,7 @@ class SesDedicatedIpV2IntegrationTest {
@Order(15)
void putAccountAutoWarmup_stringCoercesByText() {
// SES v2 coerces a JSON string only when it names a boolean.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"AutoWarmupEnabled\": \"no\"}")
.when().put("/v2/email/account/dedicated-ips/warmup")
.then().statusCode(200);
@@ -205,7 +206,7 @@ class SesDedicatedIpV2IntegrationTest {
.then().statusCode(200)
.body("DedicatedIpAutoWarmupEnabled", equalTo(false));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"AutoWarmupEnabled\": \"yes\"}")
.when().put("/v2/email/account/dedicated-ips/warmup")
.then().statusCode(200);
@@ -214,7 +215,7 @@ class SesDedicatedIpV2IntegrationTest {
.then().statusCode(200)
.body("DedicatedIpAutoWarmupEnabled", equalTo(true));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"AutoWarmupEnabled\": \"nonsense\"}")
.when().put("/v2/email/account/dedicated-ips/warmup")
.then().statusCode(400)
@@ -226,7 +227,7 @@ class SesDedicatedIpV2IntegrationTest {
@Order(16)
void putAccountAutoWarmup_explicitNull_returnsSerializationException() {
// Only an omitted member falls back to the @default(false); an explicit null does not.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"AutoWarmupEnabled\": null}")
.when().put("/v2/email/account/dedicated-ips/warmup")
.then().statusCode(400)
@@ -236,7 +237,7 @@ class SesDedicatedIpV2IntegrationTest {
@Test
@Order(17)
void putAccountAutoWarmup_number_returnsSerializationException() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"AutoWarmupEnabled\": 1}")
.when().put("/v2/email/account/dedicated-ips/warmup")
.then().statusCode(400)
@@ -18,6 +18,7 @@ import java.util.Base64;
import java.util.List;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -57,11 +58,11 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Test
@Order(1)
void setup_identity_configSet_snsEventDestination() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + IDENTITY + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
@@ -88,7 +89,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
.body("{\"TopicArn\":\"" + topicArn + "\",\"Protocol\":\"sqs\",\"Endpoint\":\"" + queueArn + "\"}")
.when().post("/").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-sns",
@@ -106,7 +107,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Test
@Order(2)
void putEmailIdentityConfigurationSet_associatesAndSurfacesInGet() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(200);
@@ -122,7 +123,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
void sendWithoutConfigSet_routesThroughIdentityDefault_publishesEvent() throws Exception {
drainQueue();
// No ConfigurationSetName on the send — it must resolve to the identity's default.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -144,7 +145,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Test
@Order(4)
void clearConfigurationSet_removesAssociation() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{}")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(200);
@@ -159,7 +160,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Order(5)
void sendRawContentWithoutConfigSet_routesThroughIdentityDefault() throws Exception {
// Re-associate (Order 4 cleared it) so this test is self-contained.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(200);
@@ -171,7 +172,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
String rawB64 = Base64.getEncoder().encodeToString(raw.getBytes(StandardCharsets.UTF_8));
// SendEmail with Raw content and no ConfigurationSetName must route through the
// identity's default, just like the Simple-content path.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -192,7 +193,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Test
@Order(6)
void unknownIdentity_returns404() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when().put("/v2/email/identities/cs-attr-ghost@floci.test/configuration-set")
.then().statusCode(404)
@@ -202,7 +203,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Test
@Order(7)
void unknownConfigurationSet_returns404() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"cs-attr-missing\"}")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(404)
@@ -213,7 +214,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Order(8)
void sendRawContentWithoutFromAddress_routesThroughIdentityDefault() throws Exception {
// Re-associate so this test is self-contained.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(200);
@@ -225,7 +226,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
+ "To: bounce@simulator.amazonses.com\r\n"
+ "Subject: cs-attr-raw-nofrom\r\n\r\nbody";
String rawB64 = Base64.getEncoder().encodeToString(raw.getBytes(StandardCharsets.UTF_8));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"Destination": {"ToAddresses": ["bounce@simulator.amazonses.com"]},
@@ -247,18 +248,18 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Order(9)
void putConfigurationSet_whitespaceOnlyOrArrayBody_returnsSerializationExceptionAndKeepsAssociation() {
// Re-associate so we can confirm a whitespace-only body does NOT clear.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(200);
// A whitespace-only body is a serialization error on real AWS, not a silent clear.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body(" \n")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(400)
.body("__type", equalTo("SerializationException"));
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("[]")
.when().put("/v2/email/identities/" + IDENTITY + "/configuration-set")
.then().statusCode(400)
@@ -279,13 +280,13 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
// identity's default, then sending through that identity, fails with a bad-request error.
String id = "cs-attr-stale@floci.test";
String cs = "cs-attr-stale-cs";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + id + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + cs + "\"}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + cs + "\"}")
.when().put("/v2/email/identities/" + id + "/configuration-set").then().statusCode(200);
@@ -294,7 +295,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
.when().delete("/v2/email/configuration-sets/" + cs).then().statusCode(200);
// A send with no explicit ConfigurationSetName must fail rather than silently drop it.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -312,12 +313,12 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
void createEmailIdentity_withConfigurationSet_surfacesInGet() {
String cs = "cs-attr-oncreate-cs";
String id = "cs-attr-oncreate@floci.test";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + cs + "\"}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
// CreateEmailIdentity accepts a ConfigurationSetName and sets it as the identity default.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\"" + cs + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
@@ -330,7 +331,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Order(12)
void createEmailIdentity_withMissingConfigurationSet_returns404AndDoesNotCreate() {
String id = "cs-attr-oncreate-missing@floci.test";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\"cs-attr-ghost-oncreate\"}")
.when().post("/v2/email/identities").then().statusCode(404)
.body("__type", equalTo("NotFoundException"))
@@ -345,7 +346,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Order(17)
void createEmailIdentity_withNonArrayTags_returns400AndDoesNotCreate() {
String id = "cs-attr-oncreate-badtags@floci.test";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + id + "\",\"Tags\":\"oops\"}")
.when().post("/v2/email/identities").then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -360,7 +361,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
@Order(13)
void createEmailIdentity_withNonStringConfigurationSet_returns400() {
// ConfigurationSetName is a string; a non-string must be rejected, not coerced.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"cs-attr-badtype@floci.test\",\"ConfigurationSetName\":123}")
.when().post("/v2/email/identities").then().statusCode(400)
.body("__type", equalTo("SerializationException"));
@@ -376,7 +377,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
// deviation from AWS, which stores "" verbatim and echoes it back; Floci keeps the two paths
// aligned instead.
String id = "cs-attr-emptycs@floci.test";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\"\"}")
.when().post("/v2/email/identities").then().statusCode(200);
given().header("Authorization", AUTH)
@@ -390,7 +391,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
// A whitespace-only name is not "absent": it flows through name validation and is rejected
// as invalid input (the same 400 the Put path yields), rather than being silently ignored.
String id = "cs-attr-wscs@floci.test";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\" \"}")
.when().post("/v2/email/identities").then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -404,7 +405,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest {
void createEmailIdentity_withNonStringEmailIdentity_returns400() {
// EmailIdentity is a string; a non-string must be rejected (not coerced into "123"), the same
// as a non-string ConfigurationSetName.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":123}")
.when().post("/v2/email/identities").then().statusCode(400)
.body("__type", equalTo("SerializationException"));
@@ -25,6 +25,7 @@ import java.util.Base64;
import java.util.List;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasKey;
@@ -152,27 +153,21 @@ class SesEventPublishingV2IntegrationTest {
@Test
@Order(2)
void setupSesIdentityConfigSetAndEventDestination() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + SENDER + "\"}")
.when()
.post("/v2/email/identities")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-sns",
@@ -282,18 +277,14 @@ class SesEventPublishingV2IntegrationTest {
@Order(7)
void disabledEventDestination_skipsPublish() throws Exception {
String csDisabled = "v2-cs-ed-disabled";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-sns-disabled",
@@ -311,9 +302,7 @@ class SesEventPublishingV2IntegrationTest {
drainQueue();
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -340,9 +329,7 @@ class SesEventPublishingV2IntegrationTest {
@Order(8)
void mixedRecipients_filterBouncedRecipientsToSimulatorOnly() throws Exception {
drainQueue();
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -380,9 +367,7 @@ class SesEventPublishingV2IntegrationTest {
@Order(9)
void sendEmail_emailTagsPropagateIntoMailTags() throws Exception {
drainQueue();
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -452,9 +437,7 @@ class SesEventPublishingV2IntegrationTest {
@Order(11)
void sendEmail_simpleHeadersAppearInEventMailHeaders() throws Exception {
drainQueue();
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -502,9 +485,7 @@ class SesEventPublishingV2IntegrationTest {
void sendToSuppressedAddress_withBounceReason_publishesSyntheticBounceEvent() throws Exception {
String suppressed = "bounce-suppressed-" + System.nanoTime() + "@example.com";
// Pre-register the address in the account-level suppression list with reason BOUNCE.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + suppressed + "\",\"Reason\":\"BOUNCE\"}")
.when()
.put("/v2/email/suppression/addresses")
@@ -513,9 +494,7 @@ class SesEventPublishingV2IntegrationTest {
try {
drainQueue();
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -576,18 +555,14 @@ class SesEventPublishingV2IntegrationTest {
.extract().jsonPath().getString("DeliveryStreamARN");
assertNotNull(firehoseStreamArn);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS_FIREHOSE + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-firehose",
@@ -611,9 +586,7 @@ class SesEventPublishingV2IntegrationTest {
@Order(13)
void sendToSuppressedAddress_withComplaintReason_publishesSyntheticComplaintEvent() throws Exception {
String suppressed = "complaint-suppressed-" + System.nanoTime() + "@example.com";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + suppressed + "\",\"Reason\":\"COMPLAINT\"}")
.when()
.put("/v2/email/suppression/addresses")
@@ -622,9 +595,7 @@ class SesEventPublishingV2IntegrationTest {
try {
drainQueue();
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -710,18 +681,14 @@ class SesEventPublishingV2IntegrationTest {
.statusCode(200)
.extract().jsonPath().getString("DeliveryStreamARN");
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-firehose-disabled",
@@ -756,18 +723,14 @@ class SesEventPublishingV2IntegrationTest {
String bogusStreamArn =
"arn:aws:firehose:us-east-1:000000000000:deliverystream/does-not-exist";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csUnknown + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-firehose-unknown",
@@ -846,18 +809,14 @@ class SesEventPublishingV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS_EB + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-eventbridge",
@@ -922,18 +881,14 @@ class SesEventPublishingV2IntegrationTest {
@Order(21)
void eventBridge_disabledEventDestination_skipsPublish() throws Exception {
String csDisabled = "ses-events-eb-cs-disabled";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-eventbridge-disabled",
@@ -964,9 +919,7 @@ class SesEventPublishingV2IntegrationTest {
String bogusBusArn =
"arn:aws:events:us-east-1:000000000000:event-bus/does-not-exist";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csUnknown + "\"}")
.when()
.post("/v2/email/configuration-sets")
@@ -975,9 +928,7 @@ class SesEventPublishingV2IntegrationTest {
// SES only supports the account default event bus, so a custom bus ARN is
// rejected at create time and never stored.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-eventbridge-unknown",
@@ -1008,18 +959,14 @@ class SesEventPublishingV2IntegrationTest {
@Test
@Order(23)
void cloudWatch_setupConfigSetAndEventDestination() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS_CW + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-cloudwatch",
@@ -1057,9 +1004,7 @@ class SesEventPublishingV2IntegrationTest {
@Test
@Order(24)
void cloudWatch_sendWithTagsAndHeaders_registersSendMetricWithResolvedDimensions() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -1100,9 +1045,7 @@ class SesEventPublishingV2IntegrationTest {
@Test
@Order(25)
void cloudWatch_sendWithoutTags_fallsBackToDefaultDimensionValue() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -1131,9 +1074,7 @@ class SesEventPublishingV2IntegrationTest {
@Test
@Order(26)
void cloudWatch_successSimulator_registersBothSendAndDeliveryMetrics() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -1163,18 +1104,14 @@ class SesEventPublishingV2IntegrationTest {
@Order(27)
void cloudWatch_disabledEventDestination_doesNotPublishMetric() {
String csDisabled = "ses-events-cw-cs-disabled";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-cloudwatch-disabled",
@@ -1198,9 +1135,7 @@ class SesEventPublishingV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -1443,18 +1378,14 @@ class SesEventPublishingV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + csName + "\"}")
.when()
.post("/v2/email/configuration-sets")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EventDestinationName": "ed-eventbridge-detail",
@@ -1512,9 +1443,7 @@ class SesEventPublishingV2IntegrationTest {
}
private void sendEmailToConfigSet(String configSet, String to, String subject) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -1630,12 +1559,12 @@ class SesEventPublishingV2IntegrationTest {
@Order(33)
void simulatorAndSuppressedBounces_arePublishedAsSeparateEvents() throws Exception {
String suppressed = "split-suppressed-" + System.nanoTime() + "@example.com";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + suppressed + "\",\"Reason\":\"BOUNCE\"}")
.when().put("/v2/email/suppression/addresses").then().statusCode(200);
try {
drainQueue();
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -1682,7 +1611,7 @@ class SesEventPublishingV2IntegrationTest {
String rawB64 = Base64.getEncoder().encodeToString(
mime.getBytes(StandardCharsets.UTF_8));
drainQueue();
String messageId = given().contentType("application/json").header("Authorization", AUTH)
String messageId = v2()
.body("""
{"FromEmailAddress": "%s",
"Destination": {"ToAddresses": ["success@simulator.amazonses.com"]},
@@ -1720,7 +1649,7 @@ class SesEventPublishingV2IntegrationTest {
// The request's own tags, validated by the controller, stay on both events.
drainQueue();
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{"FromEmailAddress": "%s",
"Destination": {"ToAddresses": ["success@simulator.amazonses.com"]},
@@ -1752,7 +1681,7 @@ class SesEventPublishingV2IntegrationTest {
@Order(35)
void eicarInSimpleBody_isAcceptedThenRejectedAndStoredWithoutTheBody() throws Exception {
drainQueue();
String messageId = given().contentType("application/json").header("Authorization", AUTH)
String messageId = v2()
.body("""
{"FromEmailAddress": "%s",
"Destination": {"ToAddresses": ["success@simulator.amazonses.com"]},
@@ -1791,7 +1720,7 @@ class SesEventPublishingV2IntegrationTest {
"\"Subject\": {\"Data\": \"clean\"}, \"Body\": {\"Text\": {\"Data\": \"clean\"}}, "
+ "\"Headers\": [{\"Name\": \"" + signature + "\", \"Value\": \"x\"}]"}) {
drainQueue();
String messageId = given().contentType("application/json").header("Authorization", AUTH)
String messageId = v2()
.body("""
{"FromEmailAddress": "%s",
"Destination": {"ToAddresses": ["success@simulator.amazonses.com"]},
@@ -1857,7 +1786,7 @@ class SesEventPublishingV2IntegrationTest {
}
private void createCustomVerificationTemplate(String name, String content) {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{"TemplateName": "%s", "FromEmailAddress": "%s", "TemplateSubject": "verify",
"TemplateContent": "%s",
@@ -1870,7 +1799,7 @@ class SesEventPublishingV2IntegrationTest {
private String sendCustomVerificationEmail(String recipient, String templateName, String configurationSet) {
String configurationSetField = configurationSet == null
? "" : ", \"ConfigurationSetName\": \"" + configurationSet + "\"";
return given().contentType("application/json").header("Authorization", AUTH)
return v2()
.body("""
{"EmailAddress": "%s", "TemplateName": "%s"%s}
""".formatted(recipient, templateName, configurationSetField))
@@ -1886,7 +1815,7 @@ class SesEventPublishingV2IntegrationTest {
String recipient = "cvet-preamble@cvet-events.floci.test";
createCustomVerificationTemplate("cvet-preamble", "<p>verify</p>");
try {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"" + CS + "\"}")
.when().put("/v2/email/identities/" + SENDER + "/configuration-set").then().statusCode(200);
drainQueue();
@@ -1895,7 +1824,7 @@ class SesEventPublishingV2IntegrationTest {
receiveSesEvents(1).stream().map(e -> e.path("eventType").asText()).toList(),
"the identity default configuration set publishes without an explicit name");
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + recipient + "\",\"Reason\":\"BOUNCE\"}")
.when().put("/v2/email/suppression/addresses").then().statusCode(200);
drainQueue();
@@ -1904,20 +1833,20 @@ class SesEventPublishingV2IntegrationTest {
.filter(e -> "Bounce".equals(e.path("eventType").asText())).findFirst().orElseThrow();
assertEquals("OnAccountSuppressionList", bounce.path("bounce").path("bounceSubType").asText());
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"ConfigurationSetName\":\"cvet-paused\"}")
.when().post("/v2/email/configuration-sets").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"SendingEnabled\":false}")
.when().put("/v2/email/configuration-sets/cvet-paused/sending").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "%s", "TemplateName": "cvet-preamble", "ConfigurationSetName": "cvet-paused"}
""".formatted(recipient))
.when().post("/v2/email/outbound-custom-verification-emails").then().statusCode(400)
.body("__type", equalTo("SendingPausedException"));
} finally {
given().contentType("application/json").header("Authorization", AUTH).body("{}")
v2().body("{}")
.when().put("/v2/email/identities/" + SENDER + "/configuration-set");
given().header("Authorization", AUTH)
.when().delete("/v2/email/suppression/addresses/" + recipient);
@@ -1930,9 +1859,7 @@ class SesEventPublishingV2IntegrationTest {
}
private void sendEmail(String to) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "%s",
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -19,9 +20,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(1)
void createEmailIdentity_setsUpDomain() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "v2-attrs.floci.test"}
""")
@@ -49,9 +48,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(2)
void putEmailIdentityMailFromAttributes_setsDomain() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"MailFromDomain": "mail.v2-attrs.floci.test",
@@ -81,9 +78,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(4)
void putEmailIdentityMailFromAttributes_emptyDomain_clears() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"MailFromDomain": ""}
""")
@@ -109,9 +104,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(5)
void putEmailIdentityMailFromAttributes_unknownIdentity_returnsBadRequest() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"MailFromDomain": "mail.ghost.floci.test"}
""")
@@ -126,9 +119,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(11)
void putEmailIdentityFeedbackAttributes_unknownIdentity_returnsBadRequest() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailForwardingEnabled": true}
""")
@@ -144,9 +135,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(6)
void putEmailIdentityMailFromAttributes_invalidJson_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("[1,2,3]")
.when()
.put("/v2/email/identities/v2-attrs.floci.test/mail-from")
@@ -159,9 +148,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(7)
void putEmailIdentityMailFromAttributes_missingBody_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.put("/v2/email/identities/v2-attrs.floci.test/mail-from")
.then()
@@ -172,9 +159,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(8)
void putEmailIdentityMailFromAttributes_missingMailFromDomainField_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"BehaviorOnMxFailure": "USE_DEFAULT_VALUE"}
""")
@@ -188,9 +173,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(9)
void putEmailIdentityMailFromAttributes_mailFromDomainAsObject_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"MailFromDomain": {"foo": "bar"}}
""")
@@ -204,9 +187,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(10)
void putEmailIdentityMailFromAttributes_unknownBehavior_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"MailFromDomain": "mail.v2-attrs.floci.test",
@@ -225,9 +206,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(20)
void putEmailIdentityDkimAttributes_unknownIdentity_returnsBadRequest() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningEnabled": true}
""")
@@ -245,9 +224,7 @@ class SesIdentityAttributesV2IntegrationTest {
void putEmailIdentityDkimAttributes_emailFormatWithUnregisteredParent_returnsBadRequest() {
// Real SES v2 reports the parent domain (not the full email identity)
// in the error message even when the input is email-formatted.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningEnabled": true}
""")
@@ -267,18 +244,14 @@ class SesIdentityAttributesV2IntegrationTest {
// whose parent domain is registered, but persists nothing — DKIM is a
// domain-level concept. The parent domain's DkimAttributes must remain
// untouched, and no email identity is auto-created.
Object parentDkimBefore = given()
.contentType("application/json")
.header("Authorization", AUTH)
Object parentDkimBefore = v2()
.when()
.get("/v2/email/identities/v2-attrs.floci.test")
.then()
.statusCode(200)
.extract().path("DkimAttributes");
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningEnabled": true}
""")
@@ -287,18 +260,14 @@ class SesIdentityAttributesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/v2-attrs.floci.test")
.then()
.statusCode(200)
.body("DkimAttributes", equalTo(parentDkimBefore));
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/orphan@v2-attrs.floci.test")
.then()
@@ -308,9 +277,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(23)
void createEmailIdentity_duplicate_returnsAlreadyExists() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "v2-attrs.floci.test"}
""")
@@ -326,9 +293,7 @@ class SesIdentityAttributesV2IntegrationTest {
@Test
@Order(24)
void deleteEmailIdentity_unknownIdentity_returnsNotFound() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.delete("/v2/email/identities/ghost-delete.floci.test")
.then()
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@@ -33,7 +34,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Test
@Order(0)
void setup_createIdentity() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\": \"" + IDENTITY + "\"}")
.when().post("/v2/email/identities")
.then().statusCode(200);
@@ -42,7 +43,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Test
@Order(1)
void createPolicy_thenGet() {
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(BASE + "/p1")
.then().statusCode(200);
@@ -55,7 +56,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Test
@Order(2)
void createDuplicateName_throwsAlreadyExists() {
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(BASE + "/p1")
.then().statusCode(400)
.body("__type", equalTo("AlreadyExistsException"))
@@ -65,7 +66,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Test
@Order(3)
void createSameContentDifferentName_ok() {
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(BASE + "/p2")
.then().statusCode(200);
}
@@ -74,7 +75,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Order(4)
void updatePolicy_replaces() {
String updated = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"X\"}]}";
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(updated))
v2().body(policyBody(updated))
.when().put(BASE + "/p1")
.then().statusCode(200);
@@ -87,7 +88,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Test
@Order(5)
void updateMissing_throwsNotFound() {
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().put(BASE + "/nope")
.then().statusCode(404)
.body("__type", equalTo("NotFoundException"))
@@ -120,7 +121,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Order(8)
void operationsOnMissingIdentity_throwNotFound() {
String ghost = "/v2/email/identities/ghost-v2.floci.test/policies";
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(ghost + "/p")
.then().statusCode(404)
.body("__type", equalTo("NotFoundException"))
@@ -131,7 +132,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Test
@Order(9)
void invalidPolicyName_chars_returns400() {
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(BASE + "/bad%20name")
.then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -142,7 +143,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Test
@Order(10)
void invalidPolicyName_tooLong_returns400() {
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(BASE + "/" + "a".repeat(65))
.then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -155,11 +156,11 @@ class SesIdentityPolicyV2IntegrationTest {
void perIdentityLimit_21stThrowsLimitExceeded() {
// p1 already exists (Order 4). Fill to 20, then the 21st create fails.
for (int i = 2; i <= 20; i++) {
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(BASE + "/lp" + i)
.then().statusCode(200);
}
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(BASE + "/overflow")
.then().statusCode(400)
.body("__type", equalTo("LimitExceededException"))
@@ -172,17 +173,17 @@ class SesIdentityPolicyV2IntegrationTest {
void deleteIdentity_purgesPolicies_noResurrectOnRecreate() {
String id = "cascade.floci.test";
String base = "/v2/email/identities/" + id + "/policies";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\": \"" + id + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH).body(policyBody(DOC))
v2().body(policyBody(DOC))
.when().post(base + "/c1").then().statusCode(200);
given().header("Authorization", AUTH)
.when().delete("/v2/email/identities/" + id).then().statusCode(200);
// Recreate the same-named identity: the old policy must not leak back in.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\": \"" + id + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
given().header("Authorization", AUTH)
@@ -194,7 +195,7 @@ class SesIdentityPolicyV2IntegrationTest {
@Order(13)
void policyWrongType_returns400() {
// Policy is a string field; a non-string must be rejected, not coerced to "123".
given().contentType("application/json").header("Authorization", AUTH).body("{\"Policy\": 123}")
v2().body("{\"Policy\": 123}")
.when().post(BASE + "/wrongtype")
.then().statusCode(400)
.body("__type", equalTo("SerializationException"));
@@ -205,10 +206,10 @@ class SesIdentityPolicyV2IntegrationTest {
void policyMissingOrNull_returnsValidationError() {
String expected = "1 validation error detected: Value at 'policy' failed to satisfy "
+ "constraint: Member must not be null";
given().contentType("application/json").header("Authorization", AUTH).body("{}")
v2().body("{}")
.when().post(BASE + "/missing")
.then().statusCode(400).body("message", equalTo(expected));
given().contentType("application/json").header("Authorization", AUTH).body("{\"Policy\": null}")
v2().body("{\"Policy\": null}")
.when().post(BASE + "/nullpol")
.then().statusCode(400).body("message", equalTo(expected));
}
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
@@ -32,11 +33,11 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
@Test
@Order(0)
void setup_verifyFromAndCreateTemplate() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + FROM + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "%s",
@@ -53,7 +54,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
@Test
@Order(1)
void send_returnsMessageId() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + RECIPIENT + "\",\"TemplateName\":\"" + NAME + "\"}")
.when().post(SEND).then().statusCode(200)
.body("MessageId", notNullValue());
@@ -84,7 +85,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
@Test
@Order(4)
void send_missingTemplate_returnsNotFound() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + RECIPIENT + "\",\"TemplateName\":\"scve-v2-ghost\"}")
.when().post(SEND).then().statusCode(404)
.body("__type", equalTo("NotFoundException"))
@@ -96,7 +97,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
@Test
@Order(5)
void send_unknownConfigurationSet_returnsNotFound() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + RECIPIENT + "\",\"TemplateName\":\"" + NAME
+ "\",\"ConfigurationSetName\":\"scve-v2-ghost-cs\"}")
.when().post(SEND).then().statusCode(404)
@@ -106,7 +107,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
@Test
@Order(6)
void send_missingEmailAddress_returnsBadRequest() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TemplateName\":\"" + NAME + "\"}")
.when().post(SEND).then().statusCode(400)
.body("__type", equalTo("BadRequestException"));
@@ -120,10 +121,10 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
// (consistent with the CreateCustomVerificationEmailTemplate unverified-From mapping).
String from2 = "scve-v2-stale-from@floci.test";
String template2 = "scve-v2-stale-template";
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\":\"" + from2 + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "%s",
@@ -138,7 +139,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
given().header("Authorization", AUTH)
.when().delete("/v2/email/identities/" + from2).then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + RECIPIENT + "\",\"TemplateName\":\"" + template2 + "\"}")
.when().post(SEND).then().statusCode(404)
.body("__type", equalTo("NotFoundException"));
@@ -148,16 +149,16 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
@Order(8)
void send_accountSendingDisabled_returnsSendingPaused() {
// Like the v2 SendEmail endpoint, the send is refused while account sending is paused.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"SendingEnabled\":false}")
.when().put("/v2/email/account/sending").then().statusCode(200);
try {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"" + RECIPIENT + "\",\"TemplateName\":\"" + NAME + "\"}")
.when().post(SEND).then().statusCode(400)
.body("__type", equalTo("SendingPausedException"));
} finally {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"SendingEnabled\":true}")
.when().put("/v2/email/account/sending").then().statusCode(200);
}
@@ -168,7 +169,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
void send_malformedEmailAddress_returnsBadRequestWithAwsMessage() {
// AWS returns the same "Invalid email address<addr>." message on v2 as on v1 (verified);
// Floci throws the v1-native InvalidParameterValue which remaps to BadRequestException / 400.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"not-an-email\",\"TemplateName\":\"" + NAME + "\"}")
.when().post(SEND).then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -180,7 +181,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
void send_multipleUnquotedAt_returnsBadRequest() {
// AWS rejects more than one unquoted '@'; a quoted local part that contains '@' is accepted
// (see the v1 test) — the check must only reject the unquoted case.
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"a@@b.com\",\"TemplateName\":\"" + NAME + "\"}")
.when().post(SEND).then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -191,7 +192,7 @@ class SesSendCustomVerificationEmailV2IntegrationTest {
@Order(11)
void send_emptyDomain_returnsBadRequest() {
// A trailing '@' is an empty domain, which AWS rejects (verified).
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailAddress\":\"local@\",\"TemplateName\":\"" + NAME + "\"}")
.when().post(SEND).then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -24,6 +24,7 @@ import java.util.Base64;
import java.util.List;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;
@@ -43,7 +44,7 @@ class SesSimpleAttachmentsV2IntegrationTest {
@Test
@Order(1)
void createSender() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"EmailIdentity\": \"" + SENDER + "\"}")
.when().post("/v2/email/identities").then().statusCode(200);
}
@@ -298,7 +299,7 @@ class SesSimpleAttachmentsV2IntegrationTest {
}
private static Response send(String body) {
return given().contentType("application/json").header("Authorization", AUTH)
return v2()
.body(body)
.when().post("/v2/email/outbound-emails");
}
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.DECIMAL_NUMBERS;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis;
import static io.restassured.RestAssured.given;
@@ -22,9 +23,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(1)
void putSuppressedDestination_bounce() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "bounce-1@example.com", "Reason": "BOUNCE"}
""")
@@ -37,9 +36,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(2)
void putSuppressedDestination_complaint() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "complaint-1@example.com", "Reason": "COMPLAINT"}
""")
@@ -79,9 +76,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(5)
void putSuppressedDestination_updatesExistingReason() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "bounce-1@example.com", "Reason": "COMPLAINT"}
""")
@@ -121,9 +116,7 @@ class SesSuppressionV2IntegrationTest {
// Seed a BOUNCE entry so the filter has something to exclude — without it
// every existing entry is already COMPLAINT (bounce-1 was flipped at @Order(5))
// and the assertion would pass even if the server ignored the filter.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "filter-bounce@example.com", "Reason": "BOUNCE"}
""")
@@ -188,9 +181,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(10)
void putSuppressedDestination_invalidReason_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "bad@example.com", "Reason": "OTHER"}
""")
@@ -204,9 +195,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(11)
void putSuppressedDestination_missingEmailAddress_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"Reason": "BOUNCE"}
""")
@@ -220,9 +209,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(12)
void putSuppressedDestination_missingBody_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.put("/v2/email/suppression/addresses")
.then()
@@ -233,9 +220,7 @@ class SesSuppressionV2IntegrationTest {
@Order(16)
void putSuppressedDestination_nullEmailAddress_returns400() {
// JSON null for EmailAddress must not coerce into the literal string "null".
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": null, "Reason": "BOUNCE"}
""")
@@ -249,9 +234,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(17)
void putSuppressedDestination_nullReason_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "null-reason@example.com", "Reason": null}
""")
@@ -265,9 +248,7 @@ class SesSuppressionV2IntegrationTest {
@Test
@Order(18)
void putSuppressedDestination_nonObjectBody_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("[\"not\", \"an\", \"object\"]")
.when()
.put("/v2/email/suppression/addresses")
@@ -281,9 +262,7 @@ class SesSuppressionV2IntegrationTest {
@Order(13)
void putSuppressedDestination_trimsWhitespaceFromEmailAddress() {
// AWS silently trims leading/trailing whitespace from EmailAddress on Put.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": " padded@example.com ", "Reason": "BOUNCE"}
""")
@@ -318,9 +297,7 @@ class SesSuppressionV2IntegrationTest {
@Order(15)
void listSuppressedDestinations_multipleReasonFilters_appliesOrSemantics() {
// Seed a BOUNCE entry alongside the surviving complaint-1 COMPLAINT entry
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "multi-bounce@example.com", "Reason": "BOUNCE"}
""")
@@ -347,9 +324,7 @@ class SesSuppressionV2IntegrationTest {
// Verified against real AWS SES V2 (2026-06-15): AWS canonicalizes only the
// domain to lower case; the local-part keeps its case. PUT MixedCase@Example.COM
// is stored and read back as MixedCase@example.com.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "MixedCase@Example.COM", "Reason": "BOUNCE"}
""")
@@ -374,9 +349,7 @@ class SesSuppressionV2IntegrationTest {
// Self-contained: seed its own entry so the test is order-independent.
// A differing domain case still hits the entry; a differing local-part case
// does not (it is a different key).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "CaseProbe@Example.COM", "Reason": "BOUNCE"}
""")
@@ -405,9 +378,7 @@ class SesSuppressionV2IntegrationTest {
@Order(22)
void deleteSuppressedDestination_domainCaseInsensitive() {
// PUT one domain case, DELETE a different domain case (same local-part), GET 404.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "DeleteMe@Example.com", "Reason": "COMPLAINT"}
""")
@@ -435,9 +406,7 @@ class SesSuppressionV2IntegrationTest {
@Order(23)
void putSuppressedDestination_domainCaseCollision_lastPutWins() {
// Same local-part, domain differing only in case: one entry, latest Reason wins.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "UpdateTarget@example.com", "Reason": "BOUNCE"}
""")
@@ -446,9 +415,7 @@ class SesSuppressionV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "UpdateTarget@EXAMPLE.com", "Reason": "COMPLAINT"}
""")
@@ -472,9 +439,7 @@ class SesSuppressionV2IntegrationTest {
void putSuppressedDestination_localPartCaseDifference_distinctEntries() {
// Local-part case differences are distinct entries (not merged), each keeping
// its own Reason. Verified against real AWS SES V2 (2026-06-15).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "LocalCase@distinct.example.com", "Reason": "BOUNCE"}
""")
@@ -483,9 +448,7 @@ class SesSuppressionV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailAddress": "localcase@distinct.example.com", "Reason": "COMPLAINT"}
""")
@@ -7,6 +7,7 @@ import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
@@ -115,9 +116,7 @@ class SesTagArnV2IntegrationTest {
@Test
void omittedResourceArn_onTagAndUntag_isMessagelessValidation() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"Tags\": [{\"Key\": \"k\", \"Value\": \"v\"}]}")
.when()
.post("/v2/email/tags")
@@ -157,9 +156,7 @@ class SesTagArnV2IntegrationTest {
private static String createConfigurationSet(String prefix, String key, String value) {
String name = prefix + "-" + System.nanoTime();
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "%s", "Tags": [{"Key": "%s", "Value": "%s"}]}
""".formatted(name, key, value))
@@ -183,9 +180,7 @@ class SesTagArnV2IntegrationTest {
}
private static Response tagWith(String arn, String key, String value) {
return given()
.contentType("application/json")
.header("Authorization", AUTH)
return v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "%s", "Value": "%s"}]}
""".formatted(arn, key, value))
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
@@ -22,9 +23,7 @@ class SesTagsV2IntegrationTest {
@Order(1)
void tags_lifecycle_onConfigurationSet() {
// Seed: create a configuration set we can tag against
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "tag-cs-1"}
""")
@@ -46,9 +45,7 @@ class SesTagsV2IntegrationTest {
.body("Tags", hasSize(0));
// TagResource
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [
{"Key": "env", "Value": "dev"},
@@ -72,9 +69,7 @@ class SesTagsV2IntegrationTest {
.body("Tags.find { it.Key == 'owner' }.Value", equalTo("alice"));
// TagResource on existing key replaces value (merge semantics)
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [
{"Key": "env", "Value": "prod"}
@@ -120,9 +115,7 @@ class SesTagsV2IntegrationTest {
@Order(2)
void tags_lifecycle_onEmailTemplate() {
// Seed: create an email template we can tag against
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "tag-tpl-1",
@@ -147,9 +140,7 @@ class SesTagsV2IntegrationTest {
.body("Tags", hasSize(0));
// Tag the template
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [
{"Key": "env", "Value": "stg"},
@@ -195,9 +186,7 @@ class SesTagsV2IntegrationTest {
@Order(3)
void tagResource_unknownEmailTemplate_returns404() {
String arn = "arn:aws:ses:us-east-1:000000000000:template/missing-tpl";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]}
""".formatted(arn))
@@ -212,9 +201,7 @@ class SesTagsV2IntegrationTest {
@Order(4)
void tagResource_unknownConfigurationSet_returns404() {
String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/missing-cs";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]}
""".formatted(arn))
@@ -240,9 +227,7 @@ class SesTagsV2IntegrationTest {
@Test
@Order(6)
void tagResource_invalidArn_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "not-an-arn", "Tags": [{"Key": "env", "Value": "dev"}]}
""")
@@ -258,9 +243,7 @@ class SesTagsV2IntegrationTest {
// An empty Tags list is not an error (probe-confirmed): the existence check still runs,
// then the empty merge no-ops. tag-cs-1 was left with a single "owner" tag by @Order(1).
String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/tag-cs-1";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": []}
""".formatted(arn))
@@ -280,9 +263,7 @@ class SesTagsV2IntegrationTest {
.body("Tags[0].Key", equalTo("owner"));
// The no-op still checks existence: an unknown resource stays NotFound.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "arn:aws:ses:us-east-1:000000000000:configuration-set/nowhere", "Tags": []}
""")
@@ -317,9 +298,7 @@ class SesTagsV2IntegrationTest {
@Order(9)
void tagResource_arnMissingRegion_returns400() {
String arn = "arn:aws:ses::000000000000:configuration-set/tag-cs-1";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]}
""".formatted(arn))
@@ -333,9 +312,7 @@ class SesTagsV2IntegrationTest {
@Order(10)
void tagResource_nonSesArn_returns400() {
String arn = "arn:aws:s3:us-east-1:000000000000:bucket/my-bucket";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]}
""".formatted(arn))
@@ -351,9 +328,7 @@ class SesTagsV2IntegrationTest {
// AWS rejects TagResource on ARN/signing region mismatch with BadRequestException
// ("Failed to tag resource") for every resource type (probe-confirmed).
String arn = "arn:aws:ses:eu-west-1:000000000000:configuration-set/tag-cs-1";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]}
""".formatted(arn))
@@ -388,9 +363,7 @@ class SesTagsV2IntegrationTest {
// Whitespace in configuration-set name fails configSetKey validation,
// which is remapped from InvalidParameterValue -> BadRequestException at the controller.
String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/has spaces";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]}
""".formatted(arn))
@@ -440,9 +413,7 @@ class SesTagsV2IntegrationTest {
@Order(16)
void tags_lifecycle_onEmailIdentity() {
// Seed: create an email identity we can tag against
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "tag-id-1@example.com"}
""")
@@ -464,9 +435,7 @@ class SesTagsV2IntegrationTest {
.body("Tags", hasSize(0));
// Tag it
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [
{"Key": "env", "Value": "stg"},
@@ -512,9 +481,7 @@ class SesTagsV2IntegrationTest {
@Order(17)
void tagResource_unknownEmailIdentity_returns404() {
String arn = "arn:aws:ses:us-east-1:000000000000:identity/missing-id@example.com";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]}
""".formatted(arn))
@@ -563,9 +530,7 @@ class SesTagsV2IntegrationTest {
void tagResource_mergeExceedingFifty_returns400() {
// AWS enforces the 50-tag ceiling on the MERGED (existing + incoming) set, and updating an
// existing key (net count unchanged) is allowed. Probe-confirmed against real AWS.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ConfigurationSetName": "tag-cs-merge"}
""")
@@ -577,9 +542,7 @@ class SesTagsV2IntegrationTest {
String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/tag-cs-merge";
// Seed with the full 50 tags.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": " + tagArray(0, 50) + "}")
.when()
.post("/v2/email/tags")
@@ -587,9 +550,7 @@ class SesTagsV2IntegrationTest {
.statusCode(200);
// Updating an existing key keeps the count at 50 and is accepted.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": [{\"Key\": \"k0\", \"Value\": \"updated\"}]}")
.when()
.post("/v2/email/tags")
@@ -597,9 +558,7 @@ class SesTagsV2IntegrationTest {
.statusCode(200);
// Adding one new key would make 51 — rejected with the merge-specific message.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": [{\"Key\": \"extra\", \"Value\": \"v\"}]}")
.when()
.post("/v2/email/tags")
@@ -614,9 +573,7 @@ class SesTagsV2IntegrationTest {
@Order(21)
void tagResource_reservedAwsPrefixKey_returns400() {
String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/tag-cs-1";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": [{\"Key\": \"aws:foo\", \"Value\": \"v\"}]}")
.when()
.post("/v2/email/tags")
@@ -633,9 +590,7 @@ class SesTagsV2IntegrationTest {
// corrected retry does not hit AlreadyExistsException. Validation is now applied to the parsed
// tag list up front, before verifyEmailIdentity/verifyDomainIdentity.
String id = "atomic-tag-id@example.com";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "%s", "Tags": [
{"Key": "dup", "Value": "1"},
@@ -662,9 +617,7 @@ class SesTagsV2IntegrationTest {
@Order(23)
void tags_lifecycle_onContactList() {
// Seed: create a contact list with inline tags
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ContactListName": "tag-cl-1", "Tags": [{"Key": "env", "Value": "dev"}]}
""")
@@ -687,9 +640,7 @@ class SesTagsV2IntegrationTest {
.body("Tags[0].Key", equalTo("env"));
// TagResource merges an additional key
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "owner", "Value": "alice"}]}
""".formatted(arn))
@@ -763,9 +714,7 @@ class SesTagsV2IntegrationTest {
@Order(24)
void tagResource_unknownContactList_returns404() {
String arn = "arn:aws:ses:us-east-1:000000000000:contact-list/missing-cl";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]}
""".formatted(arn))
@@ -780,9 +729,7 @@ class SesTagsV2IntegrationTest {
@Order(25)
void tags_lifecycle_onCustomVerificationEmailTemplate() {
// Seed: CVET creation requires a verified From identity
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "tag-cvet-sender@floci.test"}
""")
@@ -791,9 +738,7 @@ class SesTagsV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "tag-cvet-1",
@@ -820,9 +765,7 @@ class SesTagsV2IntegrationTest {
.statusCode(200)
.body("Tags", hasSize(0));
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [
{"Key": "env", "Value": "dev"},
@@ -835,9 +778,7 @@ class SesTagsV2IntegrationTest {
.statusCode(200);
// UpdateCustomVerificationEmailTemplate must not wipe the tags
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "tag-cvet-sender@floci.test",
@@ -885,9 +826,7 @@ class SesTagsV2IntegrationTest {
@Order(26)
void tagResource_unknownCustomVerificationEmailTemplate_returns404() {
String arn = "arn:aws:ses:us-east-1:000000000000:custom-verification-email-template/missing-cvet";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]}
""".formatted(arn))
@@ -902,9 +841,7 @@ class SesTagsV2IntegrationTest {
@Order(27)
void tags_lifecycle_onDedicatedIpPool() {
// Seed: create a pool with inline tags
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"PoolName": "tag-pool-1", "Tags": [{"Key": "env", "Value": "dev"}]}
""")
@@ -935,9 +872,7 @@ class SesTagsV2IntegrationTest {
.body("DedicatedIpPool.PoolName", equalTo("tag-pool-1"))
.body("DedicatedIpPool.Tags", nullValue());
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "owner", "Value": "alice"}]}
""".formatted(arn))
@@ -970,9 +905,7 @@ class SesTagsV2IntegrationTest {
@Order(28)
void tagResource_unknownDedicatedIpPool_returns404() {
String arn = "arn:aws:ses:us-east-1:000000000000:dedicated-ip-pool/missing-pool";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]}
""".formatted(arn))
@@ -988,9 +921,7 @@ class SesTagsV2IntegrationTest {
void createDedicatedIpPool_invalidInlineTags_isAtomic_poolNotPersisted() {
// A semantic tag error must fail CreateDedicatedIpPool before the pool is persisted, so a
// corrected retry does not hit AlreadyExistsException.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"PoolName": "atomic-tag-pool", "Tags": [
{"Key": "dup", "Value": "1"},
@@ -1098,9 +1029,7 @@ class SesTagsV2IntegrationTest {
@Order(35)
void tagResource_foreignAccountArn_returns400() {
String arn = "arn:aws:ses:us-east-1:999999999999:configuration-set/tag-cs-1";
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]}
""".formatted(arn))
@@ -1133,9 +1062,7 @@ class SesTagsV2IntegrationTest {
void createCustomVerificationEmailTemplate_inlineTags_storedAndAtomic() {
// v2 CreateCustomVerificationEmailTemplate accepts Tags (probe-confirmed); the From
// identity tag-cvet-sender@floci.test was verified by the lifecycle case at @Order(25).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "tag-cvet-inline",
@@ -1165,9 +1092,7 @@ class SesTagsV2IntegrationTest {
// A semantic tag error fails the create before anything is persisted, so a corrected
// retry does not hit AlreadyExistsException (probe-confirmed message and atomicity).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "tag-cvet-atomic",
@@ -1192,9 +1117,7 @@ class SesTagsV2IntegrationTest {
.then()
.statusCode(404);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "tag-cvet-atomic",
@@ -11,6 +11,7 @@ import java.util.stream.IntStream;
import java.util.stream.Stream;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@@ -58,9 +59,7 @@ class SesTemplateTagOrderIntegrationTest {
@ParameterizedTest
@MethodSource("refused")
void create_refusesInTheOrderSesDoes(String name, String content, String tags, String message) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(createBody(name, content, tags))
.when()
.post("/v2/email/templates")
@@ -72,9 +71,7 @@ class SesTemplateTagOrderIntegrationTest {
@Test
void create_refusedForAReservedKeyStoresNothing() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(createBody("tag-order-reserved", VALID, tag("aws:x")))
.when()
.post("/v2/email/templates")
@@ -12,6 +12,7 @@ import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.DECIMAL_NUMBERS;
import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis;
import static io.restassured.RestAssured.given;
@@ -32,9 +33,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(1)
void createTemplate() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "v2-welcome",
@@ -54,9 +53,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(2)
void createTemplate_duplicateRejected() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "v2-welcome",
@@ -74,9 +71,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(3)
void createTemplate_missingName() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"TemplateContent": {"Subject": "x"}}
""")
@@ -90,9 +85,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(4)
void getTemplate() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/templates/v2-welcome")
.then()
@@ -106,9 +99,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(5)
void getTemplate_notFound() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/templates/does-not-exist")
.then()
@@ -119,9 +110,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(6)
void updateTemplate() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateContent": {
@@ -136,9 +125,7 @@ class SesTemplateV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/templates/v2-welcome")
.then()
@@ -150,9 +137,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(7)
void updateTemplate_notFound() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"TemplateContent": {"Subject": "x", "Text": "x"}}
""")
@@ -182,9 +167,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(9)
void sendEmail_withTemplate_substitutesVariables() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "sender@example.com"}
""")
@@ -193,9 +176,7 @@ class SesTemplateV2IntegrationTest {
.then()
.statusCode(200);
String messageId = given()
.contentType("application/json")
.header("Authorization", AUTH)
String messageId = v2()
.body("""
{
"FromEmailAddress": "sender@example.com",
@@ -229,9 +210,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(10)
void sendEmail_withUnknownTemplate_returns404() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "sender@example.com",
@@ -254,9 +233,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(11)
void sendEmail_withTemplate_missingName_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "sender@example.com",
@@ -274,17 +251,13 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(12)
void deleteTemplate() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.delete("/v2/email/templates/v2-welcome")
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/templates/v2-welcome")
.then()
@@ -294,9 +267,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(13)
void deleteTemplate_notFound() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.delete("/v2/email/templates/already-gone")
.then()
@@ -307,9 +278,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(14)
void createTemplate_rejectsLeadingTrailingWhitespace() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": " padded ",
@@ -326,9 +295,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(15)
void sendEmail_withInlineTemplate_substitutesVariables() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "inline-sender@example.com"}
""")
@@ -337,9 +304,7 @@ class SesTemplateV2IntegrationTest {
.then()
.statusCode(200);
String messageId = given()
.contentType("application/json")
.header("Authorization", AUTH)
String messageId = v2()
.body("""
{
"FromEmailAddress": "inline-sender@example.com",
@@ -377,9 +342,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(16)
void sendEmail_templateWithBothNameAndContent_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inline-sender@example.com",
@@ -403,9 +366,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(17)
void sendEmail_withTemplateArn_resolvesStoredTemplate() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "arn-welcome",
@@ -420,9 +381,7 @@ class SesTemplateV2IntegrationTest {
.then()
.statusCode(200);
String messageId = given()
.contentType("application/json")
.header("Authorization", AUTH)
String messageId = v2()
.body("""
{
"FromEmailAddress": "inline-sender@example.com",
@@ -455,9 +414,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(18)
void sendEmail_templateWithMalformedArn_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inline-sender@example.com",
@@ -480,9 +437,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(19)
void sendEmail_templateWithNameAndArn_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inline-sender@example.com",
@@ -557,9 +512,7 @@ class SesTemplateV2IntegrationTest {
@Test
@Order(21)
void createEmailTemplate_withTags_visibleViaGet() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "tpl-with-tags",
@@ -609,9 +562,7 @@ class SesTemplateV2IntegrationTest {
@Order(23)
void updateEmailTemplate_preservesTags() {
// tpl-with-tags has 2 tags from @Order(21)
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateContent": {
@@ -641,9 +592,7 @@ class SesTemplateV2IntegrationTest {
void createTemplate_invalidTags_returns400_andNotPersisted() {
// Route-level coverage: CreateEmailTemplate must reject an invalid tag set (here duplicate
// keys) atomically, before the template is persisted.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "v2-badtags",
@@ -671,9 +620,7 @@ class SesTemplateV2IntegrationTest {
@MethodSource("malformedSendEmailBodies")
@Order(50)
void sendEmail_malformedShape_returnsBadRequest(String label, String body) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-emails")
@@ -686,9 +633,7 @@ class SesTemplateV2IntegrationTest {
@MethodSource("io.floci.aws.services.ses.SesV2SerializationErrors#nonObjectBodies")
@Order(51)
void sendEmail_nonObjectBody_isASerializationException(String body, String message) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-emails")
@@ -702,9 +647,7 @@ class SesTemplateV2IntegrationTest {
@MethodSource("wrongTypeSendEmailBodies")
@Order(52)
void sendEmail_wrongMemberType_returnsSerializationException(String label, String body) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/outbound-emails")
@@ -6,8 +6,7 @@ import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.restassured.RestAssured.given;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.Matchers.notNullValue;
@@ -28,7 +27,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(1)
void createTenant_returnsGeneratedIdArnAndEnabledStatus() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"" + TENANT + "\",\"Tags\":[{\"Key\":\"team\",\"Value\":\"floci\"}]}")
.when().post("/v2/email/tenants").then().statusCode(200)
.body("TenantName", equalTo(TENANT))
@@ -42,7 +41,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(2)
void getTenant_returnsTenant() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"" + TENANT + "\"}")
.when().post("/v2/email/tenants/get").then().statusCode(200)
.body("Tenant.TenantName", equalTo(TENANT))
@@ -53,7 +52,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(3)
void listTenants_includesTenantInfoSubset() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.when().post("/v2/email/tenants/list").then().statusCode(200)
.body("Tenants.find { it.TenantName == '" + TENANT + "' }.TenantId", startsWith("tn-"))
.body("Tenants.find { it.TenantName == '" + TENANT + "' }.SendingStatus", equalTo(null));
@@ -62,7 +61,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(4)
void createTenant_duplicate_returnsAlreadyExists() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"" + TENANT + "\"}")
.when().post("/v2/email/tenants").then().statusCode(400)
.body("__type", equalTo("AlreadyExistsException"))
@@ -72,11 +71,11 @@ class SesTenantV2IntegrationTest {
@Test
@Order(5)
void deleteTenant_removesIt() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"" + TENANT + "\"}")
.when().post("/v2/email/tenants/delete").then().statusCode(200);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"" + TENANT + "\"}")
.when().post("/v2/email/tenants/get").then().statusCode(404)
.body("__type", equalTo("NotFoundException"))
@@ -86,7 +85,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(6)
void deleteTenant_missing_returnsNotFound() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"ghost-tenant\"}")
.when().post("/v2/email/tenants/delete").then().statusCode(404)
.body("__type", equalTo("NotFoundException"));
@@ -95,7 +94,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(7)
void createTenant_invalidName_returnsBadRequest() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"bad name!\"}")
.when().post("/v2/email/tenants").then().statusCode(400)
.body("__type", equalTo("BadRequestException"))
@@ -106,7 +105,7 @@ class SesTenantV2IntegrationTest {
@Order(8)
void createTenant_tooLongName_returnsBadRequest() {
String longName = "x".repeat(65);
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"" + longName + "\"}")
.when().post("/v2/email/tenants").then().statusCode(400)
.body("message", equalTo("TenantName cannot exceed 64 characters."));
@@ -115,7 +114,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(9)
void createTenant_invalidTag_returnsBadRequest() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"tag-tenant\",\"Tags\":[{\"Key\":\"\",\"Value\":\"v\"}]}")
.when().post("/v2/email/tenants").then().statusCode(400)
.body("__type", equalTo("BadRequestException"));
@@ -124,7 +123,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(10)
void getTenant_emptyName_returnsBadRequest() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"\"}")
.when().post("/v2/email/tenants/get").then().statusCode(400)
.body("__type", equalTo("BadRequestException"));
@@ -133,7 +132,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(11)
void listTenants_malformedBody_returnsSerializationException() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{ not json")
.when().post("/v2/email/tenants/list").then().statusCode(400)
.body("__type", equalTo("SerializationException"));
@@ -142,7 +141,7 @@ class SesTenantV2IntegrationTest {
@Test
@Order(12)
void createTenant_nonStringTagMember_returnsSerializationException() {
given().contentType("application/json").header("Authorization", AUTH)
v2()
.body("{\"TenantName\":\"nonstring-tag\",\"Tags\":[{\"Key\":123,\"Value\":true}]}")
.when().post("/v2/email/tenants").then().statusCode(400)
.body("__type", equalTo("SerializationException"));
@@ -13,8 +13,7 @@ import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.restassured.RestAssured.given;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
@@ -24,9 +23,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(1)
void createTemplate() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "v2-render-welcome",
@@ -46,9 +43,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(2)
void testRenderEmailTemplate_substitutesVariables() {
String rendered = given()
.contentType("application/json")
.header("Authorization", AUTH)
String rendered = v2()
.body("""
{"TemplateData": "{\\"name\\":\\"Alice\\",\\"team\\":\\"floci\\"}"}
""")
@@ -67,9 +62,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(3)
void testRenderEmailTemplate_unknownTemplate_returns404() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"TemplateData": "{}"}
""")
@@ -84,9 +77,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(6)
void testRenderEmailTemplate_unknownTemplateWithMalformedData_reportsTheData() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"TemplateData": "[1]"}
""")
@@ -101,9 +92,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(4)
void testRenderEmailTemplate_invalidJson_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"TemplateData": "{not json"}
""")
@@ -118,9 +107,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(5)
void testRenderEmailTemplate_missingVariable_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"TemplateData": "{\\"name\\":\\"Alice\\"}"}
""")
@@ -135,9 +122,7 @@ class SesTestRenderV2IntegrationTest {
@MethodSource("malformedRenderBodies")
@Order(7)
void testRenderEmailTemplate_malformedBody_returns400(String label, String body) {
RequestSpecification spec = given()
.contentType("application/json")
.header("Authorization", AUTH);
RequestSpecification spec = v2();
if (body != null) {
spec = spec.body(body);
}
@@ -159,9 +144,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(8)
void testRenderEmailTemplate_arrayBody_isASerializationException() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("[1,2,3]")
.when()
.post("/v2/email/templates/v2-render-welcome/render")
@@ -174,9 +157,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(10)
void testRenderEmailTemplate_dateHeaderIsUtc() {
String rendered = given()
.contentType("application/json")
.header("Authorization", AUTH)
String rendered = v2()
.body("""
{"TemplateData": "{\\"name\\":\\"Alice\\",\\"team\\":\\"floci\\"}"}
""")
@@ -195,9 +176,7 @@ class SesTestRenderV2IntegrationTest {
@Test
@Order(11)
void testRenderEmailTemplate_utf8Body_isBase64WithAnEncodedSubject() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "v2-render-jp",
@@ -212,9 +191,7 @@ class SesTestRenderV2IntegrationTest {
.then()
.statusCode(200);
String rendered = given()
.contentType("application/json")
.header("Authorization", AUTH)
String rendered = v2()
.body("""
{"TemplateData": "{\\"name\\":\\"太郎\\"}"}
""")
@@ -9,9 +9,8 @@ import org.junit.jupiter.params.provider.MethodSource;
import java.util.List;
import java.util.stream.Stream;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.floci.aws.services.ses.SesV2SerializationErrors.assertSerializationException;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
@@ -75,9 +74,7 @@ class SesV2BodyReadIntegrationTest {
void emptyBody_isReadAsOneWithoutMembers() {
listTenants("");
// Reaches the missing-name validation rather than failing to read the body.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("")
.when()
.post("/v2/email/configuration-sets")
@@ -92,9 +89,7 @@ class SesV2BodyReadIntegrationTest {
}
private static void listTenants(String body) {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body(body)
.when()
.post("/v2/email/tenants/list")
@@ -9,6 +9,7 @@ import org.junit.jupiter.api.TestMethodOrder;
import java.util.List;
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
import static io.floci.aws.services.ses.SesV2Requests.v2;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.*;
@@ -22,9 +23,7 @@ class SesV2IntegrationTest {
@Test
@Order(1)
void createEmailIdentity_email() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "v2sender@example.com"}
""")
@@ -39,9 +38,7 @@ class SesV2IntegrationTest {
@Test
@Order(2)
void createEmailIdentity_domain() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "v2example.com"}
""")
@@ -57,9 +54,7 @@ class SesV2IntegrationTest {
.body("DkimAttributes.Tokens", not(empty()));
// A subsequent GetEmailIdentity transitions the DKIM status to PENDING, matching AWS.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/v2example.com")
.then()
@@ -70,9 +65,7 @@ class SesV2IntegrationTest {
@Test
@Order(3)
void createEmailIdentity_missingField() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{}")
.when()
.post("/v2/email/identities")
@@ -85,9 +78,7 @@ class SesV2IntegrationTest {
@Order(4)
void listEmailIdentities() {
// Other classes share this region, so ask for a page large enough to hold every identity.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.queryParam("PageSize", 1000)
.when()
.get("/v2/email/identities")
@@ -113,9 +104,7 @@ class SesV2IntegrationTest {
@Test
@Order(5)
void getEmailIdentity() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/v2sender@example.com")
.then()
@@ -128,9 +117,7 @@ class SesV2IntegrationTest {
@Test
@Order(61)
void getEmailIdentity_domainTransitionsToSuccessWhenDkimRecordsExist() {
List<String> tokens = given()
.contentType("application/json")
.header("Authorization", AUTH)
List<String> tokens = v2()
.body("""
{"EmailIdentity": "v2dkim-success.floci.test"}
""")
@@ -145,9 +132,7 @@ class SesV2IntegrationTest {
SesDomainIdentityTestHelper.publishDkimRecords("v2dkim-success.floci.test", tokens);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/v2dkim-success.floci.test")
.then()
@@ -161,9 +146,7 @@ class SesV2IntegrationTest {
// DKIM verification status tracks DNS detection independently of the signing flag: disabling
// DKIM keeps Status=SUCCESS while the CNAMEs remain published.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningEnabled": false}
""")
@@ -172,9 +155,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/v2dkim-success.floci.test")
.then()
@@ -183,9 +164,7 @@ class SesV2IntegrationTest {
.body("DkimAttributes.Status", equalTo("SUCCESS"));
// Re-enable so the key-rotation assertion below starts from the signing-enabled state.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningEnabled": true}
""")
@@ -196,9 +175,7 @@ class SesV2IntegrationTest {
// Rotating the DKIM key must not revoke the identity's sending verification (matching AWS):
// VerificationStatus stays SUCCESS, but DKIM re-pends until the new tokens' records are detected.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningAttributesOrigin":"AWS_SES","SigningAttributes":{"NextSigningKeyLength":"RSA_1024_BIT"}}
""")
@@ -207,9 +184,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/v2dkim-success.floci.test")
.then()
@@ -221,9 +196,7 @@ class SesV2IntegrationTest {
@Test
@Order(6)
void getEmailIdentity_notFound() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/nonexistent@example.com")
.then()
@@ -234,9 +207,7 @@ class SesV2IntegrationTest {
@Test
@Order(7)
void sendEmail_simple() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "v2sender@example.com",
@@ -263,9 +234,7 @@ class SesV2IntegrationTest {
@Test
@Order(8)
void sendEmail_html() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "v2sender@example.com",
@@ -293,9 +262,7 @@ class SesV2IntegrationTest {
@Test
@Order(9)
void sendEmail_raw() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "v2sender@example.com",
@@ -319,9 +286,7 @@ class SesV2IntegrationTest {
@Test
@Order(10)
void sendEmail_missingContent() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "v2sender@example.com",
@@ -344,9 +309,7 @@ class SesV2IntegrationTest {
// SuppressionAttributes defaults to BOUNCE + COMPLAINT on a fresh region,
// matching real SES account behaviour. Later @Order(58+) tests overwrite
// the stored value, so this assertion only holds before those run.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/account")
.then()
@@ -363,9 +326,7 @@ class SesV2IntegrationTest {
@Test
@Order(12)
void deleteEmailIdentity() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.delete("/v2/email/identities/v2sender@example.com")
.then()
@@ -374,9 +335,7 @@ class SesV2IntegrationTest {
.body("size()", equalTo(0)); // empty JSON object {}
// Verify it's gone
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/v2sender@example.com")
.then()
@@ -386,9 +345,7 @@ class SesV2IntegrationTest {
@Test
@Order(13)
void sendEmail_template() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "template-sender@example.com"}
""")
@@ -397,9 +354,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"TemplateName": "MyTemplate",
@@ -414,9 +369,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "template-sender@example.com",
@@ -441,9 +394,7 @@ class SesV2IntegrationTest {
@Test
@Order(14)
void createEmailIdentity_rejectsLeadingTrailingWhitespace() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": " padded@example.com "}
""")
@@ -460,9 +411,7 @@ class SesV2IntegrationTest {
void createEmailIdentity_withTags_visibleViaGetAndListTags() {
// Tags supplied to CreateEmailIdentity must round-trip through GetEmailIdentity
// and ListTagsForResource (template/configuration-set behaviour parallel).
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"EmailIdentity": "v2-tag-roundtrip.floci.test",
@@ -504,9 +453,7 @@ class SesV2IntegrationTest {
@Order(20)
void putDkimAttributes_enable() {
// Create identity first
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "dkim-test@example.com"}
""")
@@ -516,9 +463,7 @@ class SesV2IntegrationTest {
.statusCode(200);
// Enable DKIM
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningEnabled": true}
""")
@@ -528,9 +473,7 @@ class SesV2IntegrationTest {
.statusCode(200);
// Verify DKIM is enabled on the identity
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/dkim-test@example.com")
.then()
@@ -544,9 +487,7 @@ class SesV2IntegrationTest {
@Test
@Order(21)
void putDkimAttributes_disable() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SigningEnabled": false}
""")
@@ -555,9 +496,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/dkim-test@example.com")
.then()
@@ -571,9 +510,7 @@ class SesV2IntegrationTest {
@Test
@Order(40)
void putFeedbackAttributes_disable() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailForwardingEnabled": false}
""")
@@ -582,9 +519,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/dkim-test@example.com")
.then()
@@ -595,9 +530,7 @@ class SesV2IntegrationTest {
@Test
@Order(41)
void putFeedbackAttributes_enable() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailForwardingEnabled": true}
""")
@@ -606,9 +539,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/dkim-test@example.com")
.then()
@@ -623,9 +554,7 @@ class SesV2IntegrationTest {
// identity on this endpoint, with the "Identity X is invalid..."
// message inherited from the v1 SetIdentityFeedbackForwardingEnabled
// wire shape via remapV1Exception.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailForwardingEnabled": false}
""")
@@ -641,9 +570,7 @@ class SesV2IntegrationTest {
@Test
@Order(50)
void putAccountSendingAttributes_disable() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SendingEnabled": false}
""")
@@ -652,9 +579,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/account")
.then()
@@ -665,9 +590,7 @@ class SesV2IntegrationTest {
@Test
@Order(51)
void putAccountSendingAttributes_enable() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SendingEnabled": true}
""")
@@ -676,9 +599,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/account")
.then()
@@ -689,9 +610,7 @@ class SesV2IntegrationTest {
@Test
@Order(58)
void putAccountSuppressionAttributes_storesReasons_visibleViaGetAccount() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SuppressedReasons": ["BOUNCE", "COMPLAINT"]}
""")
@@ -712,9 +631,7 @@ class SesV2IntegrationTest {
@Test
@Order(59)
void putAccountSuppressionAttributes_emptyArray_clearsReasons() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SuppressedReasons": []}
""")
@@ -735,9 +652,7 @@ class SesV2IntegrationTest {
@Test
@Order(61)
void putAccountSuppressionAttributes_missingField_succeedsWithEmptyList() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("{}")
.when()
.put("/v2/email/account/suppression")
@@ -756,9 +671,7 @@ class SesV2IntegrationTest {
@Test
@Order(62)
void putAccountSuppressionAttributes_invalidReason_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SuppressedReasons": ["BOUNCE", "OTHER"]}
""")
@@ -775,9 +688,7 @@ class SesV2IntegrationTest {
@Test
@Order(64)
void putAccountSuppressionAttributes_nullMember_returns400() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"SuppressedReasons": [null]}
""")
@@ -793,9 +704,7 @@ class SesV2IntegrationTest {
void putAccountSuppressionAttributes_acceptsValidationAttributes() {
// The optional ValidationAttributes object is accepted but not parsed —
// verifying the request shape does not regress to a 400.
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"SuppressedReasons": ["BOUNCE"],
@@ -827,9 +736,7 @@ class SesV2IntegrationTest {
@Order(57)
void sendEmail_ccOnly_noToAddresses() {
// Re-create identity
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "cc-only-sender@example.com"}
""")
@@ -839,9 +746,7 @@ class SesV2IntegrationTest {
.statusCode(200);
// Send with only CcAddresses (no ToAddresses)
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "cc-only-sender@example.com",
@@ -868,9 +773,7 @@ class SesV2IntegrationTest {
@Test
@Order(55)
void sendEmail_raw_missingData() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "v2sender@example.com",
@@ -888,9 +791,7 @@ class SesV2IntegrationTest {
@Test
@Order(56)
void sendEmail_raw_missingFrom() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"Destination": {"ToAddresses": ["r@example.com"]},
@@ -912,9 +813,7 @@ class SesV2IntegrationTest {
@Test
@Order(67)
void sendEmail_raw_noFromAddress_usesMimeFrom() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "raw-from@floci.test"}
""")
@@ -923,9 +822,7 @@ class SesV2IntegrationTest {
.then()
.statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"Destination": {"ToAddresses": ["r@example.com"]},
@@ -942,9 +839,7 @@ class SesV2IntegrationTest {
@Test
@Order(68)
void sendEmail_simple_missingFrom() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"Destination": {"ToAddresses": ["r@example.com"]},
@@ -964,9 +859,7 @@ class SesV2IntegrationTest {
@Test
@Order(69)
void sendEmail_template_missingFrom() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"Destination": {"ToAddresses": ["r@example.com"]},
@@ -987,9 +880,7 @@ class SesV2IntegrationTest {
@Order(70)
void inspectionEndpoint_textAndHtmlAreStoredSeparately() {
// Create identity
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{"EmailIdentity": "inspect-sender@example.com"}
""")
@@ -1002,9 +893,7 @@ class SesV2IntegrationTest {
given().delete("/_aws/ses").then().statusCode(200);
// Send with distinct Text and Html bodies
String messageId = given()
.contentType("application/json")
.header("Authorization", AUTH)
String messageId = v2()
.body("""
{
"FromEmailAddress": "inspect-sender@example.com",
@@ -1044,9 +933,7 @@ class SesV2IntegrationTest {
void inspectionEndpoint_textOnlyEmail() {
given().delete("/_aws/ses").then().statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inspect-sender@example.com",
@@ -1082,9 +969,7 @@ class SesV2IntegrationTest {
void inspectionEndpoint_htmlOnlyEmail() {
given().delete("/_aws/ses").then().statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inspect-sender@example.com",
@@ -1120,9 +1005,7 @@ class SesV2IntegrationTest {
void inspectionEndpoint_replyToAddressesAreStored() {
given().delete("/_aws/ses").then().statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inspect-sender@example.com",
@@ -1156,9 +1039,7 @@ class SesV2IntegrationTest {
void inspectionEndpoint_noReplyToOmitsField() {
given().delete("/_aws/ses").then().statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inspect-sender@example.com",
@@ -1191,9 +1072,7 @@ class SesV2IntegrationTest {
void inspectionEndpoint_rawEmailReturnsRawData() {
given().delete("/_aws/ses").then().statusCode(200);
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "inspect-sender@example.com",
@@ -1243,9 +1122,7 @@ class SesV2IntegrationTest {
}
// Send from us-east-1
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.body("""
{
"FromEmailAddress": "multi@example.com",
@@ -1300,9 +1177,7 @@ class SesV2IntegrationTest {
@Test
@Order(60)
void getEmailIdentity_fullResponse() {
given()
.contentType("application/json")
.header("Authorization", AUTH)
v2()
.when()
.get("/v2/email/identities/dkim-test@example.com")
.then()