From df43df43f68edbdd4cc98ef046220c26600f0602 Mon Sep 17 00:00:00 2001 From: Kenshin Okinaka Date: Sun, 22 Nov 2026 13:51:24 +0900 Subject: [PATCH] test(ses): move the remaining SES integration tests onto SesV2Requests (#9177) --- .../ses/SesBulkV2IntegrationTest.java | 41 ++-- ...nSetEventDestinationV2IntegrationTest.java | 80 ++++--- ...onSetMessageSecurityV2IntegrationTest.java | 11 +- ...esConfigurationSetNameIntegrationTest.java | 10 +- ...ionSetSendingOptionsV2IntegrationTest.java | 37 ++- ...etSuppressionOptionsV2IntegrationTest.java | 3 +- ...onSetTrackingOptionsV1IntegrationTest.java | 6 +- .../SesConfigurationSetV2IntegrationTest.java | 210 +++++++++--------- .../SesContactFilterV2IntegrationTest.java | 36 ++- .../ses/SesContactListV2IntegrationTest.java | 51 +++-- .../ses/SesContactV2IntegrationTest.java | 55 +++-- ...icationEmailTemplateV1IntegrationTest.java | 4 +- ...icationEmailTemplateV2IntegrationTest.java | 3 +- .../SesDedicatedIpPoolV2IntegrationTest.java | 34 ++- .../ses/SesDedicatedIpV2IntegrationTest.java | 53 +++-- .../SesDkimSigningActionsIntegrationTest.java | 46 ++-- ...tityConfigurationSetV2IntegrationTest.java | 79 ++++--- .../SesEventPublishingV2IntegrationTest.java | 141 ++++++------ ...esIdentityAttributesV2IntegrationTest.java | 46 ++-- ...sIdentityCertificateV2IntegrationTest.java | 16 +- ...ficationTopicPublishV1IntegrationTest.java | 25 +-- .../SesIdentityPolicyV1IntegrationTest.java | 4 +- .../SesIdentityPolicyV2IntegrationTest.java | 3 +- .../ses/SesListFilterV2IntegrationTest.java | 60 +++-- ...tomVerificationEmailV2IntegrationTest.java | 3 +- .../SesSendVerifiedSenderIntegrationTest.java | 34 ++- ...SesSimpleAttachmentsV2IntegrationTest.java | 3 +- .../ses/SesSuppressionV2IntegrationTest.java | 82 ++++--- .../ses/SesTagArnV2IntegrationTest.java | 17 +- .../ses/SesTagsV2IntegrationTest.java | 174 +++++++-------- .../ses/SesTemplateNameIntegrationTest.java | 20 +- ...sTemplateRequiredPartsIntegrationTest.java | 12 +- .../SesTemplateTagOrderIntegrationTest.java | 3 +- .../ses/SesTemplateV2IntegrationTest.java | 74 +++--- .../ses/SesTenantV2IntegrationTest.java | 3 +- .../ses/SesTestRenderV2IntegrationTest.java | 26 +-- .../services/ses/SesV2IntegrationTest.java | 143 ++++++------ 37 files changed, 791 insertions(+), 857 deletions(-) diff --git a/src/test/java/io/floci/aws/services/ses/SesBulkV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesBulkV2IntegrationTest.java index 9681cf37e4..4447217eb0 100644 --- a/src/test/java/io/floci/aws/services/ses/SesBulkV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesBulkV2IntegrationTest.java @@ -13,6 +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.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.everyItem; @@ -26,8 +27,6 @@ import static org.hamcrest.Matchers.notNullValue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesBulkV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; // Senders of their own: an identity under example.com would outlive this class and reach the // other SES classes that share the application. private static final List SENDERS = @@ -42,7 +41,7 @@ class SesBulkV2IntegrationTest { for (String sender : SENDERS) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"EmailIdentity\": \"" + sender + "\"}") .when() .post("/v2/email/identities") @@ -51,7 +50,7 @@ class SesBulkV2IntegrationTest { } given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "v2-bulk-welcome", @@ -73,7 +72,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_storedTemplate_perEntryReplacement() { String firstId = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -116,7 +115,7 @@ class SesBulkV2IntegrationTest { String secondId = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2-second@floci.test", @@ -169,7 +168,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_inlineTemplateContent() { String messageId = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2-inline@floci.test", @@ -216,7 +215,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_unknownTemplate_returns404() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -240,7 +239,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_emptyEntries_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -263,7 +262,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_missingTemplate_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -285,7 +284,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_entriesExceeds50_returnsBadRequest() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -308,7 +307,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_perEntryMissingVariable_mapsToInvalidParameter() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -339,7 +338,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_malformedShape_returns400(String label, String body) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-bulk-emails") @@ -354,7 +353,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_nonObjectBody_isASerializationException(String body, String message) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-bulk-emails") @@ -370,7 +369,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_wrongMemberType_returnsSerializationException(String label, String body) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-bulk-emails") @@ -492,7 +491,7 @@ class SesBulkV2IntegrationTest { } given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -516,7 +515,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_fiftyEntries_sendsEachEntry() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2@floci.test", @@ -543,7 +542,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_missingEntries_isAModelViolation(String label, String entriesMember) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk@example.com", @@ -575,7 +574,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_entryCountIsCheckedBeforeLookups(String label, String body) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-bulk-emails") @@ -619,7 +618,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_earlierChecksWinOverEntryCount(String label, String body, String message) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-bulk-emails") @@ -649,7 +648,7 @@ class SesBulkV2IntegrationTest { void sendBulkEmail_emptyEntryBesideRecipients_failsOnlyThatEntry() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "bulk-v2-inline@floci.test", diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV2IntegrationTest.java index 9e9e69d284..9f5a725c34 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV2IntegrationTest.java @@ -10,6 +10,7 @@ import org.junit.jupiter.params.provider.CsvSource; import java.util.List; +import static io.floci.aws.services.ses.SesV2Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -24,9 +25,6 @@ import static org.hamcrest.Matchers.nullValue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetEventDestinationV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - private static final String CS = "v2-cs-ed"; private static final String SCOPED_AUTH_HEADER = @@ -43,7 +41,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { } given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"" + CS + "\"}") .when() .post("/v2/email/configuration-sets") @@ -56,7 +54,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void createEventDestination() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-sns", @@ -77,7 +75,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { @Order(3) void getEventDestinations_returnsRoundTrip() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS + "/event-destinations") .then() @@ -96,7 +94,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void createEventDestination_duplicateRejected() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-sns", @@ -120,7 +118,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void createEventDestination_unknownConfigSetReturns404() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-x", @@ -143,7 +141,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void createEventDestination_emptyMatchingEventTypes_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-empty", @@ -165,7 +163,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void createEventDestination_noDestination_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-nodest", @@ -186,7 +184,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void updateEventDestination_replacesDefinition() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestination": { @@ -202,7 +200,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS + "/event-destinations") .then() @@ -220,7 +218,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void updateEventDestination_unknownReturns404() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestination": { @@ -242,14 +240,14 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { @Order(10) void deleteEventDestination() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/configuration-sets/" + CS + "/event-destinations/ed-sns") .then() .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS + "/event-destinations") .then() @@ -261,7 +259,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { @Order(11) void deleteEventDestination_unknownReturns404() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/configuration-sets/" + CS + "/event-destinations/ed-ghost") .then() @@ -275,7 +273,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { @Order(12) void getEventDestinations_unknownConfigSetReturns404() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-ghost/event-destinations") .then() @@ -289,7 +287,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { void updateEventDestination_invalidName_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestination": { @@ -311,7 +309,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { @Order(14) void deleteEventDestination_invalidName_returns400() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/configuration-sets/" + CS + "/event-destinations/bad.name") .then() @@ -327,7 +325,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { String cs = "v2-cs-ed-multi"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"" + cs + "\"}") .when() .post("/v2/email/configuration-sets") @@ -337,7 +335,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { for (String n : new String[]{"ed-a", "ed-b"}) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "%s", @@ -356,7 +354,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestination": { @@ -372,7 +370,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + cs + "/event-destinations") .then() @@ -391,7 +389,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { String cs = "v2-cs-ed-ebus"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"" + cs + "\"}") .when() .post("/v2/email/configuration-sets") @@ -405,7 +403,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { String cs = "v2-cs-ed-ebus"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-eb-custom", @@ -427,7 +425,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { // The rejected destination must not have been stored. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + cs + "/event-destinations") .then() @@ -444,7 +442,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { // Seed a destination on the default event bus. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-eb-default", @@ -463,7 +461,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { // An otherwise identical ARN naming a custom event bus must be rejected. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestination": { @@ -484,7 +482,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { // The stored destination must still point at the default event bus. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + cs + "/event-destinations") .then() @@ -547,7 +545,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { String cs = "v2-cs-ed-ebus"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-eb-blank", @@ -582,7 +580,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { String destinationName = "ed-eb-invalid-create-" + caseName; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "%s", @@ -600,7 +598,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .body("__type", equalTo("BadRequestException")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + cs + "/event-destinations") .then() @@ -627,7 +625,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { String defaultBusArn = "arn:aws:events:us-east-1:000000000000:event-bus/default"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "%s", @@ -646,7 +644,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { try { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EventDestination": { @@ -663,7 +661,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .body("__type", equalTo("BadRequestException")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + cs + "/event-destinations") .then() @@ -676,7 +674,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { + ".EventBridgeDestination.EventBusArn", equalTo(defaultBusArn)); } finally { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/configuration-sets/" + cs + "/event-destinations/" + destinationName) .then() @@ -761,7 +759,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { String set = "v2-cs-sns-check"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"" + set + "\"}") .when() .post("/v2/email/configuration-sets") @@ -769,7 +767,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .statusCode(200); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body.replace("never-created", "x")) .when() .post("/v2/email/configuration-sets/" + set + "/event-destinations") @@ -777,7 +775,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .statusCode(200); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/configuration-sets/" + set + "/event-destinations") @@ -787,7 +785,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .body("message", equalTo(message)); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/configuration-sets/v2-cs-ghost/event-destinations") @@ -796,7 +794,7 @@ class SesConfigurationSetEventDestinationV2IntegrationTest { .body("message", equalTo(message)); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .put("/v2/email/configuration-sets/" + set + "/event-destinations/ed-sns") diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetMessageSecurityV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetMessageSecurityV2IntegrationTest.java index c702c7cd4b..bc908d1be4 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetMessageSecurityV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetMessageSecurityV2IntegrationTest.java @@ -7,6 +7,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 org.hamcrest.Matchers.anEmptyMap; import static org.hamcrest.Matchers.equalTo; @@ -24,8 +25,6 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetMessageSecurityV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String CS = "cs-message-security"; private static final String SMIME = "{\"SigningScheme\":{\"SmimeScheme\":{\"SignatureFormat\":\"DETACHED\"}}}"; private static final String DEFAULT = "{\"SigningScheme\":{\"DefaultScheme\":{}}}"; @@ -154,7 +153,7 @@ class SesConfigurationSetMessageSecurityV2IntegrationTest { .body("__type", equalTo("BadRequestException")) .body("message", equalTo(BAD_FORMAT_MESSAGE)); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/cs-message-security-bad") .then().statusCode(404); } @@ -188,19 +187,19 @@ class SesConfigurationSetMessageSecurityV2IntegrationTest { } private static ValidatableResponse create(String body) { - return given().contentType("application/json").header("Authorization", AUTH_HEADER).body(body) + return given().contentType("application/json").header("Authorization", AUTH).body(body) .when().post("/v2/email/configuration-sets") .then(); } private static ValidatableResponse update(String body) { - return given().contentType("application/json").header("Authorization", AUTH_HEADER).body(body) + return given().contentType("application/json").header("Authorization", AUTH).body(body) .when().post("/v2/email/update-configuration-sets") .then(); } private static ValidatableResponse get(String name) { - return given().header("Authorization", AUTH_HEADER) + return given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/" + name) .then().statusCode(200); } diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetNameIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetNameIntegrationTest.java index 229173978b..43777a71d6 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetNameIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetNameIntegrationTest.java @@ -13,8 +13,6 @@ import static org.hamcrest.Matchers.equalTo; @QuarkusTest class SesConfigurationSetNameIntegrationTest { - private static final String V2_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String V1_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String SIXTY_FIVE = @@ -23,7 +21,7 @@ class SesConfigurationSetNameIntegrationTest { @Test void v2_invalidCharacters_nameTheOffendingValue() { given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .get("/v2/email/configuration-sets/a.b") .then() @@ -36,7 +34,7 @@ class SesConfigurationSetNameIntegrationTest { @Test void v2_lengthIsCheckedBeforeCharacters() { given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .delete("/v2/email/configuration-sets/b." + SIXTY_FIVE) .then() @@ -49,7 +47,7 @@ class SesConfigurationSetNameIntegrationTest { void v2_createWithEmptyName_mustBeSpecified() { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"ConfigurationSetName\": \"\"}") .when() .post("/v2/email/configuration-sets") @@ -63,7 +61,7 @@ class SesConfigurationSetNameIntegrationTest { void v2_createWithInvalidName_rejectsBeforeStoring() { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"ConfigurationSetName\": \"bad name\"}") .when() .post("/v2/email/configuration-sets") diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java index 2bc1add199..fc82d09e40 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSendingOptionsV2IntegrationTest.java @@ -7,6 +7,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 org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -24,8 +25,6 @@ import static org.hamcrest.Matchers.equalTo; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetSendingOptionsV2IntegrationTest { - private static final String SES_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String CS = "cs-sending-options"; // A sender of its own, verified below: the identity outlives this class, and other SES classes // that share the application create sender@example.com themselves. @@ -36,7 +35,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { void verifySender() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", SENDER) .when() @@ -50,7 +49,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { void createConfigurationSet() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when() .post("/v2/email/configuration-sets") @@ -62,7 +61,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { @Order(2) void getConfigurationSet_defaultSendingEnabledTrue() { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS) .then() @@ -82,7 +81,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { void putSendingOptions_disableViaV2() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"SendingEnabled\":false}") .when() .put("/v2/email/configuration-sets/" + CS + "/sending") @@ -94,7 +93,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { @Order(5) void getConfigurationSet_reflectsDisabled() { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS) .then() @@ -120,7 +119,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { // narrows this to SendingPausedException for v2 callers only. given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .formParam("Action", "SendEmail") .formParam("Source", SENDER) .formParam("Destination.ToAddresses.member.1", "recipient@example.com") @@ -141,7 +140,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { void v1_describeConfigurationSet_reputationOptions_reflectsDisabled() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .formParam("Action", "DescribeConfigurationSet") .formParam("ConfigurationSetName", CS) .formParam("ConfigurationSetAttributeNames.member.1", "reputationOptions") @@ -157,7 +156,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { void v1_updateConfigurationSetSendingEnabled_reEnables() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .formParam("Action", "UpdateConfigurationSetSendingEnabled") .formParam("ConfigurationSetName", CS) .formParam("Enabled", "true") @@ -177,7 +176,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { @Order(11) void getConfigurationSet_reflectsReEnabled() { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS) .then() @@ -192,14 +191,14 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { // disables sending (verified against real AWS). Sending is enabled here from @Order(9). given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .put("/v2/email/configuration-sets/" + CS + "/sending") .then() .statusCode(200); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS) .then() @@ -214,7 +213,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { // persisted value, not just the status — CS was disabled by @Order(12). given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"SendingEnabled\":\"yes\"}") .when() .put("/v2/email/configuration-sets/" + CS + "/sending") @@ -222,7 +221,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + CS) .then() @@ -237,7 +236,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { // matching CreateConfigurationSet's deserialization. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"SendingEnabled\":null}") .when() .put("/v2/email/configuration-sets/" + CS + "/sending") @@ -251,7 +250,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { void putSendingOptions_unknownConfigSet_returns404_NotFoundException() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"SendingEnabled\":false}") .when() .put("/v2/email/configuration-sets/does-not-exist/sending") @@ -269,7 +268,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { // silently coerced to false (which would disable sending without the caller realizing). given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .formParam("Action", "UpdateConfigurationSetSendingEnabled") .formParam("ConfigurationSetName", CS) .formParam("Enabled", "yes") @@ -284,7 +283,7 @@ class SesConfigurationSetSendingOptionsV2IntegrationTest { private static Response sendEmail(String configSet) { return given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.java index 0c88d4de49..311d874f35 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetSuppressionOptionsV2IntegrationTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.api.TestMethodOrder; import java.util.List; +import static io.floci.aws.services.ses.SesV2Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; @@ -30,8 +31,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetSuppressionOptionsV2IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String REGION = "us-east-1"; private static final String CS = "cs-suppression-options"; diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetTrackingOptionsV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetTrackingOptionsV1IntegrationTest.java index a7f2066729..9f4e5ea8c2 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetTrackingOptionsV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetTrackingOptionsV1IntegrationTest.java @@ -26,8 +26,6 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { private static final String AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - private static final String AUTH_V2 = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String DOMAIN = "track-v1.floci.test"; private static final String CS = "v1-cs-tracking"; @@ -41,7 +39,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(1) void setup_verifyDomain_andCreateConfigSet() { - SesDomainIdentityTestHelper.createVerified(DOMAIN, AUTH_V2); + SesDomainIdentityTestHelper.createVerified(DOMAIN, SesV2Requests.AUTH); query("CreateConfigurationSet").formParam("ConfigurationSet.Name", CS) .when().post("/").then().statusCode(200); } @@ -101,7 +99,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(6) void updateTrackingOptions_changesDomain() { - SesDomainIdentityTestHelper.createVerified("other." + DOMAIN, AUTH_V2); + SesDomainIdentityTestHelper.createVerified("other." + DOMAIN, SesV2Requests.AUTH); query("UpdateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .formParam("TrackingOptions.CustomRedirectDomain", "other." + DOMAIN) diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV2IntegrationTest.java index 32ba720d8d..71c59544dc 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV2IntegrationTest.java @@ -6,6 +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 org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -19,15 +20,12 @@ import static org.hamcrest.Matchers.nullValue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void createConfigurationSet() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-alpha", @@ -45,7 +43,7 @@ class SesConfigurationSetV2IntegrationTest { void createConfigurationSet_duplicateRejected() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "v2-cs-alpha"} """) @@ -61,7 +59,7 @@ class SesConfigurationSetV2IntegrationTest { void createConfigurationSet_missingName() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{}") .when() .post("/v2/email/configuration-sets") @@ -74,7 +72,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(5) void getConfigurationSet_returnsRoundTrip() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-alpha") .then() @@ -88,7 +86,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(6) void getConfigurationSet_unknownReturns404() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-ghost") .then() @@ -101,7 +99,7 @@ class SesConfigurationSetV2IntegrationTest { void listConfigurationSets() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "v2-cs-beta"} """) @@ -111,7 +109,7 @@ class SesConfigurationSetV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets") .then() @@ -124,14 +122,14 @@ class SesConfigurationSetV2IntegrationTest { @Order(8) void deleteConfigurationSet() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/configuration-sets/v2-cs-alpha") .then() .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-alpha") .then() @@ -142,7 +140,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(9) void deleteConfigurationSet_unknownReturns404() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/configuration-sets/v2-cs-ghost") .then() @@ -155,7 +153,7 @@ class SesConfigurationSetV2IntegrationTest { void createConfigurationSet_invalidNameCharacters() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "bad name!"} """) @@ -172,7 +170,7 @@ class SesConfigurationSetV2IntegrationTest { String longName = "a".repeat(65); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "%s"} """.formatted(longName)) @@ -188,7 +186,7 @@ class SesConfigurationSetV2IntegrationTest { void createConfigurationSet_tagWithMissingValue_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-tag-no-value", @@ -209,7 +207,7 @@ class SesConfigurationSetV2IntegrationTest { void createConfigurationSet_tagWithMissingKey_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-bad-tag-key", @@ -229,7 +227,7 @@ class SesConfigurationSetV2IntegrationTest { String longKey = "k".repeat(129); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-long-tag-key", @@ -249,7 +247,7 @@ class SesConfigurationSetV2IntegrationTest { String longValue = "v".repeat(257); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-long-tag-value", @@ -270,7 +268,7 @@ class SesConfigurationSetV2IntegrationTest { // the ListTagsForResource endpoint, not just GET configuration-sets/{name}. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-tag-roundtrip", @@ -287,7 +285,7 @@ class SesConfigurationSetV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/v2-cs-tag-roundtrip"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -305,7 +303,7 @@ class SesConfigurationSetV2IntegrationTest { // (verified against real AWS SES V2 on 2026-06-12). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-inline-options", @@ -319,7 +317,7 @@ class SesConfigurationSetV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-inline-options") .then() @@ -338,7 +336,7 @@ class SesConfigurationSetV2IntegrationTest { // 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-bad-reason", @@ -357,7 +355,7 @@ class SesConfigurationSetV2IntegrationTest { // Validation happens before the store write, so the set must not exist. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-bad-reason") .then() @@ -372,7 +370,7 @@ class SesConfigurationSetV2IntegrationTest { // (verified against real AWS SES V2 on 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-string-sending", @@ -385,7 +383,7 @@ class SesConfigurationSetV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-string-sending") .then() @@ -401,7 +399,7 @@ class SesConfigurationSetV2IntegrationTest { // defaults to true (verified against real AWS SES V2 on 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-empty-sending", @@ -414,7 +412,7 @@ class SesConfigurationSetV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-empty-sending") .then() @@ -429,7 +427,7 @@ class SesConfigurationSetV2IntegrationTest { // set is not created (verified against real AWS SES V2 on 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-null-sending", @@ -443,7 +441,7 @@ class SesConfigurationSetV2IntegrationTest { .body("__type", equalTo("SerializationException")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-null-sending") .then() @@ -456,7 +454,7 @@ class SesConfigurationSetV2IntegrationTest { // Verified against real AWS SES V2 on 2026-06-13. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-number-sending", @@ -480,7 +478,7 @@ class SesConfigurationSetV2IntegrationTest { // 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-empty-suppression", @@ -495,7 +493,7 @@ class SesConfigurationSetV2IntegrationTest { .body("message", equalTo("An internal failure has occurred.")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-empty-suppression") .then() @@ -508,7 +506,7 @@ class SesConfigurationSetV2IntegrationTest { // Verified against real AWS SES V2 on 2026-06-13. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-string-reasons", @@ -530,7 +528,7 @@ class SesConfigurationSetV2IntegrationTest { // (verified against real AWS SES V2 on 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-empty-reasons", @@ -543,7 +541,7 @@ class SesConfigurationSetV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-empty-reasons") .then() @@ -560,7 +558,7 @@ class SesConfigurationSetV2IntegrationTest { // (verified against real AWS SES V2 on 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-null-reason", @@ -575,7 +573,7 @@ class SesConfigurationSetV2IntegrationTest { .body("message", equalTo("Reason null is invalid, must be one of [BOUNCE, COMPLAINT].")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/v2-cs-null-reason") .then() @@ -588,7 +586,7 @@ class SesConfigurationSetV2IntegrationTest { // Verified against real AWS SES V2 on 2026-06-13. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-boolean-reason", @@ -611,7 +609,7 @@ class SesConfigurationSetV2IntegrationTest { // 2026-06-13). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-string-suppression", @@ -627,7 +625,7 @@ class SesConfigurationSetV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "ConfigurationSetName": "v2-cs-string-options", @@ -649,7 +647,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(30) void getConfigurationSet_reputationOptions_defaultsEnabled() { putConfigSet("v2-cs-rep-default"); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-rep-default") .then().statusCode(200) .body("ReputationOptions.ReputationMetricsEnabled", equalTo(true)); @@ -659,11 +657,11 @@ class SesConfigurationSetV2IntegrationTest { @Order(31) void putReputationOptions_disables_andEchoes() { putConfigSet("v2-cs-rep"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ReputationMetricsEnabled\": false}") .when().put("/v2/email/configuration-sets/v2-cs-rep/reputation-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-rep") .then().statusCode(200) .body("ReputationOptions.ReputationMetricsEnabled", equalTo(false)); @@ -672,13 +670,13 @@ class SesConfigurationSetV2IntegrationTest { @Test @Order(32) void createConfigurationSet_inlineReputation_echoed() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "v2-cs-rep-inline", "ReputationOptions": {"ReputationMetricsEnabled": false}} """) .when().post("/v2/email/configuration-sets").then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-rep-inline") .then().statusCode(200) .body("ReputationOptions.ReputationMetricsEnabled", equalTo(false)); @@ -688,11 +686,11 @@ class SesConfigurationSetV2IntegrationTest { @Order(33) void putDeliveryOptions_echoed() { putConfigSet("v2-cs-delivery"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TlsPolicy\": \"REQUIRE\", \"MaxDeliverySeconds\": 300}") .when().put("/v2/email/configuration-sets/v2-cs-delivery/delivery-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-delivery") .then().statusCode(200) .body("DeliveryOptions.TlsPolicy", equalTo("REQUIRE")) @@ -703,7 +701,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(34) void putDeliveryOptions_nonexistentPool_returns400() { putConfigSet("v2-cs-delivery-pool"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TlsPolicy\": \"OPTIONAL\", \"SendingPoolName\": \"ghost-pool\"}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-pool/delivery-options") .then().statusCode(400) @@ -716,11 +714,11 @@ 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ArchiveArn\": \"" + arn + "\"}") .when().put("/v2/email/configuration-sets/v2-cs-archiving/archiving-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-archiving") .then().statusCode(200) .body("ArchivingOptions.ArchiveArn", equalTo(arn)); @@ -734,11 +732,11 @@ 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ArchiveArn\": \"" + arn + "\"}") .when().put("/v2/email/configuration-sets/v2-cs-archiving-any/archiving-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-archiving-any") .then().statusCode(200) .body("ArchivingOptions.ArchiveArn", equalTo(arn)); @@ -747,13 +745,13 @@ class SesConfigurationSetV2IntegrationTest { @Test @Order(37) void putTrackingOptions_verifiedDomain_echoed() { - SesDomainIdentityTestHelper.createVerified("track.floci.test", AUTH_HEADER); + SesDomainIdentityTestHelper.createVerified("track.floci.test", AUTH); putConfigSet("v2-cs-tracking"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \"track.floci.test\", \"HttpsPolicy\": \"REQUIRE\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking/tracking-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-tracking") .then().statusCode(200) .body("TrackingOptions.CustomRedirectDomain", equalTo("track.floci.test")) @@ -764,7 +762,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(38) void putTrackingOptions_unverifiedDomain_returns400() { putConfigSet("v2-cs-tracking-unverified"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \"never-verified.example.com\", \"HttpsPolicy\": \"REQUIRE\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-unverified/tracking-options") .then().statusCode(400) @@ -777,9 +775,9 @@ class SesConfigurationSetV2IntegrationTest { void putTrackingOptions_invalidHttpsPolicy_returns400() { // AWS validates the HttpsPolicy enum only after CustomRedirectDomain // presence and verification, so the domain must be verified to reach it. - SesDomainIdentityTestHelper.createVerified("track-enum.floci.test", AUTH_HEADER); + SesDomainIdentityTestHelper.createVerified("track-enum.floci.test", AUTH); putConfigSet("v2-cs-tracking-enum"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \"track-enum.floci.test\", \"HttpsPolicy\": \"BOGUS\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-enum/tracking-options") .then().statusCode(400) @@ -792,11 +790,11 @@ class SesConfigurationSetV2IntegrationTest { @Test @Order(100) void putTrackingOptions_pendingDomain_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \"track-pending.floci.test\", \"HttpsPolicy\": \"REQUIRE\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-pending/tracking-options") .then().statusCode(400) @@ -811,11 +809,11 @@ 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/configuration-sets/v2-cs-rep-empty/reputation-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-rep-empty") .then().statusCode(200) .body("ReputationOptions.ReputationMetricsEnabled", equalTo(false)); @@ -825,7 +823,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(41) void putDeliveryOptions_invalidTlsPolicy_returns400() { putConfigSet("v2-cs-delivery-tls"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TlsPolicy\": \"MAYBE\"}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-tls/delivery-options") .then().statusCode(400) @@ -839,7 +837,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(42) void putDeliveryOptions_nonNumericMaxDeliverySeconds_returns400() { putConfigSet("v2-cs-delivery-max"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TlsPolicy\": \"REQUIRE\", \"MaxDeliverySeconds\": \"soon\"}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-max/delivery-options") .then().statusCode(400) @@ -851,7 +849,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(43) void putTrackingOptions_nonStringHttpsPolicy_returns400() { putConfigSet("v2-cs-tracking-type"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"HttpsPolicy\": 123}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-type/tracking-options") .then().statusCode(400) @@ -863,7 +861,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(44) void putArchivingOptions_nonStringArn_returns400() { putConfigSet("v2-cs-archiving-type"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ArchiveArn\": true}") .when().put("/v2/email/configuration-sets/v2-cs-archiving-type/archiving-options") .then().statusCode(400) @@ -877,7 +875,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TlsPolicy\": \"REQUIRE\", \"MaxDeliverySeconds\": 1.5}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-frac/delivery-options") .then().statusCode(400) @@ -891,7 +889,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"HttpsPolicy\": \"REQUIRE\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-nodomain/tracking-options") .then().statusCode(400) @@ -905,7 +903,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \"unverified-order.example.com\", \"HttpsPolicy\": \"BOGUS\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-order/tracking-options") .then().statusCode(400) @@ -918,11 +916,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \"redirect@floci.test\", \"HttpsPolicy\": \"REQUIRE\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-email-id/tracking-options") .then().statusCode(400) @@ -937,7 +935,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \" \"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-blank/tracking-options") .then().statusCode(400) @@ -950,7 +948,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"CustomRedirectDomain\": \"never-verified-nopolicy.example.com\"}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-nopolicy/tracking-options") .then().statusCode(400) @@ -963,20 +961,20 @@ class SesConfigurationSetV2IntegrationTest { void putTrackingOptions_emptyBody_clears() { // An empty PUT body clears tracking options rather than persisting an // empty block that GetConfigurationSet would echo as {}. - SesDomainIdentityTestHelper.createVerified("clear.floci.test", AUTH_HEADER); + SesDomainIdentityTestHelper.createVerified("clear.floci.test", AUTH); putConfigSet("v2-cs-tracking-clear"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .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_HEADER) + 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/configuration-sets/v2-cs-tracking-clear/tracking-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-tracking-clear") .then().statusCode(200).body("TrackingOptions", nullValue()); } @@ -985,18 +983,18 @@ class SesConfigurationSetV2IntegrationTest { @Order(52) void putDeliveryOptions_emptyBody_clears() { putConfigSet("v2-cs-delivery-clear"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TlsPolicy\": \"REQUIRE\"}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-clear/delivery-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-clear/delivery-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-delivery-clear") .then().statusCode(200).body("DeliveryOptions", nullValue()); } @@ -1007,7 +1005,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"SendingPoolName\": \" \"}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-blankpool/delivery-options") .then().statusCode(400) @@ -1019,7 +1017,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(54) void putDeliveryOptions_maxDeliverySecondsBelowMinimum_returns400() { putConfigSet("v2-cs-delivery-min"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"MaxDeliverySeconds\": 5}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-min/delivery-options") .then().statusCode(400) @@ -1033,7 +1031,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(55) void putDeliveryOptions_maxDeliverySecondsAboveMaximum_returns400() { putConfigSet("v2-cs-delivery-overmax"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"MaxDeliverySeconds\": 999999}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-overmax/delivery-options") .then().statusCode(400) @@ -1047,12 +1045,12 @@ class SesConfigurationSetV2IntegrationTest { @Order(56) void putVdmOptions_echoed() { putConfigSet("v2-cs-vdm"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"ENABLED\"}, " + "\"GuardianOptions\": {\"OptimizedSharedDelivery\": \"DISABLED\"}}}") .when().put("/v2/email/configuration-sets/v2-cs-vdm/vdm-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-vdm") .then().statusCode(200) .body("VdmOptions.DashboardOptions.EngagementMetrics", equalTo("ENABLED")) @@ -1063,7 +1061,7 @@ class SesConfigurationSetV2IntegrationTest { @Order(57) void putVdmOptions_invalidEngagementMetrics_returns400() { putConfigSet("v2-cs-vdm-bad"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"NONSENSE\"}}}") .when().put("/v2/email/configuration-sets/v2-cs-vdm-bad/vdm-options") .then().statusCode(400) @@ -1076,11 +1074,11 @@ class SesConfigurationSetV2IntegrationTest { @Test @Order(58) void createConfigurationSet_inlineVdm_echoed() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"v2-cs-vdm-inline\", " + "\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"DISABLED\"}}}") .when().post("/v2/email/configuration-sets").then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-vdm-inline") .then().statusCode(200) .body("VdmOptions.DashboardOptions.EngagementMetrics", equalTo("DISABLED")); @@ -1090,18 +1088,18 @@ class SesConfigurationSetV2IntegrationTest { @Order(59) void putVdmOptions_emptyBody_clears() { putConfigSet("v2-cs-vdm-clear"); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"ENABLED\"}}}") .when().put("/v2/email/configuration-sets/v2-cs-vdm-clear/vdm-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/configuration-sets/v2-cs-vdm-clear/vdm-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-vdm-clear") .then().statusCode(200).body("VdmOptions", nullValue()); } @@ -1109,7 +1107,7 @@ class SesConfigurationSetV2IntegrationTest { @Test @Order(60) void createConfigurationSet_invalidInlineVdm_returns400_andDoesNotCreate() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"v2-cs-vdm-inline-bad\", " + "\"VdmOptions\": {\"DashboardOptions\": {\"EngagementMetrics\": \"NONSENSE\"}}}") .when().post("/v2/email/configuration-sets") @@ -1120,7 +1118,7 @@ class SesConfigurationSetV2IntegrationTest { + "Member must satisfy enum value set: [ENABLED, DISABLED]")); // Validation happens before the store write, so the set must not exist. - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-vdm-inline-bad") .then().statusCode(404) .body("__type", equalTo("NotFoundException")); @@ -1132,15 +1130,15 @@ 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TlsPolicy\": \"REQUIRE\", \"SendingPoolName\": \"v2-cs-pool-ref\"}") .when().put("/v2/email/configuration-sets/v2-cs-delivery-poolref/delivery-options") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/configuration-sets/v2-cs-delivery-poolref") .then().statusCode(200) .body("DeliveryOptions.SendingPoolName", equalTo("v2-cs-pool-ref")); @@ -1152,7 +1150,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"v2-cs-nonstr-key\", \"Tags\": [{\"Key\": 123, \"Value\": \"v\"}]}") .when().post("/v2/email/configuration-sets") .then().statusCode(400).body("__type", equalTo("SerializationException")); @@ -1162,12 +1160,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .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")); @@ -1181,7 +1179,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"v2-cs-bad-el\", \"Tags\": [" + badElement + "]}") .when().post("/v2/email/configuration-sets") .then().statusCode(400).body("__type", equalTo("SerializationException")); @@ -1189,7 +1187,7 @@ class SesConfigurationSetV2IntegrationTest { } private static void putConfigSet(String name) { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\": \"" + name + "\"}") .when().post("/v2/email/configuration-sets").then().statusCode(200); } diff --git a/src/test/java/io/floci/aws/services/ses/SesContactFilterV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesContactFilterV2IntegrationTest.java index 2d75d5eccd..884a8a468e 100644 --- a/src/test/java/io/floci/aws/services/ses/SesContactFilterV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesContactFilterV2IntegrationTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import static io.restassured.RestAssured.given; +import static io.floci.aws.services.ses.SesV2Requests.post; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; @@ -21,8 +21,7 @@ import static org.hamcrest.Matchers.nullValue; class SesContactFilterV2IntegrationTest { private static final String REGION = "me-central-1"; - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/" + REGION + "/ses/aws4_request"; + private static final String AUTH = SesV2Requests.authFor(REGION); private static final String LIST = "filter-wire"; private static final String CONTACTS = "/v2/email/contact-lists/" + LIST + "/contacts"; @@ -34,7 +33,7 @@ class SesContactFilterV2IntegrationTest { if (created) { return; } - send("/v2/email/contact-lists", """ + post(AUTH, "/v2/email/contact-lists", """ {"ContactListName": "%s", "Topics": [ {"TopicName": "news", "DisplayName": "News", "DefaultSubscriptionStatus": "OPT_IN"}]} """.formatted(LIST)).statusCode(200); @@ -73,7 +72,7 @@ class SesContactFilterV2IntegrationTest { @Test void useDefault_rejectsAStringThatIsNotABoolean() { - send(CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + post(AUTH, CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + "{\"TopicName\": \"news\", \"UseDefaultIfPreferenceUnavailable\": \"abc\"}}}") .statusCode(400) .body("__type", equalTo("SerializationException")) @@ -82,13 +81,13 @@ class SesContactFilterV2IntegrationTest { @Test void errors_carryTheProbedStatusesAndMessages() { - send(CONTACTS + "/list", "{\"Filter\": {}}").statusCode(400) + post(AUTH, CONTACTS + "/list", "{\"Filter\": {}}").statusCode(400) .body("__type", equalTo("BadRequestException")) .body("message", equalTo("Invalid FilteredStatus ")); - send(CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": {}}}") + post(AUTH, CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": {}}}") .statusCode(400) .body("message", equalTo("TopicName can't be blank in TopicFilter.")); - send(CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + post(AUTH, CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + "{\"TopicName\": \"nope\"}}}") .statusCode(404) .body("__type", equalTo("NotFoundException")) @@ -97,25 +96,25 @@ class SesContactFilterV2IntegrationTest { @Test void wrongJsonTypes_areSerializationExceptions() { - send(CONTACTS + "/list", "{\"Filter\": []}").statusCode(400) + post(AUTH, CONTACTS + "/list", "{\"Filter\": []}").statusCode(400) .body("__type", equalTo("SerializationException")) .body("message", equalTo("Start of list found where not expected")); - send(CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": \"x\"}}") + post(AUTH, CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": \"x\"}}") .statusCode(400) .body("__type", equalTo("SerializationException")) .body("message", equalTo("Expected null")); - send(CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": 1}, \"PageSize\": 0}").statusCode(400) + post(AUTH, CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": 1}, \"PageSize\": 0}").statusCode(400) .body("__type", equalTo("SerializationException")) .body("message", equalTo("NUMBER_VALUE can not be converted to a String")); } @Test void topicName_isMatchedExactly() { - send(CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + post(AUTH, CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + "{\"TopicName\": \" news \"}}}") .statusCode(404) .body("message", equalTo("List: " + LIST + " doesn't contain Topic: news ")); - send(CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + post(AUTH, CONTACTS + "/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", \"TopicFilter\": " + "{\"TopicName\": \" \"}}}") .statusCode(400) .body("message", equalTo("TopicName can't be blank in TopicFilter.")); @@ -129,24 +128,19 @@ class SesContactFilterV2IntegrationTest { @Test void filterOnAMissingList_reportsTheListBeforeTheTopic() { - send("/v2/email/contact-lists/ghost/contacts/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", " + post(AUTH, "/v2/email/contact-lists/ghost/contacts/list", "{\"Filter\": {\"FilteredStatus\": \"OPT_IN\", " + "\"TopicFilter\": {\"TopicName\": \"nope\"}}}") .statusCode(404) .body("message", equalTo("List with name: ghost doesn't exist.")); } private void contact(String name, String preference, boolean unsubscribeAll) { - send(CONTACTS, """ + post(AUTH, CONTACTS, """ {"EmailAddress": "%s@example.com", "TopicPreferences": [%s], "UnsubscribeAll": %s} """.formatted(name, preference, unsubscribeAll)).statusCode(200); } private static ValidatableResponse list(String body) { - return send(CONTACTS + "/list", body).statusCode(200); - } - - private static ValidatableResponse send(String path, String body) { - return given().contentType("application/json").header("Authorization", AUTH).body(body) - .when().post(path).then(); + return post(AUTH, CONTACTS + "/list", body).statusCode(200); } } diff --git a/src/test/java/io/floci/aws/services/ses/SesContactListV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesContactListV2IntegrationTest.java index e37dcb691b..8a9cb392a3 100644 --- a/src/test/java/io/floci/aws/services/ses/SesContactListV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesContactListV2IntegrationTest.java @@ -7,6 +7,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.floci.aws.services.ses.SesV2TimestampMatchers.DECIMAL_NUMBERS; import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis; import static io.restassured.RestAssured.given; @@ -25,8 +26,6 @@ import static org.hamcrest.Matchers.hasSize; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesContactListV2IntegrationTest { - private static final String SES_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String LIST = "my-newsletter"; private static final String CREATE_BODY = "{" @@ -44,7 +43,7 @@ class SesContactListV2IntegrationTest { void createContactList() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(CREATE_BODY) .when() .post("/v2/email/contact-lists") @@ -57,7 +56,7 @@ class SesContactListV2IntegrationTest { void getContactList_returnsShape() { given() .config(DECIMAL_NUMBERS) - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists/" + LIST) .then() @@ -77,7 +76,7 @@ class SesContactListV2IntegrationTest { void listContactLists_containsList() { given() .config(DECIMAL_NUMBERS) - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists") .then() @@ -91,7 +90,7 @@ class SesContactListV2IntegrationTest { void createSecondContactList_rejectedByPerAccountLimit() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ContactListName\":\"second-list\"}") .when() .post("/v2/email/contact-lists") @@ -108,7 +107,7 @@ class SesContactListV2IntegrationTest { // so AWS never returns AlreadyExistsException here. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ContactListName\":\"" + LIST + "\"}") .when() .post("/v2/email/contact-lists") @@ -123,7 +122,7 @@ class SesContactListV2IntegrationTest { void createContactList_invalidTopicStatus_returns400() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ContactListName\":\"bad-list\",\"Topics\":[" + "{\"TopicName\":\"t\",\"DisplayName\":\"T\"," + "\"DefaultSubscriptionStatus\":\"MAYBE\"}]}") @@ -142,7 +141,7 @@ class SesContactListV2IntegrationTest { void updateContactList_replacesTopicsAndDescription() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"Description\":\"updated\",\"Topics\":[" + "{\"TopicName\":\"monthly\",\"DisplayName\":\"Monthly\"," + "\"DefaultSubscriptionStatus\":\"OPT_IN\"}]}") @@ -152,7 +151,7 @@ class SesContactListV2IntegrationTest { .statusCode(200); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists/" + LIST) .then() @@ -164,7 +163,7 @@ class SesContactListV2IntegrationTest { // An explicit-null Topics is treated as "not provided" and preserves existing topics. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"Topics\":null,\"Description\":\"kept-topics\"}") .when() .put("/v2/email/contact-lists/" + LIST) @@ -172,7 +171,7 @@ class SesContactListV2IntegrationTest { .statusCode(200); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists/" + LIST) .then() @@ -184,7 +183,7 @@ class SesContactListV2IntegrationTest { // An empty body is accepted as a no-op update (200), matching real AWS. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .put("/v2/email/contact-lists/" + LIST) .then() @@ -195,7 +194,7 @@ class SesContactListV2IntegrationTest { @Order(8) void getContactList_unknown_returns404() { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists/does-not-exist") .then() @@ -209,7 +208,7 @@ class SesContactListV2IntegrationTest { void updateContactList_unknown_returns404() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"Description\":\"x\"}") .when() .put("/v2/email/contact-lists/does-not-exist") @@ -222,21 +221,21 @@ class SesContactListV2IntegrationTest { @Order(10) void deleteContactList_thenGoneAndSlotFreed() { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .delete("/v2/email/contact-lists/" + LIST) .then() .statusCode(200); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists/" + LIST) .then() .statusCode(404); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists") .then() @@ -246,7 +245,7 @@ class SesContactListV2IntegrationTest { // The single-list slot is freed, so a new list can be created. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ContactListName\":\"fresh-list\"}") .when() .post("/v2/email/contact-lists") @@ -254,7 +253,7 @@ class SesContactListV2IntegrationTest { .statusCode(200); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .delete("/v2/email/contact-lists/fresh-list") .then() @@ -266,7 +265,7 @@ class SesContactListV2IntegrationTest { void createContactList_missingName_returnsSmithyValidationError() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{}") .when() .post("/v2/email/contact-lists") @@ -282,7 +281,7 @@ class SesContactListV2IntegrationTest { void createContactList_topicMissingTopicName_returnsSmithyValidationError() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ContactListName\":\"x\",\"Topics\":[" + "{\"DisplayName\":\"T\",\"DefaultSubscriptionStatus\":\"OPT_IN\"}]}") .when() @@ -369,7 +368,7 @@ class SesContactListV2IntegrationTest { @Order(20) void getContactList_invalidName_returns400NotNotFound() { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/contact-lists/" + "a".repeat(65)) .then() @@ -383,7 +382,7 @@ class SesContactListV2IntegrationTest { @Order(21) void deleteContactList_invalidName_returns400NotNotFound() { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .delete("/v2/email/contact-lists/" + "a".repeat(65)) .then() @@ -423,7 +422,7 @@ class SesContactListV2IntegrationTest { // Same two-phase order on update: the Smithy enum error wins over the invalid path name. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"Topics\":[{\"TopicName\":\"t\",\"DisplayName\":\"T\"," + "\"DefaultSubscriptionStatus\":\"MAYBE\"}]}") .when() @@ -449,7 +448,7 @@ class SesContactListV2IntegrationTest { private static Response post(String body) { return given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/contact-lists"); diff --git a/src/test/java/io/floci/aws/services/ses/SesContactV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesContactV2IntegrationTest.java index 07e47ae5a5..adee912664 100644 --- a/src/test/java/io/floci/aws/services/ses/SesContactV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesContactV2IntegrationTest.java @@ -8,6 +8,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.floci.aws.services.ses.SesV2TimestampMatchers.DECIMAL_NUMBERS; import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis; import static io.restassured.RestAssured.given; @@ -24,21 +25,19 @@ import static org.hamcrest.Matchers.hasSize; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesContactV2IntegrationTest { - private static final String SES_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String LIST = "contacts-it-list"; private static final String EMAIL = "alice@example.com"; 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", SES_AUTH) + return given().contentType("application/json").header("Authorization", AUTH) .body(body).when().post(path); } @Test @Order(1) void setup_createContactList() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ContactListName\":\"" + LIST + "\",\"Topics\":[" + "{\"TopicName\":\"weekly\",\"DisplayName\":\"Weekly\",\"DefaultSubscriptionStatus\":\"OPT_IN\"}," + "{\"TopicName\":\"promos\",\"DisplayName\":\"Promos\",\"DefaultSubscriptionStatus\":\"OPT_OUT\"}]}") @@ -57,7 +56,7 @@ class SesContactV2IntegrationTest { @Test @Order(3) void getContact_shape() { - given().config(DECIMAL_NUMBERS).header("Authorization", SES_AUTH) + given().config(DECIMAL_NUMBERS).header("Authorization", AUTH) .when().get(CONTACTS + "/" + EMAIL) .then().statusCode(200) .body("EmailAddress", equalTo(EMAIL)) @@ -86,7 +85,7 @@ class SesContactV2IntegrationTest { @Test @Order(5) void getContact_unknownEmail_returns404() { - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get(CONTACTS + "/ghost@example.com") .then().statusCode(404) .body("__type", equalTo("NotFoundException")) @@ -96,7 +95,7 @@ class SesContactV2IntegrationTest { @Test @Order(6) void getContact_unknownList_returns404() { - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/contact-lists/does-not-exist/contacts/" + EMAIL) .then().statusCode(404) .body("message", equalTo("List with name: does-not-exist doesn't exist.")); @@ -146,11 +145,11 @@ class SesContactV2IntegrationTest { @Test @Order(11) void updateContact_unsubscribeAll_replacesAttributesKeepsPreferences() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"UnsubscribeAll\":true}") .when().put(CONTACTS + "/" + EMAIL).then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get(CONTACTS + "/" + EMAIL) .then().statusCode(200) .body("UnsubscribeAll", equalTo(true)) @@ -163,11 +162,11 @@ class SesContactV2IntegrationTest { @Test @Order(12) void updateContact_topicPreferences_mergeByTopicName() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"TopicPreferences\":[{\"TopicName\":\"promos\",\"SubscriptionStatus\":\"OPT_IN\"}]}") .when().put(CONTACTS + "/" + EMAIL).then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get(CONTACTS + "/" + EMAIL) .then().statusCode(200) // Merged: existing weekly kept + promos added; no topic left for defaults. @@ -178,7 +177,7 @@ class SesContactV2IntegrationTest { @Test @Order(13) void listContacts_lightweightProjection() { - given().config(DECIMAL_NUMBERS).contentType("application/json").header("Authorization", SES_AUTH).body("{}") + given().config(DECIMAL_NUMBERS).contentType("application/json").header("Authorization", AUTH).body("{}") .when().post(CONTACTS + "/list") .then().statusCode(200) .body("Contacts", hasSize(1)) @@ -193,17 +192,17 @@ class SesContactV2IntegrationTest { @Test @Order(14) void deleteContact_thenGone() { - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete(CONTACTS + "/" + EMAIL).then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get(CONTACTS + "/" + EMAIL).then().statusCode(404); } @Test @Order(15) void deleteContact_unknown_returns404() { - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete(CONTACTS + "/ghost@example.com") .then().statusCode(404) .body("message", equalTo("ghost@example.com doesn't exist in List.")); @@ -215,15 +214,15 @@ class SesContactV2IntegrationTest { // Add a contact, delete the list (which must cascade-delete its contacts), then recreate a // same-named list — the old contact must not leak into it. post(CONTACTS, "{\"EmailAddress\":\"carol@example.com\"}").then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete("/v2/email/contact-lists/" + LIST).then().statusCode(200); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .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", SES_AUTH).body("{}") + given().contentType("application/json").header("Authorization", AUTH).body("{}") .when().post(CONTACTS + "/list") .then().statusCode(200).body("Contacts", hasSize(0)); } @@ -232,7 +231,7 @@ class SesContactV2IntegrationTest { @Order(17) void getContact_invalidEmail_returns400() { // Verified against real AWS: the EmailAddress format is validated before list existence. - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get(CONTACTS + "/not-an-email") .then().statusCode(400) .body("message", equalTo("EmailAddress is invalid")); @@ -241,7 +240,7 @@ class SesContactV2IntegrationTest { @Test @Order(18) void getContact_invalidEmailAndUnknownList_reportsEmailFirst() { - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/contact-lists/does-not-exist/contacts/not-an-email") .then().statusCode(400) .body("message", equalTo("EmailAddress is invalid")); @@ -250,7 +249,7 @@ class SesContactV2IntegrationTest { @Test @Order(19) void deleteContact_invalidEmail_returns400() { - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete(CONTACTS + "/not-an-email") .then().statusCode(400) .body("message", equalTo("EmailAddress is invalid")); @@ -259,7 +258,7 @@ class SesContactV2IntegrationTest { @Test @Order(20) void listContacts_nonObjectBody_returns400() { - given().contentType("application/json").header("Authorization", SES_AUTH).body("[]") + given().contentType("application/json").header("Authorization", AUTH).body("[]") .when().post(CONTACTS + "/list") .then().statusCode(400) .body("__type", equalTo("SerializationException")) @@ -302,15 +301,15 @@ class SesContactV2IntegrationTest { void createContact_unsubscribeAllString_coercesByText() { post(CONTACTS, "{\"EmailAddress\":\"type-d@example.com\",\"UnsubscribeAll\":\"yes\"}") .then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get(CONTACTS + "/type-d@example.com") .then().statusCode(200).body("UnsubscribeAll", equalTo(true)); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"UnsubscribeAll\":\"no\"}") .when().put(CONTACTS + "/type-d@example.com") .then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get(CONTACTS + "/type-d@example.com") .then().statusCode(200).body("UnsubscribeAll", equalTo(false)); @@ -323,7 +322,7 @@ class SesContactV2IntegrationTest { @Test @Order(25) void updateContact_attributesDataNumber_returns400() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"AttributesData\":123}") .when().put(CONTACTS + "/" + EMAIL) .then().statusCode(400) @@ -369,14 +368,14 @@ class SesContactV2IntegrationTest { // that has been deleted (which would orphan the contact for a same-named list recreated later). // AWS allows only one contact list per account, so this reuses (and deletes) LIST. post(CONTACTS, "{\"EmailAddress\":\"bob@example.com\"}").then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete("/v2/email/contact-lists/" + LIST).then().statusCode(200); post(CONTACTS, "{\"EmailAddress\":\"ghost@example.com\"}") .then().statusCode(404) .body("__type", equalTo("NotFoundException")); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"UnsubscribeAll\":true}") .when().put(CONTACTS + "/bob@example.com") .then().statusCode(404) diff --git a/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java index c2221bb615..112357580a 100644 --- a/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java @@ -21,8 +21,6 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { private static final String AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - private static final String V2_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String FROM = "cvet-v1-sender@floci.test"; private static final String NAME = "cvet-v1-a"; private static final String MISSING_MESSAGE = @@ -191,7 +189,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { void v1Template_isVisibleViaV2() { create("cvet-v1-shared", "Shared").when().post("/").then().statusCode(200); - given().header("Authorization", V2_AUTH) + given().header("Authorization", SesV2Requests.AUTH) .when().get("/v2/email/custom-verification-email-templates/cvet-v1-shared") .then().statusCode(200) .body("TemplateSubject", equalTo("Shared")) diff --git a/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV2IntegrationTest.java index 96cce9f03c..f9f4d501b8 100644 --- a/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV2IntegrationTest.java @@ -7,6 +7,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 org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -23,8 +24,6 @@ import static org.hamcrest.Matchers.nullValue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesCustomVerificationEmailTemplateV2IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String FROM = "cvet-sender@floci.test"; private static final String BASE = "/v2/email/custom-verification-email-templates"; private static final String NAME = "cvet-v2-a"; diff --git a/src/test/java/io/floci/aws/services/ses/SesDedicatedIpPoolV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesDedicatedIpPoolV2IntegrationTest.java index 621f05c6a8..4c9f6543e3 100644 --- a/src/test/java/io/floci/aws/services/ses/SesDedicatedIpPoolV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesDedicatedIpPoolV2IntegrationTest.java @@ -6,6 +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 org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -18,19 +19,16 @@ import static org.hamcrest.Matchers.hasItem; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesDedicatedIpPoolV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void createDedicatedIpPool_defaultScalingMode() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"PoolName\": \"v2-pool-alpha\"}") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(200); // Default ScalingMode is STANDARD. - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ip-pools/v2-pool-alpha") .then().statusCode(200) .body("DedicatedIpPool.PoolName", equalTo("v2-pool-alpha")) @@ -40,12 +38,12 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(2) void createDedicatedIpPool_managedScalingMode() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"PoolName\": \"v2-pool-managed\", \"ScalingMode\": \"MANAGED\"}") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ip-pools/v2-pool-managed") .then().statusCode(200) .body("DedicatedIpPool.ScalingMode", equalTo("MANAGED")); @@ -54,7 +52,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(3) void createDedicatedIpPool_invalidScalingMode_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"PoolName\": \"v2-pool-bad\", \"ScalingMode\": \"NONSENSE\"}") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(400) @@ -65,7 +63,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(4) void createDedicatedIpPool_duplicate_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"PoolName\": \"v2-pool-alpha\"}") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(400) @@ -76,7 +74,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(5) void getDedicatedIpPool_unknown_returns404() { - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ip-pools/v2-pool-ghost") .then().statusCode(404) .body("__type", equalTo("NotFoundException")) @@ -86,7 +84,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(6) void listDedicatedIpPools() { - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ip-pools") .then().statusCode(200) .body("DedicatedIpPools", hasItem("v2-pool-alpha")) @@ -96,11 +94,11 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(7) void deleteDedicatedIpPool() { - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().delete("/v2/email/dedicated-ip-pools/v2-pool-alpha") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ip-pools/v2-pool-alpha") .then().statusCode(404); } @@ -108,7 +106,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(8) void deleteDedicatedIpPool_unknown_returns404() { - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().delete("/v2/email/dedicated-ip-pools/v2-pool-ghost") .then().statusCode(404) .body("__type", equalTo("NotFoundException")) @@ -118,7 +116,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(9) void createDedicatedIpPool_emptyBody_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(400) @@ -129,7 +127,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(10) void createDedicatedIpPool_missingPoolName_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(400) @@ -140,7 +138,7 @@ class SesDedicatedIpPoolV2IntegrationTest { @Test @Order(11) void createDedicatedIpPool_nullPoolName_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"PoolName\": null}") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(400) @@ -153,7 +151,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"PoolName\": \"v2-pool-objsm\", \"ScalingMode\": {}}") .when().post("/v2/email/dedicated-ip-pools") .then().statusCode(400) diff --git a/src/test/java/io/floci/aws/services/ses/SesDedicatedIpV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesDedicatedIpV2IntegrationTest.java index eb2b8278a9..36826039ee 100644 --- a/src/test/java/io/floci/aws/services/ses/SesDedicatedIpV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesDedicatedIpV2IntegrationTest.java @@ -6,6 +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 org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; @@ -20,14 +21,12 @@ import static org.hamcrest.Matchers.hasSize; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesDedicatedIpV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String TEST_IP = "192.0.2.1"; @Test @Order(1) void getDedicatedIps_empty() { - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ips") .then().statusCode(200) .body("DedicatedIps", hasSize(0)); @@ -36,7 +35,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(2) void getDedicatedIp_notFound() { - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ips/" + TEST_IP) .then().statusCode(404) .body("__type", equalTo("NotFoundException")) @@ -47,10 +46,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"PoolName\": \"dip-scaling-pool\"}") .when().post("/v2/email/dedicated-ip-pools").then().statusCode(200); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"DestinationPoolName\": \"dip-scaling-pool\"}") .when().put("/v2/email/dedicated-ips/" + TEST_IP + "/pool") .then().statusCode(404) @@ -61,7 +60,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(4) void putDedicatedIpWarmupAttributes_ipNotFound() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"WarmupPercentage\": 50}") .when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup") .then().statusCode(404) @@ -73,11 +72,11 @@ 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ScalingMode\": \"MANAGED\"}") .when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/dedicated-ip-pools/dip-scaling-pool") .then().statusCode(200) .body("DedicatedIpPool.ScalingMode", equalTo("MANAGED")); @@ -86,7 +85,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(6) void putDedicatedIpPoolScalingAttributes_invalidMode_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ScalingMode\": \"NONSENSE\"}") .when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling") .then().statusCode(400) @@ -97,7 +96,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(7) void putDedicatedIpPoolScalingAttributes_unknownPool_returns404() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ScalingMode\": \"STANDARD\"}") .when().put("/v2/email/dedicated-ip-pools/dip-ghost-pool/scaling") .then().statusCode(404) @@ -108,17 +107,17 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(8) void accountDedicatedIpAutoWarmup_defaultsTrue_andTogglable() { - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/account") .then().statusCode(200) .body("DedicatedIpAutoWarmupEnabled", equalTo(true)); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"AutoWarmupEnabled\": false}") .when().put("/v2/email/account/dedicated-ips/warmup") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/account") .then().statusCode(200) .body("DedicatedIpAutoWarmupEnabled", equalTo(false)); @@ -128,7 +127,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/dedicated-ips/" + TEST_IP + "/pool") .then().statusCode(400) @@ -141,7 +140,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/dedicated-ip-pools/dip-ghost-pool/scaling") .then().statusCode(400) @@ -153,7 +152,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ScalingMode\": \"STANDARD\"}") .when().put("/v2/email/dedicated-ip-pools/dip-scaling-pool/scaling") .then().statusCode(400) @@ -164,7 +163,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(12) void putDedicatedIpWarmupAttributes_missingPercentage_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup") .then().statusCode(400) @@ -175,7 +174,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(13) void putDedicatedIpWarmupAttributes_outOfRange_returns400() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"WarmupPercentage\": 150}") .when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup") .then().statusCode(400) @@ -186,7 +185,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(14) void putDedicatedIpWarmupAttributes_nonInteger_returnsSerializationException() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"WarmupPercentage\": \"abc\"}") .when().put("/v2/email/dedicated-ips/" + TEST_IP + "/warmup") .then().statusCode(400) @@ -197,25 +196,25 @@ 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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"AutoWarmupEnabled\": \"no\"}") .when().put("/v2/email/account/dedicated-ips/warmup") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/account") .then().statusCode(200) .body("DedicatedIpAutoWarmupEnabled", equalTo(false)); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"AutoWarmupEnabled\": \"yes\"}") .when().put("/v2/email/account/dedicated-ips/warmup") .then().statusCode(200); - given().header("Authorization", AUTH_HEADER) + given().header("Authorization", AUTH) .when().get("/v2/email/account") .then().statusCode(200) .body("DedicatedIpAutoWarmupEnabled", equalTo(true)); - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"AutoWarmupEnabled\": \"nonsense\"}") .when().put("/v2/email/account/dedicated-ips/warmup") .then().statusCode(400) @@ -227,7 +226,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_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"AutoWarmupEnabled\": null}") .when().put("/v2/email/account/dedicated-ips/warmup") .then().statusCode(400) @@ -237,7 +236,7 @@ class SesDedicatedIpV2IntegrationTest { @Test @Order(17) void putAccountAutoWarmup_number_returnsSerializationException() { - given().contentType("application/json").header("Authorization", AUTH_HEADER) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"AutoWarmupEnabled\": 1}") .when().put("/v2/email/account/dedicated-ips/warmup") .then().statusCode(400) diff --git a/src/test/java/io/floci/aws/services/ses/SesDkimSigningActionsIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesDkimSigningActionsIntegrationTest.java index f6393f3344..ade04b31f2 100644 --- a/src/test/java/io/floci/aws/services/ses/SesDkimSigningActionsIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesDkimSigningActionsIntegrationTest.java @@ -37,8 +37,6 @@ class SesDkimSigningActionsIntegrationTest { private static final String V1_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - private static final String V2_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private RequestSpecification v1(String action) { return given().contentType("application/x-www-form-urlencoded") @@ -88,13 +86,13 @@ class SesDkimSigningActionsIntegrationTest { @Test void putDkimSigningAttributes_awsSes_regeneratesTokensOnKeyLengthChange() { String domain = "dkim-signing.floci.test"; - List before = given().contentType("application/json").header("Authorization", V2_AUTH) + List before = given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200) .extract().path("DkimAttributes.Tokens"); // Change the key length (default is RSA_2048_BIT) -> tokens regenerate. - Response resp = given().contentType("application/json").header("Authorization", V2_AUTH) + Response resp = given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningAttributesOrigin\":\"AWS_SES\"," + "\"SigningAttributes\":{\"NextSigningKeyLength\":\"RSA_1024_BIT\"}}") .when().put("/v2/email/identities/" + domain + "/dkim/signing").then().statusCode(200) @@ -104,7 +102,7 @@ class SesDkimSigningActionsIntegrationTest { List after = resp.path("DkimTokens"); assertNotEquals(before, after, "changing the key length must regenerate the tokens"); - given().header("Authorization", V2_AUTH) + given().header("Authorization", SesV2Requests.AUTH) .when().get("/v2/email/identities/" + domain).then().statusCode(200) .body("DkimAttributes.CurrentSigningKeyLength", equalTo("RSA_1024_BIT")) .body("DkimAttributes.SigningHostedZone", equalTo("dkim.amazonses.com")) @@ -114,7 +112,7 @@ class SesDkimSigningActionsIntegrationTest { @Test void putDkimSigningAttributes_emailIdentity_returns400() { // DKIM signing attributes are domain-level; an email-shaped identity is rejected. - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningAttributesOrigin\":\"AWS_SES\"}") .when().put("/v2/email/identities/bob@dkim-emailsigning.floci.test/dkim/signing") .then().statusCode(400).body("__type", equalTo("BadRequestException")) @@ -125,7 +123,7 @@ class SesDkimSigningActionsIntegrationTest { void putDkimSigningAttributes_blankIdentity_returns400() { // A blank/whitespace identity is rejected with the same 400 "must be a valid domain" as an // email-shaped one (verified against AWS), rather than falling through to a 404. - given().urlEncodingEnabled(false).contentType("application/json").header("Authorization", V2_AUTH) + given().urlEncodingEnabled(false).contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningAttributesOrigin\":\"AWS_SES\"}") .when().put("/v2/email/identities/%20/dkim/signing") .then().statusCode(400).body("__type", equalTo("BadRequestException")) @@ -134,7 +132,7 @@ class SesDkimSigningActionsIntegrationTest { @Test void putDkimSigningAttributes_unknownIdentity_returns404() { - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningAttributesOrigin\":\"AWS_SES\"}") .when().put("/v2/email/identities/ghost-signing.floci.test/dkim/signing") .then().statusCode(404).body("__type", equalTo("NotFoundException")) @@ -145,11 +143,11 @@ class SesDkimSigningActionsIntegrationTest { @Test void putDkimSigningAttributes_externalWithBlankPrivateKey_returns400() { String domain = "dkim-external.floci.test"; - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningAttributesOrigin\":\"EXTERNAL\",\"SigningAttributes\":" + "{\"DomainSigningSelector\":\"sel\",\"DomainSigningPrivateKey\":\"\"}}") .when().put("/v2/email/identities/" + domain + "/dkim/signing") @@ -182,11 +180,11 @@ class SesDkimSigningActionsIntegrationTest { @Test void putDkimSigningAttributes_invalidKeyLength_returns400() { String domain = "dkim-badkeylen.floci.test"; - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningAttributesOrigin\":\"AWS_SES\"," + "\"SigningAttributes\":{\"NextSigningKeyLength\":\"RSA_4096_BIT\"}}") .when().put("/v2/email/identities/" + domain + "/dkim/signing") @@ -196,18 +194,18 @@ class SesDkimSigningActionsIntegrationTest { @Test void putDkimSigningAttributes_external_clearsTokensAndResetsStatusToPending() { String domain = "dkim-byodkim.floci.test"; - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningAttributesOrigin\":\"EXTERNAL\",\"SigningAttributes\":" + "{\"DomainSigningSelector\":\"sel\",\"DomainSigningPrivateKey\":\"key\"}}") .when().put("/v2/email/identities/" + domain + "/dkim/signing").then().statusCode(200) .body("DkimStatus", equalTo("PENDING")) .body("DkimTokens", hasSize(0)); - given().header("Authorization", V2_AUTH) + given().header("Authorization", SesV2Requests.AUTH) .when().get("/v2/email/identities/" + domain).then().statusCode(200) .body("DkimAttributes.Status", equalTo("PENDING")) .body("DkimAttributes.SigningAttributesOrigin", equalTo("EXTERNAL")) @@ -217,7 +215,7 @@ class SesDkimSigningActionsIntegrationTest { @Test void putDkimSigningAttributes_nonObjectBody_returns400() { - given().contentType("application/json").header("Authorization", V2_AUTH).body("[]") + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH).body("[]") .when().put("/v2/email/identities/dkim-nonobj.floci.test/dkim/signing") .then().statusCode(400).body("__type", equalTo("SerializationException")) .body("message", equalTo("Start of list found where not expected")); @@ -252,23 +250,23 @@ class SesDkimSigningActionsIntegrationTest { @Test void putEmailIdentityDkimAttributes_existingEmailWithRegisteredDomain_isNoOp() { String domain = "dkim-emailtoggle.floci.test"; - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"bob@" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200); // Toggling DKIM on the email is a no-op (DKIM is domain-controlled) — 200, nothing changes. - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"SigningEnabled\": false}") .when().put("/v2/email/identities/bob@" + domain + "/dkim").then().statusCode(200); // The email still reports the domain's DKIM (enabled), and the domain is untouched. - given().header("Authorization", V2_AUTH) + given().header("Authorization", SesV2Requests.AUTH) .when().get("/v2/email/identities/bob@" + domain).then().statusCode(200) .body("DkimAttributes.SigningEnabled", equalTo(true)); - given().header("Authorization", V2_AUTH) + given().header("Authorization", SesV2Requests.AUTH) .when().get("/v2/email/identities/" + domain).then().statusCode(200) .body("DkimAttributes.SigningEnabled", equalTo(true)); } @@ -276,17 +274,17 @@ class SesDkimSigningActionsIntegrationTest { @Test void emailIdentity_inheritsParentDomainDkim() { String domain = "dkim-inherit.floci.test"; - List domainTokens = given().contentType("application/json").header("Authorization", V2_AUTH) + List domainTokens = given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200) .extract().path("DkimAttributes.Tokens"); // An email under that domain inherits the domain's DKIM (tokens, enabled, pending status). - given().contentType("application/json").header("Authorization", V2_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"bob@" + domain + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().header("Authorization", V2_AUTH) + given().header("Authorization", SesV2Requests.AUTH) .when().get("/v2/email/identities/bob@" + domain).then().statusCode(200) .body("DkimAttributes.SigningEnabled", equalTo(true)) .body("DkimAttributes.Status", equalTo("PENDING")) diff --git a/src/test/java/io/floci/aws/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.java index 9efff9f4dd..e0d592c4b7 100644 --- a/src/test/java/io/floci/aws/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesEmailIdentityConfigurationSetV2IntegrationTest.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Base64; import java.util.List; +import static io.floci.aws.services.ses.SesV2Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -34,8 +35,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesEmailIdentityConfigurationSetV2IntegrationTest { - private static final String SES_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String SNS_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/sns/aws4_request"; private static final String SQS_AUTH = @@ -58,11 +57,11 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Test @Order(1) void setup_identity_configSet_snsEventDestination() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + IDENTITY + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when().post("/v2/email/configuration-sets").then().statusCode(200); @@ -89,7 +88,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { .body("{\"TopicArn\":\"" + topicArn + "\",\"Protocol\":\"sqs\",\"Endpoint\":\"" + queueArn + "\"}") .when().post("/").then().statusCode(200); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-sns", @@ -107,12 +106,12 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Test @Order(2) void putEmailIdentityConfigurationSet_associatesAndSurfacesInGet() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set") .then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + IDENTITY) .then().statusCode(200) .body("ConfigurationSetName", equalTo(CS)); @@ -123,7 +122,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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -145,12 +144,12 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Test @Order(4) void clearConfigurationSet_removesAssociation() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{}") .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set") .then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + IDENTITY) .then().statusCode(200) .body("$", Matchers.not(Matchers.hasKey("ConfigurationSetName"))); @@ -160,7 +159,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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set") .then().statusCode(200); @@ -172,7 +171,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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -193,7 +192,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Test @Order(6) void unknownIdentity_returns404() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when().put("/v2/email/identities/cs-attr-ghost@floci.test/configuration-set") .then().statusCode(404) @@ -203,7 +202,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Test @Order(7) void unknownConfigurationSet_returns404() { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"cs-attr-missing\"}") .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set") .then().statusCode(404) @@ -214,7 +213,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Order(8) void sendRawContentWithoutFromAddress_routesThroughIdentityDefault() throws Exception { // Re-associate so this test is self-contained. - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set") .then().statusCode(200); @@ -226,7 +225,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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" { "Destination": {"ToAddresses": ["bounce@simulator.amazonses.com"]}, @@ -248,18 +247,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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(" \n") .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set") .then().statusCode(400) .body("__type", equalTo("SerializationException")); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("[]") .when().put("/v2/email/identities/" + IDENTITY + "/configuration-set") .then().statusCode(400) @@ -267,7 +266,7 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { .body("message", equalTo("Start of list found where not expected")); // The association is unchanged (the invalid bodies neither cleared nor updated it). - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + IDENTITY) .then().statusCode(200) .body("ConfigurationSetName", equalTo(CS)); @@ -280,22 +279,22 @@ 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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + id + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + cs + "\"}") .when().post("/v2/email/configuration-sets").then().statusCode(200); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + cs + "\"}") .when().put("/v2/email/identities/" + id + "/configuration-set").then().statusCode(200); // Delete the configuration set that is now the identity's default. - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -313,16 +312,16 @@ 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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\"" + cs + "\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + id) .then().statusCode(200).body("ConfigurationSetName", equalTo(cs)); } @@ -331,14 +330,14 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Order(12) void createEmailIdentity_withMissingConfigurationSet_returns404AndDoesNotCreate() { String id = "cs-attr-oncreate-missing@floci.test"; - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\"cs-attr-ghost-oncreate\"}") .when().post("/v2/email/identities").then().statusCode(404) .body("__type", equalTo("NotFoundException")) .body("message", equalTo("Configuration set does not exist.")); // The identity must not have been created (AWS is atomic on the config-set validation). - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + id).then().statusCode(404); } @@ -346,14 +345,14 @@ class SesEmailIdentityConfigurationSetV2IntegrationTest { @Order(17) void createEmailIdentity_withNonArrayTags_returns400AndDoesNotCreate() { String id = "cs-attr-oncreate-badtags@floci.test"; - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + id + "\",\"Tags\":\"oops\"}") .when().post("/v2/email/identities").then().statusCode(400) .body("__type", equalTo("BadRequestException")) .body("message", equalTo("Tags must be an array.")); // Tags is validated before the identity is persisted, so nothing is created. - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + id).then().statusCode(404); } @@ -361,11 +360,11 @@ 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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"cs-attr-badtype@floci.test\",\"ConfigurationSetName\":123}") .when().post("/v2/email/identities").then().statusCode(400) .body("__type", equalTo("SerializationException")); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/cs-attr-badtype@floci.test").then().statusCode(404); } @@ -377,10 +376,10 @@ 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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\"\"}") .when().post("/v2/email/identities").then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + id).then().statusCode(200) .body("$", Matchers.not(Matchers.hasKey("ConfigurationSetName"))); } @@ -391,12 +390,12 @@ 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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + id + "\",\"ConfigurationSetName\":\" \"}") .when().post("/v2/email/identities").then().statusCode(400) .body("__type", equalTo("BadRequestException")) .body("message", equalTo("Invalid configuration set name < >: only alphanumeric ASCII characters, '_', and '-' are allowed.")); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/" + id).then().statusCode(404); } @@ -405,11 +404,11 @@ 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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailIdentity\":123}") .when().post("/v2/email/identities").then().statusCode(400) .body("__type", equalTo("SerializationException")); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/v2/email/identities/123").then().statusCode(404); } diff --git a/src/test/java/io/floci/aws/services/ses/SesEventPublishingV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesEventPublishingV2IntegrationTest.java index 142524eadd..e2b0e1ad03 100644 --- a/src/test/java/io/floci/aws/services/ses/SesEventPublishingV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesEventPublishingV2IntegrationTest.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Base64; import java.util.List; +import static io.floci.aws.services.ses.SesV2Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasKey; @@ -48,8 +49,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesEventPublishingV2IntegrationTest { - private static final String SES_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String SNS_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/sns/aws4_request"; private static final String SQS_AUTH = @@ -155,7 +154,7 @@ class SesEventPublishingV2IntegrationTest { void setupSesIdentityConfigSetAndEventDestination() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"EmailIdentity\":\"" + SENDER + "\"}") .when() .post("/v2/email/identities") @@ -164,7 +163,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when() .post("/v2/email/configuration-sets") @@ -173,7 +172,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-sns", @@ -255,7 +254,7 @@ class SesEventPublishingV2IntegrationTest { raw.getBytes(StandardCharsets.UTF_8)); given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("Action=SendRawEmail" + "&Source=" + URLEncoder.encode(SENDER, StandardCharsets.UTF_8) + "&RawMessage.Data=" + URLEncoder.encode(rawB64, StandardCharsets.UTF_8) @@ -285,7 +284,7 @@ class SesEventPublishingV2IntegrationTest { String csDisabled = "v2-cs-ed-disabled"; given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}") .when() .post("/v2/email/configuration-sets") @@ -294,7 +293,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-sns-disabled", @@ -314,7 +313,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -343,7 +342,7 @@ class SesEventPublishingV2IntegrationTest { drainQueue(); given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -383,7 +382,7 @@ class SesEventPublishingV2IntegrationTest { drainQueue(); given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -423,7 +422,7 @@ class SesEventPublishingV2IntegrationTest { drainQueue(); given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("Action=SendEmail" + "&Source=" + URLEncoder.encode(SENDER, StandardCharsets.UTF_8) + "&Destination.ToAddresses.member.1=" @@ -455,7 +454,7 @@ class SesEventPublishingV2IntegrationTest { drainQueue(); given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -505,7 +504,7 @@ class SesEventPublishingV2IntegrationTest { // Pre-register the address in the account-level suppression list with reason BOUNCE. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"EmailAddress\":\"" + suppressed + "\",\"Reason\":\"BOUNCE\"}") .when() .put("/v2/email/suppression/addresses") @@ -516,7 +515,7 @@ class SesEventPublishingV2IntegrationTest { drainQueue(); given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -551,7 +550,7 @@ class SesEventPublishingV2IntegrationTest { } finally { // Always run cleanup so the suppression list doesn't leak into subsequent tests. given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .delete("/v2/email/suppression/addresses/" + suppressed); } @@ -579,7 +578,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS_FIREHOSE + "\"}") .when() .post("/v2/email/configuration-sets") @@ -588,7 +587,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-firehose", @@ -614,7 +613,7 @@ class SesEventPublishingV2IntegrationTest { String suppressed = "complaint-suppressed-" + System.nanoTime() + "@example.com"; given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"EmailAddress\":\"" + suppressed + "\",\"Reason\":\"COMPLAINT\"}") .when() .put("/v2/email/suppression/addresses") @@ -625,7 +624,7 @@ class SesEventPublishingV2IntegrationTest { drainQueue(); given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -654,7 +653,7 @@ class SesEventPublishingV2IntegrationTest { assertEquals("OnAccountSuppressionList", complaint.path("complaint").path("complaintSubType").asText()); } finally { given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .delete("/v2/email/suppression/addresses/" + suppressed); } @@ -713,7 +712,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}") .when() .post("/v2/email/configuration-sets") @@ -722,7 +721,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-firehose-disabled", @@ -759,7 +758,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + csUnknown + "\"}") .when() .post("/v2/email/configuration-sets") @@ -768,7 +767,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-firehose-unknown", @@ -849,7 +848,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS_EB + "\"}") .when() .post("/v2/email/configuration-sets") @@ -858,7 +857,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-eventbridge", @@ -925,7 +924,7 @@ class SesEventPublishingV2IntegrationTest { String csDisabled = "ses-events-eb-cs-disabled"; given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}") .when() .post("/v2/email/configuration-sets") @@ -934,7 +933,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-eventbridge-disabled", @@ -967,7 +966,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + csUnknown + "\"}") .when() .post("/v2/email/configuration-sets") @@ -978,7 +977,7 @@ class SesEventPublishingV2IntegrationTest { // rejected at create time and never stored. given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-eventbridge-unknown", @@ -996,7 +995,7 @@ class SesEventPublishingV2IntegrationTest { .body("__type", equalTo("BadRequestException")); given() - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .when() .get("/v2/email/configuration-sets/" + csUnknown + "/event-destinations") .then() @@ -1011,7 +1010,7 @@ class SesEventPublishingV2IntegrationTest { void cloudWatch_setupConfigSetAndEventDestination() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS_CW + "\"}") .when() .post("/v2/email/configuration-sets") @@ -1020,7 +1019,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-cloudwatch", @@ -1060,7 +1059,7 @@ class SesEventPublishingV2IntegrationTest { void cloudWatch_sendWithTagsAndHeaders_registersSendMetricWithResolvedDimensions() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -1103,7 +1102,7 @@ class SesEventPublishingV2IntegrationTest { void cloudWatch_sendWithoutTags_fallsBackToDefaultDimensionValue() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -1134,7 +1133,7 @@ class SesEventPublishingV2IntegrationTest { void cloudWatch_successSimulator_registersBothSendAndDeliveryMetrics() { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -1166,7 +1165,7 @@ class SesEventPublishingV2IntegrationTest { String csDisabled = "ses-events-cw-cs-disabled"; given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + csDisabled + "\"}") .when() .post("/v2/email/configuration-sets") @@ -1175,7 +1174,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-cloudwatch-disabled", @@ -1201,7 +1200,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -1447,7 +1446,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + csName + "\"}") .when() .post("/v2/email/configuration-sets") @@ -1456,7 +1455,7 @@ class SesEventPublishingV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "EventDestinationName": "ed-eventbridge-detail", @@ -1516,7 +1515,7 @@ class SesEventPublishingV2IntegrationTest { private void sendEmailToConfigSet(String configSet, String to, String subject) { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -1632,12 +1631,12 @@ class SesEventPublishingV2IntegrationTest { @Order(33) void simulatorAndSuppressedBounces_arePublishedAsSeparateEvents() throws Exception { String suppressed = "split-suppressed-" + System.nanoTime() + "@example.com"; - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailAddress\":\"" + suppressed + "\",\"Reason\":\"BOUNCE\"}") .when().put("/v2/email/suppression/addresses").then().statusCode(200); try { drainQueue(); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -1664,7 +1663,7 @@ class SesEventPublishingV2IntegrationTest { "mail.destination carries the full envelope on every event"); } } finally { - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete("/v2/email/suppression/addresses/" + suppressed); } } @@ -1684,7 +1683,7 @@ class SesEventPublishingV2IntegrationTest { String rawB64 = Base64.getEncoder().encodeToString( mime.getBytes(StandardCharsets.UTF_8)); drainQueue(); - String messageId = given().contentType("application/json").header("Authorization", SES_AUTH) + String messageId = given().contentType("application/json").header("Authorization", AUTH) .body(""" {"FromEmailAddress": "%s", "Destination": {"ToAddresses": ["success@simulator.amazonses.com"]}, @@ -1722,7 +1721,7 @@ class SesEventPublishingV2IntegrationTest { // The request's own tags, validated by the controller, stay on both events. drainQueue(); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" {"FromEmailAddress": "%s", "Destination": {"ToAddresses": ["success@simulator.amazonses.com"]}, @@ -1741,7 +1740,7 @@ class SesEventPublishingV2IntegrationTest { // The stored record keeps the marker and its envelope but no copy of the content, so it // is listed in neither the raw shape (no RawData) nor the Simple one (no Subject or Body). - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/_aws/ses?id=" + messageId).then().statusCode(200) .body("messages[0].RejectReason", equalTo("Bad content")) .body("messages[0]", hasKey("Destination")) @@ -1754,7 +1753,7 @@ class SesEventPublishingV2IntegrationTest { @Order(35) void eicarInSimpleBody_isAcceptedThenRejectedAndStoredWithoutTheBody() throws Exception { drainQueue(); - String messageId = given().contentType("application/json").header("Authorization", SES_AUTH) + String messageId = given().contentType("application/json").header("Authorization", AUTH) .body(""" {"FromEmailAddress": "%s", "Destination": {"ToAddresses": ["success@simulator.amazonses.com"]}, @@ -1771,7 +1770,7 @@ class SesEventPublishingV2IntegrationTest { assertTrue(events.stream().anyMatch(e -> "Reject".equals(e.path("eventType").asText()))); assertTrue(events.stream().noneMatch(e -> "Delivery".equals(e.path("eventType").asText()))); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/_aws/ses?id=" + messageId).then().statusCode(200) .body("messages[0].RejectReason", equalTo("Bad content")) .body("messages[0]", hasKey("Destination")) @@ -1793,7 +1792,7 @@ class SesEventPublishingV2IntegrationTest { "\"Subject\": {\"Data\": \"clean\"}, \"Body\": {\"Text\": {\"Data\": \"clean\"}}, " + "\"Headers\": [{\"Name\": \"" + signature + "\", \"Value\": \"x\"}]"}) { drainQueue(); - String messageId = given().contentType("application/json").header("Authorization", SES_AUTH) + String messageId = given().contentType("application/json").header("Authorization", AUTH) .body(""" {"FromEmailAddress": "%s", "Destination": {"ToAddresses": ["success@simulator.amazonses.com"]}, @@ -1819,7 +1818,7 @@ class SesEventPublishingV2IntegrationTest { } } - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().get("/_aws/ses?id=" + messageId).then().statusCode(200) .body("messages[0].RejectReason", equalTo("Bad content")) .body("messages[0]", not(hasKey("Subject"))) @@ -1850,16 +1849,16 @@ class SesEventPublishingV2IntegrationTest { assertTrue(rejected.stream().anyMatch(e -> "Reject".equals(e.path("eventType").asText()))); assertTrue(rejected.stream().allMatch(e -> messageId.equals(e.path("mail").path("messageId").asText()))); } finally { - given().header("Authorization", SES_AUTH).when().delete("/v2/email/identities/" + recipient); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH).when().delete("/v2/email/identities/" + recipient); + given().header("Authorization", AUTH) .when().delete("/v2/email/custom-verification-email-templates/cvet-events-clean"); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete("/v2/email/custom-verification-email-templates/cvet-events-scan"); } } private void createCustomVerificationTemplate(String name, String content) { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body(""" {"TemplateName": "%s", "FromEmailAddress": "%s", "TemplateSubject": "verify", "TemplateContent": "%s", @@ -1872,7 +1871,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", SES_AUTH) + return given().contentType("application/json").header("Authorization", AUTH) .body(""" {"EmailAddress": "%s", "TemplateName": "%s"%s} """.formatted(recipient, templateName, configurationSetField)) @@ -1888,7 +1887,7 @@ class SesEventPublishingV2IntegrationTest { String recipient = "cvet-preamble@cvet-events.floci.test"; createCustomVerificationTemplate("cvet-preamble", "

verify

"); try { - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"" + CS + "\"}") .when().put("/v2/email/identities/" + SENDER + "/configuration-set").then().statusCode(200); drainQueue(); @@ -1897,7 +1896,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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"EmailAddress\":\"" + recipient + "\",\"Reason\":\"BOUNCE\"}") .when().put("/v2/email/suppression/addresses").then().statusCode(200); drainQueue(); @@ -1906,35 +1905,35 @@ 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", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"ConfigurationSetName\":\"cvet-paused\"}") .when().post("/v2/email/configuration-sets").then().statusCode(200); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .body("{\"SendingEnabled\":false}") .when().put("/v2/email/configuration-sets/cvet-paused/sending").then().statusCode(200); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", AUTH) .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", SES_AUTH).body("{}") + given().contentType("application/json").header("Authorization", AUTH).body("{}") .when().put("/v2/email/identities/" + SENDER + "/configuration-set"); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete("/v2/email/suppression/addresses/" + recipient); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete("/v2/email/configuration-sets/cvet-paused"); - given().header("Authorization", SES_AUTH) + given().header("Authorization", AUTH) .when().delete("/v2/email/custom-verification-email-templates/cvet-preamble"); - given().header("Authorization", SES_AUTH).when().delete("/v2/email/identities/" + recipient); + given().header("Authorization", AUTH).when().delete("/v2/email/identities/" + recipient); } } private void sendEmail(String to) { given() .contentType("application/json") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "%s", @@ -2047,7 +2046,7 @@ class SesEventPublishingV2IntegrationTest { raw.getBytes(StandardCharsets.UTF_8)); given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("Action=SendRawEmail" + "&Source=" + URLEncoder.encode(SENDER, StandardCharsets.UTF_8) + "&RawMessage.Data=" + URLEncoder.encode(rawB64, StandardCharsets.UTF_8) @@ -2080,7 +2079,7 @@ class SesEventPublishingV2IntegrationTest { raw.getBytes(StandardCharsets.UTF_8)); given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", SES_AUTH) + .header("Authorization", AUTH) .body("Action=SendRawEmail" + "&Source=" + URLEncoder.encode(SENDER, StandardCharsets.UTF_8) + "&RawMessage.Data=" + URLEncoder.encode(rawB64, StandardCharsets.UTF_8) diff --git a/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV2IntegrationTest.java index 22f4be4370..98af12b326 100644 --- a/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV2IntegrationTest.java @@ -6,6 +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 org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -15,15 +16,12 @@ import static org.hamcrest.Matchers.nullValue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesIdentityAttributesV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void createEmailIdentity_setsUpDomain() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "v2-attrs.floci.test"} """) @@ -37,7 +35,7 @@ class SesIdentityAttributesV2IntegrationTest { // block carrying only BehaviorOnMxFailure and omits the inner // MailFromDomain / MailFromDomainStatus fields. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2-attrs.floci.test") .then() @@ -53,7 +51,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_setsDomain() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "MailFromDomain": "mail.v2-attrs.floci.test", @@ -70,7 +68,7 @@ class SesIdentityAttributesV2IntegrationTest { @Order(3) void getEmailIdentity_includesMailFromAttributes() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2-attrs.floci.test") .then() @@ -85,7 +83,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_emptyDomain_clears() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"MailFromDomain": ""} """) @@ -98,7 +96,7 @@ class SesIdentityAttributesV2IntegrationTest { // the block stays, BehaviorOnMxFailure resets to USE_DEFAULT_VALUE, // and the inner domain / status fields drop out. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2-attrs.floci.test") .then() @@ -113,7 +111,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_unknownIdentity_returnsBadRequest() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"MailFromDomain": "mail.ghost.floci.test"} """) @@ -130,7 +128,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityFeedbackAttributes_unknownIdentity_returnsBadRequest() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailForwardingEnabled": true} """) @@ -148,7 +146,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_invalidJson_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("[1,2,3]") .when() .put("/v2/email/identities/v2-attrs.floci.test/mail-from") @@ -163,7 +161,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_missingBody_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .put("/v2/email/identities/v2-attrs.floci.test/mail-from") .then() @@ -176,7 +174,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_missingMailFromDomainField_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"BehaviorOnMxFailure": "USE_DEFAULT_VALUE"} """) @@ -192,7 +190,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_mailFromDomainAsObject_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"MailFromDomain": {"foo": "bar"}} """) @@ -208,7 +206,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityMailFromAttributes_unknownBehavior_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "MailFromDomain": "mail.v2-attrs.floci.test", @@ -229,7 +227,7 @@ class SesIdentityAttributesV2IntegrationTest { void putEmailIdentityDkimAttributes_unknownIdentity_returnsBadRequest() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningEnabled": true} """) @@ -249,7 +247,7 @@ class SesIdentityAttributesV2IntegrationTest { // in the error message even when the input is email-formatted. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningEnabled": true} """) @@ -271,7 +269,7 @@ class SesIdentityAttributesV2IntegrationTest { // untouched, and no email identity is auto-created. Object parentDkimBefore = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2-attrs.floci.test") .then() @@ -280,7 +278,7 @@ class SesIdentityAttributesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningEnabled": true} """) @@ -291,7 +289,7 @@ class SesIdentityAttributesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2-attrs.floci.test") .then() @@ -300,7 +298,7 @@ class SesIdentityAttributesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/orphan@v2-attrs.floci.test") .then() @@ -312,7 +310,7 @@ class SesIdentityAttributesV2IntegrationTest { void createEmailIdentity_duplicate_returnsAlreadyExists() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "v2-attrs.floci.test"} """) @@ -330,7 +328,7 @@ class SesIdentityAttributesV2IntegrationTest { void deleteEmailIdentity_unknownIdentity_returnsNotFound() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/identities/ghost-delete.floci.test") .then() diff --git a/src/test/java/io/floci/aws/services/ses/SesIdentityCertificateV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesIdentityCertificateV2IntegrationTest.java index 71f4caf5c8..b238f8e8cb 100644 --- a/src/test/java/io/floci/aws/services/ses/SesIdentityCertificateV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesIdentityCertificateV2IntegrationTest.java @@ -20,8 +20,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @QuarkusTest class SesIdentityCertificateV2IntegrationTest { - private static final String SES_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String ACM_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/acm/aws4_request"; private static final String MISSING_CERT_ARN = @@ -130,11 +128,11 @@ class SesIdentityCertificateV2IntegrationTest { void deleteEmailIdentityIsRefusedWhileACertificateIsAssociated() { String identity = "smime-delete@floci.test"; createIdentity(identity); - given().contentType("application/json").header("Authorization", SES_AUTH) + given().contentType("application/json").header("Authorization", SesV2Requests.AUTH) .body("{\"EmailIdentity\":\"" + identity + "\",\"CertificateArn\":\"" + MISSING_CERT_ARN + "\"}") .when().post("/v2/email/identity/certificates").then().statusCode(200); - given().header("Authorization", SES_AUTH) + given().header("Authorization", SesV2Requests.AUTH) .when().delete("/v2/email/identities/" + identity).then().statusCode(400) .body("__type", equalTo("BadRequestException")) .body("message", equalTo("Cannot delete .")); } - - private static ValidatableResponse send(String path, String body) { - return given().contentType("application/json").header("Authorization", AUTH).body(body) - .when().post(path).then(); - } } diff --git a/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV2IntegrationTest.java index 265804c0d6..020ef8b2fc 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV2IntegrationTest.java @@ -6,6 +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 org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -22,8 +23,6 @@ import static org.hamcrest.Matchers.notNullValue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesSendCustomVerificationEmailV2IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String FROM = "scve-v2-sender@floci.test"; private static final String RECIPIENT = "scve-v2-recipient@floci.test"; private static final String NAME = "scve-v2-template"; diff --git a/src/test/java/io/floci/aws/services/ses/SesSendVerifiedSenderIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendVerifiedSenderIntegrationTest.java index 1d27942b1f..438883a281 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendVerifiedSenderIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendVerifiedSenderIntegrationTest.java @@ -31,8 +31,6 @@ class SesSendVerifiedSenderIntegrationTest { private static final String AUTH_V1 = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - private static final String AUTH_V2 = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String UNVERIFIED = "never-verified@unverified-sender.floci.test"; private static final String VERIFIED = "verified@verified-sender.floci.test"; private static final String NOT_VERIFIED_MESSAGE = @@ -210,14 +208,14 @@ class SesSendVerifiedSenderIntegrationTest { @Test void v2SendEmail_simple_unverifiedFrom_returnsMessageRejected() { - assertMessageRejectedV2(v2(AUTH_V2).body(simpleBody(UNVERIFIED)), UNVERIFIED); + assertMessageRejectedV2(v2(SesV2Requests.AUTH).body(simpleBody(UNVERIFIED)), UNVERIFIED); assertNothingCapturedFrom(UNVERIFIED); } @Test void v2SendEmail_raw_unverifiedMimeFrom_returnsMessageRejected() { - assertMessageRejectedV2(v2(AUTH_V2).body(""" + assertMessageRejectedV2(v2(SesV2Requests.AUTH).body(""" { "Destination": {"ToAddresses": ["to@example.com"]}, "Content": {"Raw": {"Data": "%s"}} @@ -227,19 +225,19 @@ class SesSendVerifiedSenderIntegrationTest { @Test void v2SendEmail_verifiedEmailIdentity_succeeds() { - v2(AUTH_V2).body("{\"EmailIdentity\": \"v2-" + VERIFIED + "\"}") + v2(SesV2Requests.AUTH).body("{\"EmailIdentity\": \"v2-" + VERIFIED + "\"}") .when() .post("/v2/email/identities"); - assertSentV2(v2(AUTH_V2).body(simpleBody("v2-" + VERIFIED))); + assertSentV2(v2(SesV2Requests.AUTH).body(simpleBody("v2-" + VERIFIED))); } @Test void v2SendEmail_addressUnderVerifiedDomain_succeeds() { String domain = "verified-domain.floci.test"; - SesDomainIdentityTestHelper.createVerified(domain, AUTH_V2); + SesDomainIdentityTestHelper.createVerified(domain, SesV2Requests.AUTH); - assertSentV2(v2(AUTH_V2).body(simpleBody("anyone@" + domain))); + assertSentV2(v2(SesV2Requests.AUTH).body(simpleBody("anyone@" + domain))); } @Test @@ -247,15 +245,15 @@ class SesSendVerifiedSenderIntegrationTest { // "if you create and verify an identity for example.com, you don't need to create separate // identities for a.example.com, a.b.example.com, user@example.com, user@a.example.com". String domain = "verified-parent.floci.test"; - SesDomainIdentityTestHelper.createVerified(domain, AUTH_V2); + SesDomainIdentityTestHelper.createVerified(domain, SesV2Requests.AUTH); - assertSentV2(v2(AUTH_V2).body(simpleBody("anyone@a.b." + domain))); + assertSentV2(v2(SesV2Requests.AUTH).body(simpleBody("anyone@a.b." + domain))); } @Test void v1SendEmail_addressUnderADomainThatOnlyEndsLikeAVerifiedOne_returnsMessageRejected() { String domain = "verified-suffix.floci.test"; - SesDomainIdentityTestHelper.createVerified(domain, AUTH_V2); + SesDomainIdentityTestHelper.createVerified(domain, SesV2Requests.AUTH); String lookalike = "anyone@not-" + domain; assertMessageRejected(sendEmail(AUTH_V1, lookalike), lookalike); @@ -322,7 +320,7 @@ class SesSendVerifiedSenderIntegrationTest { String feedback = "v2-bounces@unverified-sender.floci.test"; verifyEmailIdentity(source); - assertMessageRejectedV2(v2(AUTH_V2).body(""" + assertMessageRejectedV2(v2(SesV2Requests.AUTH).body(""" { "FromEmailAddress": "%s", "FeedbackForwardingEmailAddress": "%s", @@ -340,7 +338,7 @@ class SesSendVerifiedSenderIntegrationTest { String feedback = "v2-raw-bounces@unverified-sender.floci.test"; verifyEmailIdentity(source); - assertMessageRejectedV2(v2(AUTH_V2).body(""" + assertMessageRejectedV2(v2(SesV2Requests.AUTH).body(""" { "FeedbackForwardingEmailAddress": "%s", "Destination": {"ToAddresses": ["to@example.com"]}, @@ -367,7 +365,7 @@ class SesSendVerifiedSenderIntegrationTest { String source = "raw-v2-source-" + VERIFIED; verifyEmailIdentity(source); - assertSentV2(v2(AUTH_V2).body(""" + assertSentV2(v2(SesV2Requests.AUTH).body(""" { "FromEmailAddress": "%s", "Destination": {"ToAddresses": ["to@example.com"]}, @@ -587,7 +585,7 @@ class SesSendVerifiedSenderIntegrationTest { @Test void v2SendBulkEmail_unverifiedFrom_rejectsTheWholeCall() { - assertBulkMessageRejectedV2(v2(AUTH_V2).body(bulkBody(UNVERIFIED)), UNVERIFIED); + assertBulkMessageRejectedV2(v2(SesV2Requests.AUTH).body(bulkBody(UNVERIFIED)), UNVERIFIED); assertNothingCapturedFrom(UNVERIFIED); } @@ -598,7 +596,7 @@ class SesSendVerifiedSenderIntegrationTest { String feedback = "bulk-bounces@unverified-sender.floci.test"; verifyEmailIdentity(source); - assertBulkMessageRejectedV2(v2(AUTH_V2).body(bulkBody(source, + assertBulkMessageRejectedV2(v2(SesV2Requests.AUTH).body(bulkBody(source, "\"FeedbackForwardingEmailAddress\": \"" + feedback + "\",", "[{\"Destination\": {\"ToAddresses\": [\"to@example.com\"]}}]")), feedback); @@ -608,7 +606,7 @@ class SesSendVerifiedSenderIntegrationTest { @Test void v2SendBulkEmail_noEntryHasARecipient_senderIsNotChecked() { // AWS fails each entry on its missing destination and never reaches the sender check. - v2(AUTH_V2).body(bulkBody(UNVERIFIED, "", "[{\"Destination\": {}}]")) + v2(SesV2Requests.AUTH).body(bulkBody(UNVERIFIED, "", "[{\"Destination\": {}}]")) .when() .post("/v2/email/outbound-bulk-emails") .then() @@ -621,7 +619,7 @@ class SesSendVerifiedSenderIntegrationTest { String source = "bulk-" + VERIFIED; verifyEmailIdentity(source); - v2(AUTH_V2).body(bulkBody(source)) + v2(SesV2Requests.AUTH).body(bulkBody(source)) .when() .post("/v2/email/outbound-bulk-emails") .then() diff --git a/src/test/java/io/floci/aws/services/ses/SesSimpleAttachmentsV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSimpleAttachmentsV2IntegrationTest.java index 78f79bf333..e54c2d9f91 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSimpleAttachmentsV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSimpleAttachmentsV2IntegrationTest.java @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.Base64; import java.util.List; +import static io.floci.aws.services.ses.SesV2Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.*; @@ -35,8 +36,6 @@ import static org.junit.jupiter.api.Assertions.*; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesSimpleAttachmentsV2IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String SENDER = "attach-sender@example.com"; private static final byte[] PDF_BYTES = "%PDF-1.4 fake report \u0000\u0001ÿ".getBytes(StandardCharsets.ISO_8859_1); private static final byte[] PNG_BYTES = {(byte) 0x89, 'P', 'N', 'G', 0, 1, 2, 3, (byte) 0xfe}; diff --git a/src/test/java/io/floci/aws/services/ses/SesSuppressionV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSuppressionV2IntegrationTest.java index 1b96091e86..0716bfd2e9 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSuppressionV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSuppressionV2IntegrationTest.java @@ -6,6 +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.floci.aws.services.ses.SesV2TimestampMatchers.DECIMAL_NUMBERS; import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis; import static io.restassured.RestAssured.given; @@ -18,15 +19,12 @@ import static org.hamcrest.Matchers.*; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesSuppressionV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void putSuppressedDestination_bounce() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "bounce-1@example.com", "Reason": "BOUNCE"} """) @@ -41,7 +39,7 @@ class SesSuppressionV2IntegrationTest { void putSuppressedDestination_complaint() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "complaint-1@example.com", "Reason": "COMPLAINT"} """) @@ -56,7 +54,7 @@ class SesSuppressionV2IntegrationTest { void getSuppressedDestination_returnsStoredEntry() { given() .config(DECIMAL_NUMBERS) - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/bounce-1@example.com") .then() @@ -70,7 +68,7 @@ class SesSuppressionV2IntegrationTest { @Order(4) void getSuppressedDestination_unknown_returns404() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/missing@example.com") .then() @@ -83,7 +81,7 @@ class SesSuppressionV2IntegrationTest { void putSuppressedDestination_updatesExistingReason() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "bounce-1@example.com", "Reason": "COMPLAINT"} """) @@ -93,7 +91,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/bounce-1@example.com") .then() @@ -106,7 +104,7 @@ class SesSuppressionV2IntegrationTest { void listSuppressedDestinations_returnsAll() { given() .config(DECIMAL_NUMBERS) - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses") .then() @@ -125,7 +123,7 @@ class SesSuppressionV2IntegrationTest { // and the assertion would pass even if the server ignored the filter. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "filter-bounce@example.com", "Reason": "BOUNCE"} """) @@ -135,7 +133,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("Reason", "COMPLAINT") .when() .get("/v2/email/suppression/addresses") @@ -147,7 +145,7 @@ class SesSuppressionV2IntegrationTest { // Clean up so the BOUNCE seed does not leak into later assertions given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/suppression/addresses/filter-bounce@example.com") .then() @@ -158,14 +156,14 @@ class SesSuppressionV2IntegrationTest { @Order(8) void deleteSuppressedDestination_removesEntry() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/suppression/addresses/bounce-1@example.com") .then() .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/bounce-1@example.com") .then() @@ -178,7 +176,7 @@ class SesSuppressionV2IntegrationTest { // AWS DeleteSuppressedDestination is not idempotent — an unknown email // surfaces as NotFoundException with the same wording as GetSuppressedDestination. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/suppression/addresses/already-gone@example.com") .then() @@ -192,7 +190,7 @@ class SesSuppressionV2IntegrationTest { void putSuppressedDestination_invalidReason_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "bad@example.com", "Reason": "OTHER"} """) @@ -208,7 +206,7 @@ class SesSuppressionV2IntegrationTest { void putSuppressedDestination_missingEmailAddress_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"Reason": "BOUNCE"} """) @@ -224,7 +222,7 @@ class SesSuppressionV2IntegrationTest { void putSuppressedDestination_missingBody_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .put("/v2/email/suppression/addresses") .then() @@ -237,7 +235,7 @@ class SesSuppressionV2IntegrationTest { // JSON null for EmailAddress must not coerce into the literal string "null". given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": null, "Reason": "BOUNCE"} """) @@ -253,7 +251,7 @@ class SesSuppressionV2IntegrationTest { void putSuppressedDestination_nullReason_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "null-reason@example.com", "Reason": null} """) @@ -269,7 +267,7 @@ class SesSuppressionV2IntegrationTest { void putSuppressedDestination_nonObjectBody_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("[\"not\", \"an\", \"object\"]") .when() .put("/v2/email/suppression/addresses") @@ -285,7 +283,7 @@ class SesSuppressionV2IntegrationTest { // AWS silently trims leading/trailing whitespace from EmailAddress on Put. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": " padded@example.com ", "Reason": "BOUNCE"} """) @@ -295,7 +293,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/padded@example.com") .then() @@ -307,7 +305,7 @@ class SesSuppressionV2IntegrationTest { @Order(14) void listSuppressedDestinations_unknownReasonFilter_returns400() { given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("Reason", "OTHER") .when() .get("/v2/email/suppression/addresses") @@ -322,7 +320,7 @@ class SesSuppressionV2IntegrationTest { // Seed a BOUNCE entry alongside the surviving complaint-1 COMPLAINT entry given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "multi-bounce@example.com", "Reason": "BOUNCE"} """) @@ -332,7 +330,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("Reason", "BOUNCE") .queryParam("Reason", "COMPLAINT") .when() @@ -351,7 +349,7 @@ class SesSuppressionV2IntegrationTest { // is stored and read back as MixedCase@example.com. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "MixedCase@Example.COM", "Reason": "BOUNCE"} """) @@ -361,7 +359,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/MixedCase@Example.COM") .then() @@ -378,7 +376,7 @@ class SesSuppressionV2IntegrationTest { // does not (it is a different key). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "CaseProbe@Example.COM", "Reason": "BOUNCE"} """) @@ -388,7 +386,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/CaseProbe@EXAMPLE.com") .then() @@ -396,7 +394,7 @@ class SesSuppressionV2IntegrationTest { .body("SuppressedDestination.EmailAddress", equalTo("CaseProbe@example.com")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/caseprobe@example.com") .then() @@ -409,7 +407,7 @@ class SesSuppressionV2IntegrationTest { // PUT one domain case, DELETE a different domain case (same local-part), GET 404. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "DeleteMe@Example.com", "Reason": "COMPLAINT"} """) @@ -419,14 +417,14 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/suppression/addresses/DeleteMe@EXAMPLE.com") .then() .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/DeleteMe@example.com") .then() @@ -439,7 +437,7 @@ class SesSuppressionV2IntegrationTest { // Same local-part, domain differing only in case: one entry, latest Reason wins. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "UpdateTarget@example.com", "Reason": "BOUNCE"} """) @@ -450,7 +448,7 @@ class SesSuppressionV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "UpdateTarget@EXAMPLE.com", "Reason": "COMPLAINT"} """) @@ -460,7 +458,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/UpdateTarget@example.com") .then() @@ -476,7 +474,7 @@ class SesSuppressionV2IntegrationTest { // its own Reason. Verified against real AWS SES V2 (2026-06-15). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "LocalCase@distinct.example.com", "Reason": "BOUNCE"} """) @@ -487,7 +485,7 @@ class SesSuppressionV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailAddress": "localcase@distinct.example.com", "Reason": "COMPLAINT"} """) @@ -497,7 +495,7 @@ class SesSuppressionV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/LocalCase@distinct.example.com") .then() @@ -505,7 +503,7 @@ class SesSuppressionV2IntegrationTest { .body("SuppressedDestination.Reason", equalTo("BOUNCE")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/suppression/addresses/localcase@distinct.example.com") .then() diff --git a/src/test/java/io/floci/aws/services/ses/SesTagArnV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTagArnV2IntegrationTest.java index 1212a8e893..97c92dd901 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTagArnV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTagArnV2IntegrationTest.java @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test; 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.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItem; @@ -17,8 +18,6 @@ import static org.hamcrest.Matchers.hasSize; @QuarkusTest class SesTagArnV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String PREFIX = "arn:aws:ses:us-east-1:000000000000:"; private static final String BARE_VALIDATION = "{\"__type\":\"ValidationException\",\"message\":null}"; @@ -118,7 +117,7 @@ class SesTagArnV2IntegrationTest { void omittedResourceArn_onTagAndUntag_isMessagelessValidation() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"Tags\": [{\"Key\": \"k\", \"Value\": \"v\"}]}") .when() .post("/v2/email/tags") @@ -127,7 +126,7 @@ class SesTagArnV2IntegrationTest { .body(equalTo(BARE_VALIDATION)); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("TagKeys", "k") .when() .delete("/v2/email/tags") @@ -140,7 +139,7 @@ class SesTagArnV2IntegrationTest { void omittedResourceArn_onList_staysAClientError() { // AWS answers this with a 500 InternalFailure; Floci keeps a 400 on purpose. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/tags") .then() @@ -160,7 +159,7 @@ class SesTagArnV2IntegrationTest { String name = prefix + "-" + System.nanoTime(); given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "%s", "Tags": [{"Key": "%s", "Value": "%s"}]} """.formatted(name, key, value)) @@ -173,7 +172,7 @@ class SesTagArnV2IntegrationTest { private static Response listTags(String arn) { return given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags"); @@ -186,7 +185,7 @@ class SesTagArnV2IntegrationTest { private static Response tagWith(String arn, String key, String value) { return given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "%s", "Value": "%s"}]} """.formatted(arn, key, value)) @@ -196,7 +195,7 @@ class SesTagArnV2IntegrationTest { private static Response untag(String arn) { return given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "probe") .when() diff --git a/src/test/java/io/floci/aws/services/ses/SesTagsV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTagsV2IntegrationTest.java index 8b4301fa05..760e52728d 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTagsV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTagsV2IntegrationTest.java @@ -6,6 +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 org.hamcrest.Matchers.*; @@ -17,16 +18,13 @@ import static org.hamcrest.Matchers.*; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesTagsV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void tags_lifecycle_onConfigurationSet() { // Seed: create a configuration set we can tag against given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "tag-cs-1"} """) @@ -39,7 +37,7 @@ class SesTagsV2IntegrationTest { // Initially empty given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -50,7 +48,7 @@ class SesTagsV2IntegrationTest { // TagResource given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [ {"Key": "env", "Value": "dev"}, @@ -63,7 +61,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -76,7 +74,7 @@ class SesTagsV2IntegrationTest { // TagResource on existing key replaces value (merge semantics) given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [ {"Key": "env", "Value": "prod"} @@ -88,7 +86,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -99,7 +97,7 @@ class SesTagsV2IntegrationTest { // UntagResource removes specific keys given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "env") .when() @@ -108,7 +106,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -124,7 +122,7 @@ class SesTagsV2IntegrationTest { // Seed: create an email template we can tag against given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "tag-tpl-1", @@ -140,7 +138,7 @@ class SesTagsV2IntegrationTest { // Initially empty given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -151,7 +149,7 @@ class SesTagsV2IntegrationTest { // Tag the template given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [ {"Key": "env", "Value": "stg"}, @@ -164,7 +162,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -174,7 +172,7 @@ class SesTagsV2IntegrationTest { // Remove a key given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "env") .when() @@ -183,7 +181,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -199,7 +197,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:template/missing-tpl"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]} """.formatted(arn)) @@ -216,7 +214,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/missing-cs"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]} """.formatted(arn)) @@ -231,7 +229,7 @@ class SesTagsV2IntegrationTest { void listTagsForResource_unsupportedResourceType_returns404() { String arn = "arn:aws:ses:us-east-1:000000000000:identity/example.com"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -244,7 +242,7 @@ class SesTagsV2IntegrationTest { void tagResource_invalidArn_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "not-an-arn", "Tags": [{"Key": "env", "Value": "dev"}]} """) @@ -262,7 +260,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/tag-cs-1"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": []} """.formatted(arn)) @@ -272,7 +270,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -284,7 +282,7 @@ class SesTagsV2IntegrationTest { // The no-op still checks existence: an unknown resource stays NotFound. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "arn:aws:ses:us-east-1:000000000000:configuration-set/nowhere", "Tags": []} """) @@ -302,7 +300,7 @@ class SesTagsV2IntegrationTest { // carries "message":null, which restJson1 SDKs parse identically). String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/tag-cs-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .delete("/v2/email/tags") @@ -321,7 +319,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses::000000000000:configuration-set/tag-cs-1"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]} """.formatted(arn)) @@ -337,7 +335,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:s3:us-east-1:000000000000:bucket/my-bucket"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]} """.formatted(arn)) @@ -355,7 +353,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:eu-west-1:000000000000:configuration-set/tag-cs-1"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]} """.formatted(arn)) @@ -374,7 +372,7 @@ class SesTagsV2IntegrationTest { // (probe-confirmed). String arn = "arn:aws:ses:eu-west-1:000000000000:configuration-set/tag-cs-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "k") .when() @@ -392,7 +390,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/has spaces"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]} """.formatted(arn)) @@ -410,7 +408,7 @@ class SesTagsV2IntegrationTest { // routes the lookup to the ARN's region and surfaces NotFound instead. String arn = "arn:aws:ses:eu-west-1:000000000000:template/tag-tpl-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "k") .when() @@ -429,7 +427,7 @@ class SesTagsV2IntegrationTest { // addresses an ARN nothing was tagged under — 200 with an empty tag set. String arn = "arn:aws:ses:eu-west-1:000000000000:template/tag-tpl-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -444,7 +442,7 @@ class SesTagsV2IntegrationTest { // Seed: create an email identity we can tag against given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "tag-id-1@example.com"} """) @@ -457,7 +455,7 @@ class SesTagsV2IntegrationTest { // Initially empty given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -468,7 +466,7 @@ class SesTagsV2IntegrationTest { // Tag it given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [ {"Key": "env", "Value": "stg"}, @@ -481,7 +479,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -491,7 +489,7 @@ class SesTagsV2IntegrationTest { // Untag a key given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "env") .when() @@ -500,7 +498,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -516,7 +514,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:identity/missing-id@example.com"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]} """.formatted(arn)) @@ -533,7 +531,7 @@ class SesTagsV2IntegrationTest { // Identity follows the same strict region check as templates for UntagResource. String arn = "arn:aws:ses:eu-west-1:000000000000:identity/tag-id-1@example.com"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "k") .when() @@ -551,7 +549,7 @@ class SesTagsV2IntegrationTest { // was tagged under — 200 with an empty tag set (probe-confirmed). String arn = "arn:aws:ses:eu-west-1:000000000000:identity/tag-id-1@example.com"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -567,7 +565,7 @@ class SesTagsV2IntegrationTest { // existing key (net count unchanged) is allowed. Probe-confirmed against real AWS. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ConfigurationSetName": "tag-cs-merge"} """) @@ -581,7 +579,7 @@ class SesTagsV2IntegrationTest { // Seed with the full 50 tags. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": " + tagArray(0, 50) + "}") .when() .post("/v2/email/tags") @@ -591,7 +589,7 @@ class SesTagsV2IntegrationTest { // Updating an existing key keeps the count at 50 and is accepted. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": [{\"Key\": \"k0\", \"Value\": \"updated\"}]}") .when() .post("/v2/email/tags") @@ -601,7 +599,7 @@ class SesTagsV2IntegrationTest { // Adding one new key would make 51 — rejected with the merge-specific message. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": [{\"Key\": \"extra\", \"Value\": \"v\"}]}") .when() .post("/v2/email/tags") @@ -618,7 +616,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:configuration-set/tag-cs-1"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{\"ResourceArn\": \"" + arn + "\", \"Tags\": [{\"Key\": \"aws:foo\", \"Value\": \"v\"}]}") .when() .post("/v2/email/tags") @@ -637,7 +635,7 @@ class SesTagsV2IntegrationTest { String id = "atomic-tag-id@example.com"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "%s", "Tags": [ {"Key": "dup", "Value": "1"}, @@ -653,7 +651,7 @@ class SesTagsV2IntegrationTest { // The failed create must leave no identity behind. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/" + id) .then() @@ -666,7 +664,7 @@ class SesTagsV2IntegrationTest { // Seed: create a contact list with inline tags given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ContactListName": "tag-cl-1", "Tags": [{"Key": "env", "Value": "dev"}]} """) @@ -679,7 +677,7 @@ class SesTagsV2IntegrationTest { // Inline create tags are visible via ListTagsForResource given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -691,7 +689,7 @@ class SesTagsV2IntegrationTest { // TagResource merges an additional key given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "owner", "Value": "alice"}]} """.formatted(arn)) @@ -701,7 +699,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -711,7 +709,7 @@ class SesTagsV2IntegrationTest { // UntagResource removes a key given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "env") .when() @@ -720,7 +718,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -734,7 +732,7 @@ class SesTagsV2IntegrationTest { // existence check but returns an empty set for the untagged mismatched ARN. String euArn = "arn:aws:ses:eu-west-1:000000000000:contact-list/tag-cl-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", euArn) .queryParam("TagKeys", "k") .when() @@ -744,7 +742,7 @@ class SesTagsV2IntegrationTest { .body(containsString("Failed to untag resource")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", euArn) .when() .get("/v2/email/tags") @@ -754,7 +752,7 @@ class SesTagsV2IntegrationTest { // Free the one-list-per-account slot so later contact-list tests aren't order-dependent. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/contact-lists/tag-cl-1") .then() @@ -767,7 +765,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:contact-list/missing-cl"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]} """.formatted(arn)) @@ -784,7 +782,7 @@ class SesTagsV2IntegrationTest { // Seed: CVET creation requires a verified From identity given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "tag-cvet-sender@floci.test"} """) @@ -795,7 +793,7 @@ class SesTagsV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "tag-cvet-1", @@ -814,7 +812,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:custom-verification-email-template/tag-cvet-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -824,7 +822,7 @@ class SesTagsV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [ {"Key": "env", "Value": "dev"}, @@ -839,7 +837,7 @@ class SesTagsV2IntegrationTest { // UpdateCustomVerificationEmailTemplate must not wipe the tags given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "tag-cvet-sender@floci.test", @@ -855,7 +853,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -864,7 +862,7 @@ class SesTagsV2IntegrationTest { .body("Tags", hasSize(2)); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "env") .when() @@ -873,7 +871,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -889,7 +887,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:custom-verification-email-template/missing-cvet"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]} """.formatted(arn)) @@ -906,7 +904,7 @@ class SesTagsV2IntegrationTest { // Seed: create a pool with inline tags given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"PoolName": "tag-pool-1", "Tags": [{"Key": "env", "Value": "dev"}]} """) @@ -918,7 +916,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:dedicated-ip-pool/tag-pool-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -929,7 +927,7 @@ class SesTagsV2IntegrationTest { // GetDedicatedIpPool keeps the AWS shape: no Tags member given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/dedicated-ip-pools/tag-pool-1") .then() @@ -939,7 +937,7 @@ class SesTagsV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "owner", "Value": "alice"}]} """.formatted(arn)) @@ -949,7 +947,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "env") .when() @@ -958,7 +956,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -974,7 +972,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:dedicated-ip-pool/missing-pool"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "env", "Value": "dev"}]} """.formatted(arn)) @@ -992,7 +990,7 @@ class SesTagsV2IntegrationTest { // corrected retry does not hit AlreadyExistsException. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"PoolName": "atomic-tag-pool", "Tags": [ {"Key": "dup", "Value": "1"}, @@ -1007,7 +1005,7 @@ class SesTagsV2IntegrationTest { .body("message", equalTo("Cannot provide multiple tags with the same key")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/dedicated-ip-pools/atomic-tag-pool") .then() @@ -1020,7 +1018,7 @@ class SesTagsV2IntegrationTest { // Probe-confirmed. String arn = "arn:aws:ses:eu-west-1:000000000000:custom-verification-email-template/tag-cvet-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "k") .when() @@ -1038,7 +1036,7 @@ class SesTagsV2IntegrationTest { // was tagged under — 200 with an empty tag set (probe-confirmed). String arn = "arn:aws:ses:eu-west-1:000000000000:custom-verification-email-template/tag-cvet-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -1053,7 +1051,7 @@ class SesTagsV2IntegrationTest { // Probe-confirmed. String arn = "arn:aws:ses:eu-west-1:000000000000:dedicated-ip-pool/tag-pool-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "k") .when() @@ -1071,7 +1069,7 @@ class SesTagsV2IntegrationTest { // was tagged under — 200 with an empty tag set (probe-confirmed). String arn = "arn:aws:ses:eu-west-1:000000000000:dedicated-ip-pool/tag-pool-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -1087,7 +1085,7 @@ class SesTagsV2IntegrationTest { // the name here exists nowhere, yet the account error wins over NotFound. String arn = "arn:aws:ses:us-east-1:999999999999:configuration-set/nowhere"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -1102,7 +1100,7 @@ class SesTagsV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:999999999999:configuration-set/tag-cs-1"; given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"ResourceArn": "%s", "Tags": [{"Key": "k", "Value": "v"}]} """.formatted(arn)) @@ -1120,7 +1118,7 @@ class SesTagsV2IntegrationTest { // not "Failed to untag resource" (probe-confirmed). String arn = "arn:aws:ses:eu-west-1:999999999999:configuration-set/tag-cs-1"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .queryParam("TagKeys", "k") .when() @@ -1137,7 +1135,7 @@ class SesTagsV2IntegrationTest { // identity tag-cvet-sender@floci.test was verified by the lifecycle case at @Order(25). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "tag-cvet-inline", @@ -1155,7 +1153,7 @@ class SesTagsV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", "arn:aws:ses:us-east-1:000000000000:custom-verification-email-template/tag-cvet-inline") .when() @@ -1169,7 +1167,7 @@ class SesTagsV2IntegrationTest { // retry does not hit AlreadyExistsException (probe-confirmed message and atomicity). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "tag-cvet-atomic", @@ -1188,7 +1186,7 @@ class SesTagsV2IntegrationTest { .body(containsString("Cannot provide multiple tags with the same key")); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/custom-verification-email-templates/tag-cvet-atomic") .then() @@ -1196,7 +1194,7 @@ class SesTagsV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "tag-cvet-atomic", diff --git a/src/test/java/io/floci/aws/services/ses/SesTemplateNameIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTemplateNameIntegrationTest.java index 739bb12cea..4b74a37927 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTemplateNameIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTemplateNameIntegrationTest.java @@ -22,8 +22,6 @@ class SesTemplateNameIntegrationTest { private static final String V1_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - private static final String V2_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String BLANK = "The template name must be specified."; private static final String TOO_LONG = "Template name cannot exceed 64 characters."; @@ -82,7 +80,7 @@ class SesTemplateNameIntegrationTest { void v2_everyOperationRefusesTheName(String name, String message) { given() .contentType("application/json; charset=UTF-8") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"TemplateName\": \"" + name + "\", \"TemplateContent\": {\"Subject\": \"S\", \"Text\": \"t\"}}") .when() .post("/v2/email/templates") @@ -93,7 +91,7 @@ class SesTemplateNameIntegrationTest { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"TemplateContent\": {\"Subject\": \"S\", \"Text\": \"t\"}}") .when() .put("/v2/email/templates/{name}", name) @@ -103,7 +101,7 @@ class SesTemplateNameIntegrationTest { .body("message", equalTo(message)); given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .get("/v2/email/templates/{name}", name) .then() @@ -112,7 +110,7 @@ class SesTemplateNameIntegrationTest { .body("message", equalTo(message)); given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .delete("/v2/email/templates/{name}", name) .then() @@ -122,7 +120,7 @@ class SesTemplateNameIntegrationTest { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"TemplateData\": \"{}\"}") .when() .post("/v2/email/templates/{name}/render", name) @@ -149,7 +147,7 @@ class SesTemplateNameIntegrationTest { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"TemplateName\": \"name probe\", \"TemplateContent\": {\"Text\": \"t\"}}") .when() .post("/v2/email/templates") @@ -174,7 +172,7 @@ class SesTemplateNameIntegrationTest { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"TemplateName\": \"name\\tprobe\", \"TemplateContent\": {\"Subject\": \"S\", \"Text\": \"t\"}}") .when() .post("/v2/email/templates") @@ -199,7 +197,7 @@ class SesTemplateNameIntegrationTest { .statusCode(200); given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .get("/v2/email/templates/{name}", name) .then() @@ -218,7 +216,7 @@ class SesTemplateNameIntegrationTest { .body(containsString("" + name + "")); given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .delete("/v2/email/templates/{name}", name) .then() diff --git a/src/test/java/io/floci/aws/services/ses/SesTemplateRequiredPartsIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTemplateRequiredPartsIntegrationTest.java index 836b0d26a4..b172cb99a6 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTemplateRequiredPartsIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTemplateRequiredPartsIntegrationTest.java @@ -22,8 +22,6 @@ class SesTemplateRequiredPartsIntegrationTest { private static final String V1_AUTH = "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - private static final String V2_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String NO_SUBJECT = "The subject must be specified."; private static final String NO_PART = "Template must specify at least one of the parts."; @@ -41,7 +39,7 @@ class SesTemplateRequiredPartsIntegrationTest { void v2Create_refusesTheContent(String content, String message) { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"TemplateName\": \"required-parts-refused\", \"TemplateContent\": " + content + "}") .when() .post("/v2/email/templates") @@ -56,7 +54,7 @@ class SesTemplateRequiredPartsIntegrationTest { void v2Update_refusesTheContentOfAnUnknownTemplate(String content, String message) { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body("{\"TemplateContent\": " + content + "}") .when() .put("/v2/email/templates/required-parts-ghost") @@ -70,7 +68,7 @@ class SesTemplateRequiredPartsIntegrationTest { void v2Create_readsAnEmptyPartBackAsNoPart() { given() .contentType("application/json") - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .body(""" {"TemplateName": "required-parts-html-only", "TemplateContent": {"Subject": "S", "Text": "", "Html": "

h

"}} @@ -81,7 +79,7 @@ class SesTemplateRequiredPartsIntegrationTest { .statusCode(200); given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .get("/v2/email/templates/required-parts-html-only") .then() @@ -90,7 +88,7 @@ class SesTemplateRequiredPartsIntegrationTest { .body("TemplateContent.Text", nullValue()); given() - .header("Authorization", V2_AUTH) + .header("Authorization", SesV2Requests.AUTH) .when() .delete("/v2/email/templates/required-parts-html-only") .then() diff --git a/src/test/java/io/floci/aws/services/ses/SesTemplateTagOrderIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTemplateTagOrderIntegrationTest.java index cfdd4ce84f..32e1b92b49 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTemplateTagOrderIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTemplateTagOrderIntegrationTest.java @@ -10,6 +10,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; +import static io.floci.aws.services.ses.SesV2Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; @@ -20,8 +21,6 @@ import static org.hamcrest.Matchers.equalTo; @QuarkusTest class SesTemplateTagOrderIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String SUBJECT_ONLY = "{\"Subject\": \"S\"}"; private static final String VALID = "{\"Subject\": \"S\", \"Text\": \"t\"}"; private static final String CHARSET = "Tags can only contain letters, numbers, spaces, and the following " diff --git a/src/test/java/io/floci/aws/services/ses/SesTemplateV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTemplateV2IntegrationTest.java index 3656a468c6..26cf05b0ee 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTemplateV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTemplateV2IntegrationTest.java @@ -11,6 +11,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.SesV2TimestampMatchers.DECIMAL_NUMBERS; import static io.floci.aws.services.ses.SesV2TimestampMatchers.epochSecondsWithMillis; import static io.restassured.RestAssured.given; @@ -28,15 +29,12 @@ import static org.hamcrest.Matchers.notNullValue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesTemplateV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void createTemplate() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "v2-welcome", @@ -58,7 +56,7 @@ class SesTemplateV2IntegrationTest { void createTemplate_duplicateRejected() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "v2-welcome", @@ -78,7 +76,7 @@ class SesTemplateV2IntegrationTest { void createTemplate_missingName() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateContent": {"Subject": "x"}} """) @@ -94,7 +92,7 @@ class SesTemplateV2IntegrationTest { void getTemplate() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/v2-welcome") .then() @@ -110,7 +108,7 @@ class SesTemplateV2IntegrationTest { void getTemplate_notFound() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/does-not-exist") .then() @@ -123,7 +121,7 @@ class SesTemplateV2IntegrationTest { void updateTemplate() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateContent": { @@ -140,7 +138,7 @@ class SesTemplateV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/v2-welcome") .then() @@ -154,7 +152,7 @@ class SesTemplateV2IntegrationTest { void updateTemplate_notFound() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateContent": {"Subject": "x", "Text": "x"}} """) @@ -171,7 +169,7 @@ class SesTemplateV2IntegrationTest { given() .config(DECIMAL_NUMBERS) .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates") .then() @@ -186,7 +184,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_withTemplate_substitutesVariables() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "sender@example.com"} """) @@ -197,7 +195,7 @@ class SesTemplateV2IntegrationTest { String messageId = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -233,7 +231,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_withUnknownTemplate_returns404() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -258,7 +256,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_withTemplate_missingName_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -278,7 +276,7 @@ class SesTemplateV2IntegrationTest { void deleteTemplate() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/templates/v2-welcome") .then() @@ -286,7 +284,7 @@ class SesTemplateV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/v2-welcome") .then() @@ -298,7 +296,7 @@ class SesTemplateV2IntegrationTest { void deleteTemplate_notFound() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/templates/already-gone") .then() @@ -311,7 +309,7 @@ class SesTemplateV2IntegrationTest { void createTemplate_rejectsLeadingTrailingWhitespace() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": " padded ", @@ -330,7 +328,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_withInlineTemplate_substitutesVariables() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "inline-sender@example.com"} """) @@ -341,7 +339,7 @@ class SesTemplateV2IntegrationTest { String messageId = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inline-sender@example.com", @@ -381,7 +379,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_templateWithBothNameAndContent_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inline-sender@example.com", @@ -407,7 +405,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_withTemplateArn_resolvesStoredTemplate() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "arn-welcome", @@ -424,7 +422,7 @@ class SesTemplateV2IntegrationTest { String messageId = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inline-sender@example.com", @@ -459,7 +457,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_templateWithMalformedArn_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inline-sender@example.com", @@ -484,7 +482,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_templateWithNameAndArn_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inline-sender@example.com", @@ -542,7 +540,7 @@ class SesTemplateV2IntegrationTest { // Verify it does NOT exist in us-east-1 given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/region-test") .then() @@ -562,7 +560,7 @@ class SesTemplateV2IntegrationTest { void createEmailTemplate_withTags_visibleViaGet() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "tpl-with-tags", @@ -582,7 +580,7 @@ class SesTemplateV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/tpl-with-tags") .then() @@ -598,7 +596,7 @@ class SesTemplateV2IntegrationTest { // tpl-with-tags is created in @Order(21) above String arn = "arn:aws:ses:us-east-1:000000000000:template/tpl-with-tags"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -614,7 +612,7 @@ class SesTemplateV2IntegrationTest { // tpl-with-tags has 2 tags from @Order(21) given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateContent": { @@ -629,7 +627,7 @@ class SesTemplateV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/tpl-with-tags") .then() @@ -646,7 +644,7 @@ class SesTemplateV2IntegrationTest { // keys) atomically, before the template is persisted. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "v2-badtags", @@ -663,7 +661,7 @@ class SesTemplateV2IntegrationTest { // The failed create must leave no template behind. given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/templates/v2-badtags") .then() @@ -676,7 +674,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_malformedShape_returnsBadRequest(String label, String body) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-emails") @@ -691,7 +689,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_nonObjectBody_isASerializationException(String body, String message) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-emails") @@ -707,7 +705,7 @@ class SesTemplateV2IntegrationTest { void sendEmail_wrongMemberType_returnsSerializationException(String label, String body) { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(body) .when() .post("/v2/email/outbound-emails") diff --git a/src/test/java/io/floci/aws/services/ses/SesTenantV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTenantV2IntegrationTest.java index 608f65550b..cdeff86648 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTenantV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTenantV2IntegrationTest.java @@ -6,6 +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 org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.matchesPattern; @@ -22,8 +23,6 @@ import static org.hamcrest.Matchers.startsWith; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesTenantV2IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; private static final String TENANT = "floci-it-tenant"; @Test diff --git a/src/test/java/io/floci/aws/services/ses/SesTestRenderV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTestRenderV2IntegrationTest.java index 11140b0f5a..24c264d9f9 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTestRenderV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTestRenderV2IntegrationTest.java @@ -13,6 +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 org.hamcrest.Matchers.equalTo; @@ -20,15 +21,12 @@ import static org.hamcrest.Matchers.equalTo; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesTestRenderV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void createTemplate() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "v2-render-welcome", @@ -50,7 +48,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_substitutesVariables() { String rendered = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateData": "{\\"name\\":\\"Alice\\",\\"team\\":\\"floci\\"}"} """) @@ -71,7 +69,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_unknownTemplate_returns404() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateData": "{}"} """) @@ -88,7 +86,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_unknownTemplateWithMalformedData_reportsTheData() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateData": "[1]"} """) @@ -105,7 +103,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_invalidJson_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateData": "{not json"} """) @@ -122,7 +120,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_missingVariable_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateData": "{\\"name\\":\\"Alice\\"}"} """) @@ -139,7 +137,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_malformedBody_returns400(String label, String body) { RequestSpecification spec = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER); + .header("Authorization", AUTH); if (body != null) { spec = spec.body(body); } @@ -163,7 +161,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_arrayBody_isASerializationException() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("[1,2,3]") .when() .post("/v2/email/templates/v2-render-welcome/render") @@ -178,7 +176,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_dateHeaderIsUtc() { String rendered = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateData": "{\\"name\\":\\"Alice\\",\\"team\\":\\"floci\\"}"} """) @@ -199,7 +197,7 @@ class SesTestRenderV2IntegrationTest { void testRenderEmailTemplate_utf8Body_isBase64WithAnEncodedSubject() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "v2-render-jp", @@ -216,7 +214,7 @@ class SesTestRenderV2IntegrationTest { String rendered = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"TemplateData": "{\\"name\\":\\"太郎\\"}"} """) diff --git a/src/test/java/io/floci/aws/services/ses/SesV2IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesV2IntegrationTest.java index 95d3751c03..f974e3024b 100644 --- a/src/test/java/io/floci/aws/services/ses/SesV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesV2IntegrationTest.java @@ -8,6 +8,7 @@ import org.junit.jupiter.api.TestMethodOrder; import java.util.List; +import static io.floci.aws.services.ses.SesV2Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.*; @@ -18,15 +19,12 @@ import static org.hamcrest.Matchers.*; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesV2IntegrationTest { - private static final String AUTH_HEADER = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request"; - @Test @Order(1) void createEmailIdentity_email() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "v2sender@example.com"} """) @@ -43,7 +41,7 @@ class SesV2IntegrationTest { void createEmailIdentity_domain() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "v2example.com"} """) @@ -61,7 +59,7 @@ class SesV2IntegrationTest { // A subsequent GetEmailIdentity transitions the DKIM status to PENDING, matching AWS. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2example.com") .then() @@ -74,7 +72,7 @@ class SesV2IntegrationTest { void createEmailIdentity_missingField() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{}") .when() .post("/v2/email/identities") @@ -89,7 +87,7 @@ class SesV2IntegrationTest { // Other classes share this region, so ask for a page large enough to hold every identity. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("PageSize", 1000) .when() .get("/v2/email/identities") @@ -117,7 +115,7 @@ class SesV2IntegrationTest { void getEmailIdentity() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2sender@example.com") .then() @@ -132,7 +130,7 @@ class SesV2IntegrationTest { void getEmailIdentity_domainTransitionsToSuccessWhenDkimRecordsExist() { List tokens = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "v2dkim-success.floci.test"} """) @@ -149,7 +147,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2dkim-success.floci.test") .then() @@ -165,7 +163,7 @@ class SesV2IntegrationTest { // DKIM keeps Status=SUCCESS while the CNAMEs remain published. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningEnabled": false} """) @@ -176,7 +174,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2dkim-success.floci.test") .then() @@ -187,7 +185,7 @@ class SesV2IntegrationTest { // Re-enable so the key-rotation assertion below starts from the signing-enabled state. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningEnabled": true} """) @@ -200,7 +198,7 @@ class SesV2IntegrationTest { // VerificationStatus stays SUCCESS, but DKIM re-pends until the new tokens' records are detected. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningAttributesOrigin":"AWS_SES","SigningAttributes":{"NextSigningKeyLength":"RSA_1024_BIT"}} """) @@ -211,7 +209,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2dkim-success.floci.test") .then() @@ -225,7 +223,7 @@ class SesV2IntegrationTest { void getEmailIdentity_notFound() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/nonexistent@example.com") .then() @@ -238,7 +236,7 @@ class SesV2IntegrationTest { void sendEmail_simple() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "v2sender@example.com", @@ -267,7 +265,7 @@ class SesV2IntegrationTest { void sendEmail_html() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "v2sender@example.com", @@ -297,7 +295,7 @@ class SesV2IntegrationTest { void sendEmail_raw() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "v2sender@example.com", @@ -323,7 +321,7 @@ class SesV2IntegrationTest { void sendEmail_missingContent() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "v2sender@example.com", @@ -348,7 +346,7 @@ class SesV2IntegrationTest { // the stored value, so this assertion only holds before those run. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/account") .then() @@ -367,7 +365,7 @@ class SesV2IntegrationTest { void deleteEmailIdentity() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .delete("/v2/email/identities/v2sender@example.com") .then() @@ -378,7 +376,7 @@ class SesV2IntegrationTest { // Verify it's gone given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2sender@example.com") .then() @@ -390,7 +388,7 @@ class SesV2IntegrationTest { void sendEmail_template() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "template-sender@example.com"} """) @@ -401,7 +399,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "TemplateName": "MyTemplate", @@ -418,7 +416,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "template-sender@example.com", @@ -445,7 +443,7 @@ class SesV2IntegrationTest { void createEmailIdentity_rejectsLeadingTrailingWhitespace() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": " padded@example.com "} """) @@ -464,7 +462,7 @@ class SesV2IntegrationTest { // and ListTagsForResource (template/configuration-set behaviour parallel). given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "EmailIdentity": "v2-tag-roundtrip.floci.test", @@ -480,7 +478,7 @@ class SesV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/v2-tag-roundtrip.floci.test") .then() @@ -491,7 +489,7 @@ class SesV2IntegrationTest { String arn = "arn:aws:ses:us-east-1:000000000000:identity/v2-tag-roundtrip.floci.test"; given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .queryParam("ResourceArn", arn) .when() .get("/v2/email/tags") @@ -508,7 +506,7 @@ class SesV2IntegrationTest { // Create identity first given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "dkim-test@example.com"} """) @@ -520,7 +518,7 @@ class SesV2IntegrationTest { // Enable DKIM given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningEnabled": true} """) @@ -532,7 +530,7 @@ class SesV2IntegrationTest { // Verify DKIM is enabled on the identity given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/dkim-test@example.com") .then() @@ -548,7 +546,7 @@ class SesV2IntegrationTest { void putDkimAttributes_disable() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SigningEnabled": false} """) @@ -559,7 +557,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/dkim-test@example.com") .then() @@ -575,7 +573,7 @@ class SesV2IntegrationTest { void putFeedbackAttributes_disable() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailForwardingEnabled": false} """) @@ -586,7 +584,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/dkim-test@example.com") .then() @@ -599,7 +597,7 @@ class SesV2IntegrationTest { void putFeedbackAttributes_enable() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailForwardingEnabled": true} """) @@ -610,7 +608,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/dkim-test@example.com") .then() @@ -627,7 +625,7 @@ class SesV2IntegrationTest { // wire shape via remapV1Exception. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailForwardingEnabled": false} """) @@ -645,7 +643,7 @@ class SesV2IntegrationTest { void putAccountSendingAttributes_disable() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SendingEnabled": false} """) @@ -656,7 +654,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/account") .then() @@ -669,7 +667,7 @@ class SesV2IntegrationTest { void putAccountSendingAttributes_enable() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SendingEnabled": true} """) @@ -680,7 +678,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/account") .then() @@ -693,7 +691,7 @@ class SesV2IntegrationTest { void putAccountSuppressionAttributes_storesReasons_visibleViaGetAccount() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SuppressedReasons": ["BOUNCE", "COMPLAINT"]} """) @@ -703,7 +701,7 @@ class SesV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/account") .then() @@ -716,7 +714,7 @@ class SesV2IntegrationTest { void putAccountSuppressionAttributes_emptyArray_clearsReasons() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SuppressedReasons": []} """) @@ -726,7 +724,7 @@ class SesV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/account") .then() @@ -739,7 +737,7 @@ class SesV2IntegrationTest { void putAccountSuppressionAttributes_missingField_succeedsWithEmptyList() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body("{}") .when() .put("/v2/email/account/suppression") @@ -747,7 +745,7 @@ class SesV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/account") .then() @@ -760,7 +758,7 @@ class SesV2IntegrationTest { void putAccountSuppressionAttributes_invalidReason_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SuppressedReasons": ["BOUNCE", "OTHER"]} """) @@ -779,7 +777,7 @@ class SesV2IntegrationTest { void putAccountSuppressionAttributes_nullMember_returns400() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"SuppressedReasons": [null]} """) @@ -797,7 +795,7 @@ class SesV2IntegrationTest { // verifying the request shape does not regress to a 400. given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "SuppressedReasons": ["BOUNCE"], @@ -817,7 +815,7 @@ class SesV2IntegrationTest { .statusCode(200); given() - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/account") .then() @@ -831,7 +829,7 @@ class SesV2IntegrationTest { // Re-create identity given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "cc-only-sender@example.com"} """) @@ -843,7 +841,7 @@ class SesV2IntegrationTest { // Send with only CcAddresses (no ToAddresses) given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "cc-only-sender@example.com", @@ -872,7 +870,7 @@ class SesV2IntegrationTest { void sendEmail_raw_missingData() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "v2sender@example.com", @@ -892,7 +890,7 @@ class SesV2IntegrationTest { void sendEmail_raw_missingFrom() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "Destination": {"ToAddresses": ["r@example.com"]}, @@ -916,7 +914,7 @@ class SesV2IntegrationTest { void sendEmail_raw_noFromAddress_usesMimeFrom() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "raw-from@floci.test"} """) @@ -927,7 +925,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "Destination": {"ToAddresses": ["r@example.com"]}, @@ -946,7 +944,7 @@ class SesV2IntegrationTest { void sendEmail_simple_missingFrom() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "Destination": {"ToAddresses": ["r@example.com"]}, @@ -968,7 +966,7 @@ class SesV2IntegrationTest { void sendEmail_template_missingFrom() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "Destination": {"ToAddresses": ["r@example.com"]}, @@ -991,7 +989,7 @@ class SesV2IntegrationTest { // Create identity given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" {"EmailIdentity": "inspect-sender@example.com"} """) @@ -1006,7 +1004,7 @@ class SesV2IntegrationTest { // Send with distinct Text and Html bodies String messageId = given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inspect-sender@example.com", @@ -1048,7 +1046,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inspect-sender@example.com", @@ -1086,7 +1084,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inspect-sender@example.com", @@ -1124,7 +1122,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inspect-sender@example.com", @@ -1160,7 +1158,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inspect-sender@example.com", @@ -1195,7 +1193,7 @@ class SesV2IntegrationTest { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "inspect-sender@example.com", @@ -1248,8 +1246,7 @@ class SesV2IntegrationTest { // Send from us-east-1 given() .contentType("application/json") - .header("Authorization", - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request") + .header("Authorization", AUTH) .body(""" { "FromEmailAddress": "multi@example.com", @@ -1307,7 +1304,7 @@ class SesV2IntegrationTest { void getEmailIdentity_fullResponse() { given() .contentType("application/json") - .header("Authorization", AUTH_HEADER) + .header("Authorization", AUTH) .when() .get("/v2/email/identities/dkim-test@example.com") .then()