diff --git a/src/test/java/io/floci/aws/services/ses/SesBulkV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesBulkV1IntegrationTest.java index 7266ff21bd..585007759f 100644 --- a/src/test/java/io/floci/aws/services/ses/SesBulkV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesBulkV1IntegrationTest.java @@ -33,9 +33,6 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesBulkV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - // A sender of its own: an identity under example.com would outlive this class and reach the // other SES classes that share the application. private static final String SENDER = "bulk-v1@floci.test"; @@ -55,7 +52,7 @@ class SesBulkV1IntegrationTest { void createTemplate() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", SENDER) .when() @@ -65,7 +62,7 @@ class SesBulkV1IntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "CreateTemplate") .formParam("Template.TemplateName", "v1-bulk-welcome") .formParam("Template.SubjectPart", "Hello {{name}}") @@ -82,7 +79,7 @@ class SesBulkV1IntegrationTest { void sendBulkTemplatedEmail_perDestinationReplacement() { String body = given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -134,7 +131,7 @@ class SesBulkV1IntegrationTest { void sendBulkTemplatedEmail_unknownTemplate() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "ghost") @@ -152,7 +149,7 @@ class SesBulkV1IntegrationTest { void sendBulkTemplatedEmail_missingDestinations() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -170,7 +167,7 @@ class SesBulkV1IntegrationTest { void sendBulkTemplatedEmail_missingTemplate() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Destinations.member.1.Destination.ToAddresses.member.1", "alice@example.com") @@ -190,7 +187,7 @@ class SesBulkV1IntegrationTest { // validation refuses for the whole request (probe-confirmed). given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -221,7 +218,7 @@ class SesBulkV1IntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -248,7 +245,7 @@ class SesBulkV1IntegrationTest { void sendBulkTemplatedEmail_destinationsExceed50_isCountedBeforeTheTemplateLookup() { destinations(given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "ghost"), 51) @@ -269,7 +266,7 @@ class SesBulkV1IntegrationTest { // not as Failed. String body = given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -395,7 +392,7 @@ class SesBulkV1IntegrationTest { String template) { RequestSpecification spec = given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", source) .formParam("Template", template) @@ -471,7 +468,7 @@ class SesBulkV1IntegrationTest { private static RequestSpecification bulkSpec(String defaultTemplateData) { return given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -483,7 +480,7 @@ class SesBulkV1IntegrationTest { void sendBulkTemplatedEmail_fiftyDestinations_sendsEachDestination() { String body = destinations(given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -504,7 +501,7 @@ class SesBulkV1IntegrationTest { // for an unverified Source and a missing template (probe-confirmed). String body = given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", "bulk-v1-unverified@floci.test") .formParam("Template", "ghost") @@ -528,7 +525,7 @@ class SesBulkV1IntegrationTest { // boto3 sends nothing for Destination={}, which leaves a gap in the member indexes. given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -548,7 +545,7 @@ class SesBulkV1IntegrationTest { void sendBulkTemplatedEmail_emptyEntryBesideRecipients_failsOnlyThatEntry() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", SENDER) .formParam("Template", "v1-bulk-welcome") @@ -582,7 +579,7 @@ class SesBulkV1IntegrationTest { String message) { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParams(params) .when() diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV1IntegrationTest.java index b4835369d8..02af1d5f00 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetEventDestinationV1IntegrationTest.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.SesV1Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -21,8 +22,6 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetEventDestinationV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String CS = "v1-evt-cs"; private static final String ED = "v1-ed-sns"; private static final String TOPIC_ARN_A = "arn:aws:sns:us-east-1:000000000000:topic-a"; 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 43777a71d6..12f5c993a6 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 V1_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String SIXTY_FIVE = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; @@ -75,7 +73,7 @@ class SesConfigurationSetNameIntegrationTest { void v1_invalidCharacters_sameMessageAsV2() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "DescribeConfigurationSet") .formParam("ConfigurationSetName", "a.b") .when() @@ -91,7 +89,7 @@ class SesConfigurationSetNameIntegrationTest { void v1_tooLong() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "DeleteConfigurationSet") .formParam("ConfigurationSetName", SIXTY_FIVE) .when() @@ -111,7 +109,7 @@ class SesConfigurationSetNameIntegrationTest { }) { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", action[0]) .formParam(action[1], "") .formParam("Enabled", "true") @@ -128,7 +126,7 @@ class SesConfigurationSetNameIntegrationTest { void v1_updateSendingEnabled_validatesTheName() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "UpdateConfigurationSetSendingEnabled") .formParam("ConfigurationSetName", "a.b") .formParam("Enabled", "true") @@ -145,7 +143,7 @@ class SesConfigurationSetNameIntegrationTest { void v1_sendEmail_validatesTheConfigurationSetName() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendEmail") .formParam("Source", "sender@example.com") .formParam("Destination.ToAddresses.member.1", "success@simulator.amazonses.com") 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 9f4e5ea8c2..892a2d4dc6 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetTrackingOptionsV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetTrackingOptionsV1IntegrationTest.java @@ -1,13 +1,11 @@ package io.floci.aws.services.ses; import io.quarkus.test.junit.QuarkusTest; -import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -24,30 +22,21 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetTrackingOptionsV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String DOMAIN = "track-v1.floci.test"; private static final String CS = "v1-cs-tracking"; - private static RequestSpecification query(String action) { - return given() - .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) - .formParam("Action", action); - } - @Test @Order(1) void setup_verifyDomain_andCreateConfigSet() { SesDomainIdentityTestHelper.createVerified(DOMAIN, SesV2Requests.AUTH); - query("CreateConfigurationSet").formParam("ConfigurationSet.Name", CS) + SesV1Requests.query("CreateConfigurationSet").formParam("ConfigurationSet.Name", CS) .when().post("/").then().statusCode(200); } @Test @Order(2) void v1CreatedSet_reputationMetricsDefaultsDisabled() { - query("DescribeConfigurationSet") + SesV1Requests.query("DescribeConfigurationSet") .formParam("ConfigurationSetName", CS) .formParam("ConfigurationSetAttributeNames.member.1", "reputationOptions") .when().post("/") @@ -58,7 +47,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(3) void createTrackingOptions_unverifiedDomain_returns400() { - query("CreateConfigurationSetTrackingOptions") + SesV1Requests.query("CreateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .formParam("TrackingOptions.CustomRedirectDomain", "never-verified-v1.example.com") .when().post("/") @@ -70,14 +59,14 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(4) void createTrackingOptions_verifiedDomain_stored() { - query("CreateConfigurationSetTrackingOptions") + SesV1Requests.query("CreateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .formParam("TrackingOptions.CustomRedirectDomain", DOMAIN) .when().post("/") .then().statusCode(200) .body(containsString("CreateConfigurationSetTrackingOptionsResponse")); - query("DescribeConfigurationSet") + SesV1Requests.query("DescribeConfigurationSet") .formParam("ConfigurationSetName", CS) .formParam("ConfigurationSetAttributeNames.member.1", "trackingOptions") .when().post("/") @@ -88,7 +77,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(5) void createTrackingOptions_alreadyExists_returns400() { - query("CreateConfigurationSetTrackingOptions") + SesV1Requests.query("CreateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .formParam("TrackingOptions.CustomRedirectDomain", DOMAIN) .when().post("/") @@ -100,13 +89,13 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Order(6) void updateTrackingOptions_changesDomain() { SesDomainIdentityTestHelper.createVerified("other." + DOMAIN, SesV2Requests.AUTH); - query("UpdateConfigurationSetTrackingOptions") + SesV1Requests.query("UpdateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .formParam("TrackingOptions.CustomRedirectDomain", "other." + DOMAIN) .when().post("/") .then().statusCode(200); - query("DescribeConfigurationSet") + SesV1Requests.query("DescribeConfigurationSet") .formParam("ConfigurationSetName", CS) .formParam("ConfigurationSetAttributeNames.member.1", "trackingOptions") .when().post("/") @@ -117,13 +106,13 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(7) void deleteTrackingOptions_removesThem() { - query("DeleteConfigurationSetTrackingOptions") + SesV1Requests.query("DeleteConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .when().post("/") .then().statusCode(200) .body(containsString("DeleteConfigurationSetTrackingOptionsResponse")); - query("DescribeConfigurationSet") + SesV1Requests.query("DescribeConfigurationSet") .formParam("ConfigurationSetName", CS) .formParam("ConfigurationSetAttributeNames.member.1", "trackingOptions") .when().post("/") @@ -134,7 +123,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(8) void deleteTrackingOptions_whenNoneSet_returns400() { - query("DeleteConfigurationSetTrackingOptions") + SesV1Requests.query("DeleteConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .when().post("/") .then().statusCode(400) @@ -144,7 +133,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(9) void updateTrackingOptions_whenNoneSet_returns400() { - query("UpdateConfigurationSetTrackingOptions") + SesV1Requests.query("UpdateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .formParam("TrackingOptions.CustomRedirectDomain", DOMAIN) .when().post("/") @@ -156,14 +145,14 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Order(10) void trackingOptions_unknownConfigSet_domainCheckedFirst() { // Verified domain reaches the configuration-set lookup; unverified short-circuits first. - query("CreateConfigurationSetTrackingOptions") + SesV1Requests.query("CreateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", "v1-cs-ghost") .formParam("TrackingOptions.CustomRedirectDomain", DOMAIN) .when().post("/") .then().statusCode(400) .body(containsString("ConfigurationSetDoesNotExist")); - query("CreateConfigurationSetTrackingOptions") + SesV1Requests.query("CreateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", "v1-cs-ghost") .formParam("TrackingOptions.CustomRedirectDomain", "never-verified-v1.example.com") .when().post("/") @@ -176,7 +165,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { void createTrackingOptions_missingDomain_returnsValidationError() { // No TrackingOptions.CustomRedirectDomain param at all: AWS treats the // tracking-options member as null and returns a framework ValidationError. - query("CreateConfigurationSetTrackingOptions") + SesV1Requests.query("CreateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .when().post("/") .then().statusCode(400) @@ -189,7 +178,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { void createTrackingOptions_blankDomain_returnsInvalidTrackingOptions() { // Present but empty CustomRedirectDomain: the structure is non-null but has // no usable field, so AWS reports InvalidTrackingOptions instead. - query("CreateConfigurationSetTrackingOptions") + SesV1Requests.query("CreateConfigurationSetTrackingOptions") .formParam("ConfigurationSetName", CS) .formParam("TrackingOptions.CustomRedirectDomain", "") .when().post("/") @@ -201,14 +190,14 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(13) void updateReputationMetricsEnabled_togglesAndReflectsInDescribe() { - query("UpdateConfigurationSetReputationMetricsEnabled") + SesV1Requests.query("UpdateConfigurationSetReputationMetricsEnabled") .formParam("ConfigurationSetName", CS) .formParam("Enabled", "true") .when().post("/") .then().statusCode(200) .body(containsString("UpdateConfigurationSetReputationMetricsEnabledResponse")); - query("DescribeConfigurationSet") + SesV1Requests.query("DescribeConfigurationSet") .formParam("ConfigurationSetName", CS) .formParam("ConfigurationSetAttributeNames.member.1", "reputationOptions") .when().post("/") @@ -219,7 +208,7 @@ class SesConfigurationSetTrackingOptionsV1IntegrationTest { @Test @Order(14) void reputationMetrics_unknownConfigSet_returns400() { - query("UpdateConfigurationSetReputationMetricsEnabled") + SesV1Requests.query("UpdateConfigurationSetReputationMetricsEnabled") .formParam("ConfigurationSetName", "v1-cs-ghost") .formParam("Enabled", "true") .when().post("/") diff --git a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV1IntegrationTest.java index 1a498444b7..871daed40f 100644 --- a/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesConfigurationSetV1IntegrationTest.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.SesV1Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -17,9 +18,6 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesConfigurationSetV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - @Test @Order(1) void createConfigurationSet() { 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 112357580a..4b520d28d6 100644 --- a/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesCustomVerificationEmailTemplateV1IntegrationTest.java @@ -19,20 +19,13 @@ import static org.hamcrest.Matchers.equalTo; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesCustomVerificationEmailTemplateV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/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 = "Provided custom verification email template name does not exist."; - private static RequestSpecification query(String action) { - return given().contentType("application/x-www-form-urlencoded").header("Authorization", AUTH) - .formParam("Action", action); - } - private static RequestSpecification create(String name, String subject) { - return query("CreateCustomVerificationEmailTemplate") + return SesV1Requests.query("CreateCustomVerificationEmailTemplate") .formParam("TemplateName", name) .formParam("FromEmailAddress", FROM) .formParam("TemplateSubject", subject) @@ -44,7 +37,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { @Test @Order(0) void setup_verifyFromIdentity() { - query("VerifyEmailIdentity").formParam("EmailAddress", FROM).when().post("/").then().statusCode(200); + SesV1Requests.query("VerifyEmailIdentity").formParam("EmailAddress", FROM).when().post("/").then().statusCode(200); } @Test @@ -53,7 +46,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { // v1 returns CustomVerificationEmailTemplateDoesNotExist / 400 (verified against AWS), so the // v1 SDK's typed exception fires, not the v2 NotFoundException / 404. The message is a // fixed sentence that does not name the template, unlike the v2 one. - query("GetCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-ghost") + SesV1Requests.query("GetCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-ghost") .when().post("/").then().statusCode(400) .body(containsString("CustomVerificationEmailTemplateDoesNotExist")) .body(containsString("" + MISSING_MESSAGE + "")); @@ -62,7 +55,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { @Test @Order(12) void update_missing_returnsTheSameFixedSentenceOnV1() { - query("UpdateCustomVerificationEmailTemplate") + SesV1Requests.query("UpdateCustomVerificationEmailTemplate") .formParam("TemplateName", "cvet-v1-ghost").formParam("FromEmailAddress", FROM) .formParam("TemplateSubject", "Verify your email") .formParam("TemplateContent", "verify") @@ -77,7 +70,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { @Order(13) void delete_missing_succeedsOnV1() { // Probed: v1 answers 200 for a name the account does not hold, where v2 answers 404. - query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-ghost") + SesV1Requests.query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-ghost") .when().post("/").then().statusCode(200) .body(containsString("DeleteCustomVerificationEmailTemplateResponse")); } @@ -87,7 +80,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { void create_unverifiedFromAddress_returnsFromEmailAddressNotVerifiedOnV1() { // An unverified FromEmailAddress is FromEmailAddressNotVerified / 400 on v1 (verified against // AWS), not the v2 NotFoundException / 404. - query("CreateCustomVerificationEmailTemplate") + SesV1Requests.query("CreateCustomVerificationEmailTemplate") .formParam("TemplateName", "cvet-v1-unverified-from") .formParam("FromEmailAddress", "cvet-v1-not-verified@floci.test") .formParam("TemplateSubject", "Verify your email") @@ -108,7 +101,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { @Test @Order(2) void get() { - query("GetCustomVerificationEmailTemplate").formParam("TemplateName", NAME) + SesV1Requests.query("GetCustomVerificationEmailTemplate").formParam("TemplateName", NAME) .when().post("/").then().statusCode(200) .body(containsString("" + NAME + "")) .body(containsString("" + FROM + "")) @@ -118,7 +111,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { @Test @Order(3) void list() { - query("ListCustomVerificationEmailTemplates") + SesV1Requests.query("ListCustomVerificationEmailTemplates") .when().post("/").then().statusCode(200) .body(containsString("" + NAME + "")); } @@ -129,7 +122,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { // create dup fails with the v1-native code (verified against AWS), not the v2 AlreadyExistsException create(NAME, "Updated via v1").when().post("/").then().statusCode(400) .body(containsString("CustomVerificationEmailTemplateAlreadyExists")); - query("UpdateCustomVerificationEmailTemplate") + SesV1Requests.query("UpdateCustomVerificationEmailTemplate") .formParam("TemplateName", NAME).formParam("FromEmailAddress", FROM) .formParam("TemplateSubject", "Updated via v1") .formParam("TemplateContent", "verify") @@ -137,7 +130,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { .formParam("FailureRedirectionURL", "https://example.com/fail") .when().post("/").then().statusCode(200); - query("GetCustomVerificationEmailTemplate").formParam("TemplateName", NAME) + SesV1Requests.query("GetCustomVerificationEmailTemplate").formParam("TemplateName", NAME) .when().post("/").then().statusCode(200) .body(containsString("Updated via v1")); } @@ -145,7 +138,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { @Test @Order(5) void delete() { - query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", NAME) + SesV1Requests.query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", NAME) .when().post("/").then().statusCode(200) .body(containsString("DeleteCustomVerificationEmailTemplateResponse")); } @@ -155,7 +148,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { void create_missingRequiredField_returnsInvalidParameterValueOnV1() { // A required-field failure must surface the v1-native InvalidParameterValue code in the // Query XML (not the v2-style BadRequestException), consistent with requireParam. - query("CreateCustomVerificationEmailTemplate") + SesV1Requests.query("CreateCustomVerificationEmailTemplate") .formParam("TemplateName", "cvet-v1-missing") .formParam("FromEmailAddress", FROM) // TemplateSubject omitted @@ -172,7 +165,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { void update_missingTemplateName_returnsInvalidParameterValueOnV1() { // TemplateName is validated before the existence check, so omitting it yields the required-field // InvalidParameterValue rather than a NotFoundException for a null-named template. - query("UpdateCustomVerificationEmailTemplate") + SesV1Requests.query("UpdateCustomVerificationEmailTemplate") // TemplateName omitted .formParam("FromEmailAddress", FROM) .formParam("TemplateSubject", "Updated via v1") @@ -199,7 +192,7 @@ class SesCustomVerificationEmailTemplateV1IntegrationTest { @Test @Order(9) void cleanup_deleteSharedTemplate() { - query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-shared") + SesV1Requests.query("DeleteCustomVerificationEmailTemplate").formParam("TemplateName", "cvet-v1-shared") .when().post("/").then().statusCode(200); } } 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 ade04b31f2..098271580f 100644 --- a/src/test/java/io/floci/aws/services/ses/SesDkimSigningActionsIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesDkimSigningActionsIntegrationTest.java @@ -35,12 +35,9 @@ import static org.junit.jupiter.api.Assertions.assertNotEquals; @QuarkusTest class SesDkimSigningActionsIntegrationTest { - private static final String V1_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - private RequestSpecification v1(String action) { return given().contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH).formParam("Action", action); + .header("Authorization", SesV1Requests.AUTH).formParam("Action", action); } @Test diff --git a/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV1IntegrationTest.java index 184f994ebf..dc4cc0a683 100644 --- a/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesIdentityAttributesV1IntegrationTest.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.SesV1Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -14,9 +15,6 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesIdentityAttributesV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - @Test @Order(1) void verifyDomainIdentity_setsUpDomain() { 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 b238f8e8cb..01ac16d667 100644 --- a/src/test/java/io/floci/aws/services/ses/SesIdentityCertificateV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesIdentityCertificateV2IntegrationTest.java @@ -163,7 +163,7 @@ class SesIdentityCertificateV2IntegrationTest { private static Response v1Delete(String action, String member, String identity) { return given().contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", action) .formParam(member, identity) .when().post("/"); diff --git a/src/test/java/io/floci/aws/services/ses/SesIdentityPolicyV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesIdentityPolicyV1IntegrationTest.java index ffec06f3f6..0cd1f15680 100644 --- a/src/test/java/io/floci/aws/services/ses/SesIdentityPolicyV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesIdentityPolicyV1IntegrationTest.java @@ -1,7 +1,6 @@ package io.floci.aws.services.ses; import io.quarkus.test.junit.QuarkusTest; -import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -21,33 +20,26 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesIdentityPolicyV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String IDENTITY = "policy-v1.floci.test"; private static final String DOC_A = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"AAA\"}]}"; private static final String DOC_B = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"BBB\"}]}"; - private static RequestSpecification query(String action) { - return given().contentType("application/x-www-form-urlencoded").header("Authorization", AUTH) - .formParam("Action", action); - } - @Test @Order(0) void setup_createIdentity() { - query("VerifyDomainIdentity").formParam("Domain", IDENTITY).when().post("/").then().statusCode(200); + SesV1Requests.query("VerifyDomainIdentity").formParam("Domain", IDENTITY).when().post("/").then().statusCode(200); } @Test @Order(1) void putIdentityPolicy_thenUpsert() { - query("PutIdentityPolicy").formParam("Identity", IDENTITY) + SesV1Requests.query("PutIdentityPolicy").formParam("Identity", IDENTITY) .formParam("PolicyName", "pA").formParam("Policy", DOC_A) .when().post("/").then().statusCode(200) .body(containsString("PutIdentityPolicyResponse")); // Same name again with a different document -> upsert, no error. - query("PutIdentityPolicy").formParam("Identity", IDENTITY) + SesV1Requests.query("PutIdentityPolicy").formParam("Identity", IDENTITY) .formParam("PolicyName", "pA").formParam("Policy", DOC_B) .when().post("/").then().statusCode(200); } @@ -55,7 +47,7 @@ class SesIdentityPolicyV1IntegrationTest { @Test @Order(2) void getIdentityPolicies_returnsUpdatedDoc() { - query("GetIdentityPolicies").formParam("Identity", IDENTITY) + SesV1Requests.query("GetIdentityPolicies").formParam("Identity", IDENTITY) .formParam("PolicyNames.member.1", "pA") .when().post("/").then().statusCode(200) .body(containsString("pA")) @@ -66,7 +58,7 @@ class SesIdentityPolicyV1IntegrationTest { @Test @Order(3) void getIdentityPolicies_missingNameOmitted() { - query("GetIdentityPolicies").formParam("Identity", IDENTITY) + SesV1Requests.query("GetIdentityPolicies").formParam("Identity", IDENTITY) .formParam("PolicyNames.member.1", "pA") .formParam("PolicyNames.member.2", "nope") .when().post("/").then().statusCode(200) @@ -77,7 +69,7 @@ class SesIdentityPolicyV1IntegrationTest { @Test @Order(4) void listIdentityPolicies() { - query("ListIdentityPolicies").formParam("Identity", IDENTITY) + SesV1Requests.query("ListIdentityPolicies").formParam("Identity", IDENTITY) .when().post("/").then().statusCode(200) .body(containsString("pA")); } @@ -85,10 +77,10 @@ class SesIdentityPolicyV1IntegrationTest { @Test @Order(5) void deleteIdentityPolicy_isIdempotent() { - query("DeleteIdentityPolicy").formParam("Identity", IDENTITY).formParam("PolicyName", "pA") + SesV1Requests.query("DeleteIdentityPolicy").formParam("Identity", IDENTITY).formParam("PolicyName", "pA") .when().post("/").then().statusCode(200); // Deleting a missing policy again succeeds (no error) on v1. - query("DeleteIdentityPolicy").formParam("Identity", IDENTITY).formParam("PolicyName", "pA") + SesV1Requests.query("DeleteIdentityPolicy").formParam("Identity", IDENTITY).formParam("PolicyName", "pA") .when().post("/").then().statusCode(200) .body(containsString("DeleteIdentityPolicyResponse")); } @@ -96,10 +88,10 @@ class SesIdentityPolicyV1IntegrationTest { @Test @Order(6) void listAndGetOnMissingIdentity_returnEmpty() { - query("ListIdentityPolicies").formParam("Identity", "never-verified.floci.test") + SesV1Requests.query("ListIdentityPolicies").formParam("Identity", "never-verified.floci.test") .when().post("/").then().statusCode(200) .body(containsString("InvalidParameterValue")) .body(containsString("Policy names must only include")); - query("PutIdentityPolicy").formParam("Identity", IDENTITY) + SesV1Requests.query("PutIdentityPolicy").formParam("Identity", IDENTITY) .formParam("PolicyName", "a".repeat(65)).formParam("Policy", DOC_A) .when().post("/").then().statusCode(400) .body(containsString("ValidationError")) @@ -124,7 +116,7 @@ class SesIdentityPolicyV1IntegrationTest { @Test @Order(7) void v1Policy_isVisibleViaV2() { - query("PutIdentityPolicy").formParam("Identity", IDENTITY) + SesV1Requests.query("PutIdentityPolicy").formParam("Identity", IDENTITY) .formParam("PolicyName", "shared").formParam("Policy", DOC_A) .when().post("/").then().statusCode(200); diff --git a/src/test/java/io/floci/aws/services/ses/SesInspectionEndpointIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesInspectionEndpointIntegrationTest.java index 4fea30240a..b3de26c84e 100644 --- a/src/test/java/io/floci/aws/services/ses/SesInspectionEndpointIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesInspectionEndpointIntegrationTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test; import java.util.ArrayList; import java.util.List; +import static io.floci.aws.services.ses.SesV1Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.empty; @@ -23,8 +24,6 @@ import static org.hamcrest.Matchers.hasSize; @QuarkusTest class SesInspectionEndpointIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String SENDER = "inspection-a@floci.test"; private static final String OTHER_SENDER = "inspection-b@floci.test"; diff --git a/src/test/java/io/floci/aws/services/ses/SesIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesIntegrationTest.java index 0e8114431b..616ed911e1 100644 --- a/src/test/java/io/floci/aws/services/ses/SesIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesIntegrationTest.java @@ -9,6 +9,8 @@ import org.junit.jupiter.api.TestMethodOrder; import java.nio.charset.StandardCharsets; import java.util.Base64; +import static io.floci.aws.services.ses.SesV1Requests.AUTH; +import static io.floci.aws.services.ses.SesV1Requests.authFor; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.*; @@ -23,18 +25,10 @@ class SesIntegrationTest { // identity under example.com, so the later sends use a sender of their own. private static final String INSPECTION_SENDER = "inspection-sender@floci.test"; - private static String authorization(String service) { - return authorization(service, "us-east-1"); - } - - private static String authorization(String service, String region) { - return "AWS4-HMAC-SHA256 Credential=AKID/20260101/" + region + "/" + service + "/aws4_request"; - } - private static void verifySender(String address) { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", address) .when() @@ -48,7 +42,7 @@ class SesIntegrationTest { void verifyEmailIdentity() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", "sender@example.com") .when() @@ -64,7 +58,7 @@ class SesIntegrationTest { void verifyEmailIdentity_second() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", "recipient@example.com") .when() @@ -78,7 +72,7 @@ class SesIntegrationTest { void verifyDomainIdentity() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "VerifyDomainIdentity") .formParam("Domain", "example.com") .when() @@ -93,7 +87,7 @@ class SesIntegrationTest { void listIdentities() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "ListIdentities") .when() .post("/") @@ -109,7 +103,7 @@ class SesIntegrationTest { void listIdentities_filteredByType() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "ListIdentities") .formParam("IdentityType", "Domain") .when() @@ -125,7 +119,7 @@ class SesIntegrationTest { void getIdentityVerificationAttributes() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "GetIdentityVerificationAttributes") .formParam("Identities.member.1", "sender@example.com") .when() @@ -141,7 +135,7 @@ class SesIntegrationTest { void getIdentityVerificationAttributes_unknownIdentity() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "GetIdentityVerificationAttributes") .formParam("Identities.member.1", "unknown@example.com") .when() @@ -156,7 +150,7 @@ class SesIntegrationTest { void getIdentityVerificationAttributes_domainStartsPending() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "GetIdentityVerificationAttributes") .formParam("Identities.member.1", "example.com") .when() @@ -172,7 +166,7 @@ class SesIntegrationTest { void listVerifiedEmailAddresses() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "ListVerifiedEmailAddresses") .when() .post("/") @@ -187,7 +181,7 @@ class SesIntegrationTest { void sendEmail() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendEmail") .formParam("Source", "sender@example.com") .formParam("Destination.ToAddresses.member.1", "recipient@example.com") @@ -205,7 +199,7 @@ class SesIntegrationTest { void sendEmail_withHtmlBody() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendEmail") .formParam("Source", "sender@example.com") .formParam("Destination.ToAddresses.member.1", "recipient@example.com") @@ -223,7 +217,7 @@ class SesIntegrationTest { void sendRawEmail() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", "sender@example.com") .formParam("Destinations.member.1", "recipient@example.com") @@ -244,7 +238,7 @@ class SesIntegrationTest { verifySender(INSPECTION_SENDER); given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendRawEmail") .formParam("Destinations.member.1", "recipient@example.com") .formParam("RawMessage.Data", @@ -264,7 +258,7 @@ class SesIntegrationTest { // Verified against real AWS: v1 returns InvalidParameterValue "Missing required header 'From'." (400). given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendRawEmail") .formParam("Destinations.member.1", "recipient@example.com") .formParam("RawMessage.Data", "Subject: hello\r\n\r\nbody\r\n") @@ -282,7 +276,7 @@ class SesIntegrationTest { void getSendQuota() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "GetSendQuota") .when() .post("/") @@ -298,7 +292,7 @@ class SesIntegrationTest { void getSendStatistics() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "GetSendStatistics") .when() .post("/") @@ -313,7 +307,7 @@ class SesIntegrationTest { void getAccountSendingEnabled() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "GetAccountSendingEnabled") .when() .post("/") @@ -327,7 +321,7 @@ class SesIntegrationTest { void getAccountSendingEnabled_acceptsTheSesCredentialScope() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("ses")) + .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request") .formParam("Action", "GetAccountSendingEnabled") .when() .post("/") @@ -341,7 +335,7 @@ class SesIntegrationTest { void getIdentityDkimAttributes() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "GetIdentityDkimAttributes") .formParam("Identities.member.1", "example.com") .when() @@ -371,7 +365,7 @@ class SesIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SetIdentityNotificationTopic") .formParam("Identity", "sender@example.com") .formParam("NotificationType", "Bounce") @@ -388,7 +382,7 @@ class SesIntegrationTest { void getIdentityNotificationAttributes() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "GetIdentityNotificationAttributes") .formParam("Identities.member.1", "sender@example.com") .when() @@ -404,7 +398,7 @@ class SesIntegrationTest { void deleteVerifiedEmailAddress() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "DeleteVerifiedEmailAddress") .formParam("EmailAddress", "recipient@example.com") .when() @@ -415,7 +409,7 @@ class SesIntegrationTest { // Verify it's gone given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "ListVerifiedEmailAddresses") .when() .post("/") @@ -429,7 +423,7 @@ class SesIntegrationTest { void deleteIdentity() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "DeleteIdentity") .formParam("Identity", "sender@example.com") .when() @@ -441,7 +435,7 @@ class SesIntegrationTest { // Verify it's gone given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "ListIdentities") .when() .post("/") @@ -458,7 +452,7 @@ class SesIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendEmail") .formParam("Source", INSPECTION_SENDER) .formParam("Destination.ToAddresses.member.1", "recipient@example.com") @@ -488,7 +482,7 @@ class SesIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendEmail") .formParam("Source", INSPECTION_SENDER) .formParam("Destination.ToAddresses.member.1", "recipient@example.com") @@ -524,7 +518,7 @@ class SesIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", INSPECTION_SENDER) .formParam("Destinations.member.1", "recipient@example.com") @@ -547,7 +541,7 @@ class SesIntegrationTest { void deleteDomainIdentity() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "DeleteIdentity") .formParam("Identity", "example.com") .when() @@ -558,7 +552,7 @@ class SesIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "ListIdentities") .when() .post("/") @@ -572,7 +566,7 @@ class SesIntegrationTest { void verifyEmailIdentity_rejectsLeadingTrailingWhitespace() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", " sender@example.com ") .when() @@ -588,7 +582,7 @@ class SesIntegrationTest { void verifyDomainIdentity_rejectsLeadingTrailingWhitespace() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "VerifyDomainIdentity") .formParam("Domain", " example.com ") .when() @@ -604,7 +598,7 @@ class SesIntegrationTest { void unsupportedAction_returns400() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request") + .header("Authorization", AUTH) .formParam("Action", "UnknownSesAction") .when() .post("/") @@ -619,7 +613,7 @@ class SesIntegrationTest { // Missing Enabled parameter defaults to false (probed against real AWS 2026-09-05) given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "UpdateAccountSendingEnabled") .when() .post("/") @@ -628,7 +622,7 @@ class SesIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "GetAccountSendingEnabled") .when() .post("/") @@ -640,7 +634,7 @@ class SesIntegrationTest { // unlike the absent case (probed against real AWS 2026-09-05) given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "UpdateAccountSendingEnabled") .formParam("Enabled", "") .when() @@ -653,7 +647,7 @@ class SesIntegrationTest { // restore default state for downstream tests given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "UpdateAccountSendingEnabled") .formParam("Enabled", "true") .when() @@ -668,7 +662,7 @@ class SesIntegrationTest { // Disable sending in us-west-2 only; also exercises the response envelope shape given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email", "us-west-2")) + .header("Authorization", authFor("us-west-2")) .formParam("Action", "UpdateAccountSendingEnabled") .formParam("Enabled", "false") .when() @@ -680,7 +674,7 @@ class SesIntegrationTest { // us-west-2 reflects the disable given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email", "us-west-2")) + .header("Authorization", authFor("us-west-2")) .formParam("Action", "GetAccountSendingEnabled") .when() .post("/") @@ -691,7 +685,7 @@ class SesIntegrationTest { // us-east-1 is unaffected given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "GetAccountSendingEnabled") .when() .post("/") @@ -702,7 +696,7 @@ class SesIntegrationTest { // re-enable us-west-2 and confirm the toggle round-tripped given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email", "us-west-2")) + .header("Authorization", authFor("us-west-2")) .formParam("Action", "UpdateAccountSendingEnabled") .formParam("Enabled", "true") .when() @@ -712,7 +706,7 @@ class SesIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email", "us-west-2")) + .header("Authorization", authFor("us-west-2")) .formParam("Action", "GetAccountSendingEnabled") .when() .post("/") @@ -727,7 +721,7 @@ class SesIntegrationTest { // Probed against real AWS 2026-09-05: non-xsd boolean values are MalformedInput given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization("email")) + .header("Authorization", AUTH) .formParam("Action", "UpdateAccountSendingEnabled") .formParam("Enabled", "yes") .when() diff --git a/src/test/java/io/floci/aws/services/ses/SesReceiptFilterV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesReceiptFilterV1IntegrationTest.java index bc11620f85..43d05c4a62 100644 --- a/src/test/java/io/floci/aws/services/ses/SesReceiptFilterV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesReceiptFilterV1IntegrationTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import static io.restassured.RestAssured.given; +import static io.floci.aws.services.ses.SesV1Requests.query; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -23,19 +23,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesReceiptFilterV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-west-2/email/aws4_request"; - - private static RequestSpecification req(String action) { - return given() - .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) - .formParam("Action", action); - } + private static final String AUTH = SesV1Requests.authFor("us-west-2"); private static RequestSpecification create( String name, String policy, String cidr) { - return req("CreateReceiptFilter") + return query(AUTH, "CreateReceiptFilter") .formParam("Filter.Name", name) .formParam("Filter.IpFilter.Policy", policy) .formParam("Filter.IpFilter.Cidr", cidr); @@ -50,7 +42,7 @@ class SesReceiptFilterV1IntegrationTest { create("floci-filter-allow", "Allow", "192.0.2.10") .when().post("/").then().statusCode(200); - String body = req("ListReceiptFilters") + String body = query(AUTH, "ListReceiptFilters") .when().post("/").then().statusCode(200) .body(containsString("floci-filter-block")) .body(containsString("Block")) @@ -73,7 +65,7 @@ class SesReceiptFilterV1IntegrationTest { @Order(3) void bareCreate_returnsSingleFilterViolation() { // Probed: with no Filter member at all, the whole structure is the one violation. - req("CreateReceiptFilter") + query(AUTH, "CreateReceiptFilter") .when().post("/").then().statusCode(400) .body(containsString("ValidationError")) .body(containsString("1 validation error detected")) @@ -99,7 +91,7 @@ class SesReceiptFilterV1IntegrationTest { .body(containsString("InvalidParameterValue")) .body(containsString("Invalid CIDR block: not-a-cidr")); - req("CreateReceiptFilter").formParam("Filter.Name", "floci-filter-x") + query(AUTH, "CreateReceiptFilter").formParam("Filter.Name", "floci-filter-x") .when().post("/").then().statusCode(400) .body(containsString("'filter.ipFilter'")) .body(containsString("Member must not be null")); @@ -108,21 +100,21 @@ class SesReceiptFilterV1IntegrationTest { @Test @Order(4) void deleteFilter_isIdempotent_andRequiresName() { - req("DeleteReceiptFilter").formParam("FilterName", "floci-filter-allow") + query(AUTH, "DeleteReceiptFilter").formParam("FilterName", "floci-filter-allow") .when().post("/").then().statusCode(200); - req("DeleteReceiptFilter").formParam("FilterName", "floci-filter-allow") + query(AUTH, "DeleteReceiptFilter").formParam("FilterName", "floci-filter-allow") .when().post("/").then().statusCode(200); - req("ListReceiptFilters") + query(AUTH, "ListReceiptFilters") .when().post("/").then().statusCode(200) .body(not(containsString("floci-filter-allow"))); - req("DeleteReceiptFilter") + query(AUTH, "DeleteReceiptFilter") .when().post("/").then().statusCode(400) .body(containsString("ValidationError")) .body(containsString("'filterName'")); - req("DeleteReceiptFilter").formParam("FilterName", "floci-filter-block") + query(AUTH, "DeleteReceiptFilter").formParam("FilterName", "floci-filter-block") .when().post("/").then().statusCode(200); } } diff --git a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetPagingIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetPagingIntegrationTest.java index e93825d6b2..e15146030e 100644 --- a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetPagingIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetPagingIntegrationTest.java @@ -2,7 +2,6 @@ package io.floci.aws.services.ses; import io.quarkus.test.junit.QuarkusTest; import io.restassured.path.xml.XmlPath; -import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; @@ -11,7 +10,7 @@ import org.junit.jupiter.api.TestMethodOrder; import java.util.ArrayList; import java.util.List; -import static io.restassured.RestAssured.given; +import static io.floci.aws.services.ses.SesV1Requests.query; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; @@ -28,15 +27,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesReceiptRuleSetPagingIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/il-central-1/email/aws4_request"; + private static final String AUTH = SesV1Requests.authFor("il-central-1"); private static final String ROOT = "ListReceiptRuleSetsResponse.ListReceiptRuleSetsResult."; @Test @Order(1) void createAHundredAndOneRuleSets() { for (int i = 0; i < 101; i++) { - req("CreateReceiptRuleSet").formParam("RuleSetName", "page-%03d".formatted(i)) + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", "page-%03d".formatted(i)) .when().post("/").then().statusCode(200); } } @@ -44,14 +42,14 @@ class SesReceiptRuleSetPagingIntegrationTest { @Test @Order(2) void servesAHundredThenTheRestOldestFirstAndOmitsTheTokenOnTheLastPage() { - XmlPath first = req("ListReceiptRuleSets").when().post("/").then().statusCode(200) + XmlPath first = query(AUTH, "ListReceiptRuleSets").when().post("/").then().statusCode(200) .extract().xmlPath(); List names = new ArrayList<>(first.getList(ROOT + "RuleSets.member.Name")); assertThat(names, hasSize(100)); String token = first.getString(ROOT + "NextToken"); assertThat(token, not(emptyOrNullString())); - XmlPath rest = req("ListReceiptRuleSets").formParam("NextToken", token) + XmlPath rest = query(AUTH, "ListReceiptRuleSets").formParam("NextToken", token) .when().post("/").then().statusCode(200) .body(not(containsString(""))) .extract().xmlPath(); @@ -64,9 +62,4 @@ class SesReceiptRuleSetPagingIntegrationTest { } assertEquals(created, names); } - - private static RequestSpecification req(String action) { - return given().contentType("application/x-www-form-urlencoded").header("Authorization", AUTH) - .formParam("Action", action); - } } diff --git a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetReorderCloneV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetReorderCloneV1IntegrationTest.java index 9d64803d81..4270ead64b 100644 --- a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetReorderCloneV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetReorderCloneV1IntegrationTest.java @@ -1,13 +1,12 @@ package io.floci.aws.services.ses; import io.quarkus.test.junit.QuarkusTest; -import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import static io.restassured.RestAssured.given; +import static io.floci.aws.services.ses.SesV1Requests.query; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -21,36 +20,28 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesReceiptRuleSetReorderCloneV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-west-2/email/aws4_request"; + private static final String AUTH = SesV1Requests.authFor("us-west-2"); private static final String RS = "floci-v1-reorder"; private static final String CLONE = "floci-v1-reorder-copy"; - private static RequestSpecification req(String action) { - return given() - .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) - .formParam("Action", action); - } - private static String describeRuleNames(String ruleSetName) { - return req("DescribeReceiptRuleSet").formParam("RuleSetName", ruleSetName) + return query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", ruleSetName) .when().post("/").then().statusCode(200).extract().asString(); } @Test @Order(1) void reorder_appliesPermutation_andAnswersEmptyResult() { - req("CreateReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200); for (String name : new String[] {"r3", "r2", "r1"}) { // Without After each create lands at the front, so the set reads r1, r2, r3. - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", name) .when().post("/").then().statusCode(200); } - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r2") .formParam("RuleNames.member.2", "r3") .formParam("RuleNames.member.3", "r1") @@ -65,13 +56,13 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { @Test @Order(2) void reorder_errorPrecedence_onTheWire() { - req("ReorderReceiptRuleSet").formParam("RuleSetName", "floci-v1-ghost") + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", "floci-v1-ghost") .formParam("RuleNames.member.1", "r1") .when().post("/").then().statusCode(400) .body(containsString("RuleSetDoesNotExist")) .body(containsString("Rule set does not exist: floci-v1-ghost")); - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r1") .formParam("RuleNames.member.2", "r1") .when().post("/").then().statusCode(400) @@ -79,13 +70,13 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { .body(containsString("Multiple positions found for rule: r1")); // Missing set rules (listed in set order) win over the unknown name. - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r3") .formParam("RuleNames.member.2", "rX") .when().post("/").then().statusCode(400) .body(containsString("Positions for rules not found: r2, r1")); - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r1") .formParam("RuleNames.member.2", "r2") .formParam("RuleNames.member.3", "r3") @@ -94,7 +85,7 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { .body(containsString("RuleDoesNotExist")) .body(containsString("Rule does not exist: rX")); - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "bad name!") .when().post("/").then().statusCode(400) .body(containsString("ValidationError")) @@ -106,10 +97,10 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { @Test @Order(3) void clone_deepCopies_andActiveStaysBehind() { - req("SetActiveReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "SetActiveReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200); - req("CloneReceiptRuleSet").formParam("RuleSetName", CLONE) + query(AUTH, "CloneReceiptRuleSet").formParam("RuleSetName", CLONE) .formParam("OriginalRuleSetName", RS) .when().post("/").then().statusCode(200) .body(containsString("CloneReceiptRuleSetResponse")); @@ -118,25 +109,25 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { assertTrue(body.contains("" + CLONE + "")); assertTrue(body.indexOf("r2") < body.indexOf("r3")); - req("DescribeActiveReceiptRuleSet") + query(AUTH, "DescribeActiveReceiptRuleSet") .when().post("/").then().statusCode(200) .body(containsString("" + RS + "")); // Clear the active flag so the shared-state teardown delete succeeds. - req("SetActiveReceiptRuleSet") + query(AUTH, "SetActiveReceiptRuleSet") .when().post("/").then().statusCode(200); } @Test @Order(4) void clone_targetConflictAndMissingSource_errors() { - req("CloneReceiptRuleSet").formParam("RuleSetName", CLONE) + query(AUTH, "CloneReceiptRuleSet").formParam("RuleSetName", CLONE) .formParam("OriginalRuleSetName", "floci-v1-ghost") .when().post("/").then().statusCode(400) .body(containsString("AlreadyExists")) .body(containsString("Rule set already exists: " + CLONE)); - req("CloneReceiptRuleSet").formParam("RuleSetName", "floci-v1-fresh") + query(AUTH, "CloneReceiptRuleSet").formParam("RuleSetName", "floci-v1-fresh") .formParam("OriginalRuleSetName", "floci-v1-ghost") .when().post("/").then().statusCode(400) .body(containsString("RuleSetDoesNotExist")) @@ -148,7 +139,7 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { void reorder_ruleNamesIndexGrammar_matchesProbedWire() { // A gap of up to 10 is padded with empty members, which then fail the ruleNames // Smithy constraint; nothing is truncated. - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r1") .formParam("RuleNames.member.3", "r3") .when().post("/").then().statusCode(400) @@ -156,7 +147,7 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { .body(containsString("Value at 'ruleNames' failed to satisfy constraint")); // A larger gap is its own MalformedInput; the skip counts from the previous index. - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r1") .formParam("RuleNames.member.2", "r2") .formParam("RuleNames.member.3", "r3") @@ -166,36 +157,36 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { .body(containsString("Excessively sparse input would skip 11 list elements")); // The skip count is comma-grouped like AWS renders it. - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r1") .formParam("RuleNames.member.1500", "rX") .when().post("/").then().statusCode(400) .body(containsString("Excessively sparse input would skip 1,499 list elements")); - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.0", "r1") .when().post("/").then().statusCode(400) .body(containsString("MalformedInput")) .body(containsString("0 is not a valid index")); - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.01", "r1") .when().post("/").then().statusCode(400) .body(containsString("Value found where not expected")); - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.x", "r1") .when().post("/").then().statusCode(400) .body(containsString("Start of list found where not expected")); - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.999999999", "r1") .when().post("/").then().statusCode(400) .body(containsString("Index 999999999 is illegal")); // A repeated index keeps its first value: the list reads r1, r1, r3 and trips the // duplicate-name check, proving the second value never displaced the first. - req("ReorderReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "ReorderReceiptRuleSet").formParam("RuleSetName", RS) .formParam("RuleNames.member.1", "r1", "r2") .formParam("RuleNames.member.2", "r1") .formParam("RuleNames.member.3", "r3") @@ -207,7 +198,7 @@ class SesReceiptRuleSetReorderCloneV1IntegrationTest { @Order(6) void cleanup_deletesBothSets() { for (String name : new String[] {RS, CLONE}) { - req("DeleteReceiptRuleSet").formParam("RuleSetName", name) + query(AUTH, "DeleteReceiptRuleSet").formParam("RuleSetName", name) .when().post("/").then().statusCode(200); } } diff --git a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetV1IntegrationTest.java index 9eb9430249..f3827d7e03 100644 --- a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleSetV1IntegrationTest.java @@ -1,13 +1,12 @@ package io.floci.aws.services.ses; import io.quarkus.test.junit.QuarkusTest; -import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import static io.restassured.RestAssured.given; +import static io.floci.aws.services.ses.SesV1Requests.query; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.not; @@ -21,21 +20,13 @@ import static org.hamcrest.Matchers.not; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesReceiptRuleSetV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-west-2/email/aws4_request"; + private static final String AUTH = SesV1Requests.authFor("us-west-2"); private static final String RS = "floci-v1-rule-set"; - private static RequestSpecification req(String action) { - return given() - .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) - .formParam("Action", action); - } - @Test @Order(1) void createReceiptRuleSet() { - req("CreateReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200) .body(containsString("CreateReceiptRuleSetResponse")); } @@ -43,7 +34,7 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(2) void createDuplicate_returnsAlreadyExists() { - req("CreateReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(400) .body(containsString("AlreadyExists")) .body(containsString("Rule set already exists: " + RS)); @@ -52,7 +43,7 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(3) void describeReceiptRuleSet_returnsMetadataWithEmptyRules() { - req("DescribeReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200) .body(containsString("")) .body(containsString("" + RS + "")) @@ -63,7 +54,7 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(4) void listReceiptRuleSets_containsTheRuleSet() { - req("ListReceiptRuleSets") + query(AUTH, "ListReceiptRuleSets") .when().post("/").then().statusCode(200) .body(containsString("")) .body(containsString("" + RS + "")); @@ -72,10 +63,10 @@ class SesReceiptRuleSetV1IntegrationTest { // Unordered on purpose: it holds whether or not the rule set above still exists. @Test void listReceiptRuleSets_treatsAnEmptyTokenAsAbsentAndRefusesAnyOther() { - req("ListReceiptRuleSets").formParam("NextToken", "") + query(AUTH, "ListReceiptRuleSets").formParam("NextToken", "") .when().post("/").then().statusCode(200) .body(containsString("ListReceiptRuleSetsResponse")); - req("ListReceiptRuleSets").formParam("NextToken", "garbage") + query(AUTH, "ListReceiptRuleSets").formParam("NextToken", "garbage") .when().post("/").then().statusCode(400) .body(containsString("InvalidParameterValue")) .body(containsString("Invalid page token: garbage")); @@ -84,7 +75,7 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(5) void describeNonExistent_returnsRuleSetDoesNotExist() { - req("DescribeReceiptRuleSet").formParam("RuleSetName", "floci-v1-nope") + query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", "floci-v1-nope") .when().post("/").then().statusCode(400) .body(containsString("RuleSetDoesNotExist")) .body(containsString("Rule set does not exist: floci-v1-nope")); @@ -93,21 +84,21 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(6) void setActive_thenDescribeActive_returnsIt() { - req("SetActiveReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "SetActiveReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200); - req("DescribeActiveReceiptRuleSet") + query(AUTH, "DescribeActiveReceiptRuleSet") .when().post("/").then().statusCode(200) .body(containsString("")) .body(containsString("" + RS + "")); // While active, deleting the rule set is rejected (verified against AWS) and it is preserved. - req("DeleteReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DeleteReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(400) .body(containsString("CannotDelete")) .body(containsString("Cannot delete active rule set: " + RS)); - req("DescribeReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200) .body(containsString("" + RS + "")); } @@ -115,7 +106,7 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(7) void setActiveNonExistent_returnsRuleSetDoesNotExist() { - req("SetActiveReceiptRuleSet").formParam("RuleSetName", "floci-v1-nope") + query(AUTH, "SetActiveReceiptRuleSet").formParam("RuleSetName", "floci-v1-nope") .when().post("/").then().statusCode(400) .body(containsString("RuleSetDoesNotExist")); } @@ -123,11 +114,11 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(8) void setActiveWithoutName_clearsActive() { - req("SetActiveReceiptRuleSet") + query(AUTH, "SetActiveReceiptRuleSet") .when().post("/").then().statusCode(200); // With no active rule set, AWS returns an empty result (no Metadata / Name). - req("DescribeActiveReceiptRuleSet") + query(AUTH, "DescribeActiveReceiptRuleSet") .when().post("/").then().statusCode(200) .body(containsString("DescribeActiveReceiptRuleSetResponse")) .body(not(containsString(""))); @@ -136,19 +127,19 @@ class SesReceiptRuleSetV1IntegrationTest { @Test @Order(9) void deleteReceiptRuleSet_thenIdempotentDelete() { - req("DeleteReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DeleteReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200) .body(containsString("DeleteReceiptRuleSetResponse")); // AWS delete is idempotent: deleting again (now absent) still succeeds. - req("DeleteReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DeleteReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200); } @Test @Order(10) void describeAfterDelete_returnsRuleSetDoesNotExist() { - req("DescribeReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(400) .body(containsString("RuleSetDoesNotExist")); } @@ -157,7 +148,7 @@ class SesReceiptRuleSetV1IntegrationTest { @Order(11) void createRuleSet_charOutsideAllowedSet_returnsValidationError() { // A character outside ^[a-zA-Z0-9_.-]+$ is a Smithy ValidationError (verified against AWS). - req("CreateReceiptRuleSet").formParam("RuleSetName", "floci bad name") + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", "floci bad name") .when().post("/").then().statusCode(400) .body(containsString("ValidationError")) .body(containsString("ruleSetName")); @@ -167,7 +158,7 @@ class SesReceiptRuleSetV1IntegrationTest { @Order(12) void createRuleSet_badFormat_returnsNotValidRuleSetName() { // Valid characters, but a name must start/end with an alphanumeric (verified against AWS). - req("CreateReceiptRuleSet").formParam("RuleSetName", "-floci-bad") + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", "-floci-bad") .when().post("/").then().statusCode(400) .body(containsString("InvalidParameterValue")) .body(containsString("Not a valid ruleSetName: -floci-bad")); @@ -177,9 +168,9 @@ class SesReceiptRuleSetV1IntegrationTest { @Order(13) void createRuleSet_dottedName_isAccepted() { // A dot is inside the allowed character set (verified against AWS). - req("CreateReceiptRuleSet").formParam("RuleSetName", "floci.v1.dotted") + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", "floci.v1.dotted") .when().post("/").then().statusCode(200); - req("DeleteReceiptRuleSet").formParam("RuleSetName", "floci.v1.dotted") + query(AUTH, "DeleteReceiptRuleSet").formParam("RuleSetName", "floci.v1.dotted") .when().post("/").then().statusCode(200); } } diff --git a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleV1IntegrationTest.java index 894d116a4f..8f01704d30 100644 --- a/src/test/java/io/floci/aws/services/ses/SesReceiptRuleV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesReceiptRuleV1IntegrationTest.java @@ -1,12 +1,12 @@ package io.floci.aws.services.ses; import io.quarkus.test.junit.QuarkusTest; -import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.MethodOrderer; 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.SesV1Requests.query; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -22,27 +22,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesReceiptRuleV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-west-2/email/aws4_request"; + private static final String AUTH = SesV1Requests.authFor("us-west-2"); private static final String RS = "floci-v1-rules"; private static final String BOUNCE_SENDER = "receipt-bounce@floci-rules.example.com"; private static String snsTopicArn; - private static RequestSpecification req(String action) { - return given() - .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) - .formParam("Action", action); - } - @Test @Order(1) void createRuleSet_andRichRule() { - req("CreateReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "rich") .formParam("Rule.Enabled", "true") .formParam("Rule.TlsPolicy", "Require") @@ -59,7 +51,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(2) void describeRule_roundTripsSortedRecipientsAndOrderedActions() { - String body = req("DescribeReceiptRule").formParam("RuleSetName", RS) + String body = query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "rich") .when().post("/").then().statusCode(200) .body(containsString("rich")) @@ -78,16 +70,16 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(3) void createWithoutAfter_insertsAtFront_andAfterInsertsBehind() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "first") .when().post("/").then().statusCode(200); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "middle") .formParam("After", "first") .when().post("/").then().statusCode(200); - String body = req("DescribeReceiptRuleSet").formParam("RuleSetName", RS) + String body = query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200).extract().asString(); assertTrue(body.indexOf("first") < body.indexOf("middle")); assertTrue(body.indexOf("middle") < body.indexOf("rich")); @@ -96,11 +88,11 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(4) void minimalRule_getsAwsDefaults() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "minimal") .when().post("/").then().statusCode(200); - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "minimal") .when().post("/").then().statusCode(200) .body(containsString("false")) @@ -112,7 +104,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(5) void duplicateCreate_returnsAlreadyExists() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "rich") .when().post("/").then().statusCode(400) .body(containsString("AlreadyExists")) @@ -122,12 +114,12 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(6) void missingSetAndMissingRule_errors() { - req("CreateReceiptRule").formParam("RuleSetName", "floci-v1-nope") + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", "floci-v1-nope") .formParam("Rule.Name", "r") .when().post("/").then().statusCode(400) .body(containsString("RuleSetDoesNotExist")); - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "ghost") .when().post("/").then().statusCode(400) .body(containsString("RuleDoesNotExist")) @@ -137,21 +129,21 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(7) void invalidRuleShape_returnsSmithyValidationError() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "bad!name") .when().post("/").then().statusCode(400) .body(containsString("ValidationError")) .body(containsString("'rule.name'")) .body(containsString("^[a-zA-Z0-9_.-]+$")); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "badtls") .formParam("Rule.TlsPolicy", "Bogus") .when().post("/").then().statusCode(400) .body(containsString("'rule.tlsPolicy'")) .body(containsString("[Optional, Require]")); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "badlambda") .formParam("Rule.Actions.member.1.LambdaAction.InvocationType", "Event") .when().post("/").then().statusCode(400) @@ -162,14 +154,14 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(8) void actionTargets_areValidatedAgainstLocalServices() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "s3neg") .formParam("Rule.Actions.member.1.S3Action.BucketName", "floci-no-such-bucket") .when().post("/").then().statusCode(400) .body(containsString("InvalidS3Configuration")) .body(containsString("No such bucket: floci-no-such-bucket")); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "snsneg") .formParam("Rule.Actions.member.1.SNSAction.TopicArn", "arn:aws:sns:us-west-2:000000000000:floci-no-such-topic") @@ -178,7 +170,7 @@ class SesReceiptRuleV1IntegrationTest { .body(containsString("Could not publish to SNS topic: " + "arn:aws:sns:us-west-2:000000000000:floci-no-such-topic")); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "lamneg") .formParam("Rule.Actions.member.1.LambdaAction.FunctionArn", "arn:aws:lambda:us-west-2:000000000000:function:floci-no-such-fn") @@ -187,7 +179,7 @@ class SesReceiptRuleV1IntegrationTest { .body(containsString("Could not invoke Lambda function: " + "arn:aws:lambda:us-west-2:000000000000:function:floci-no-such-fn")); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "bounceneg") .formParam("Rule.Actions.member.1.BounceAction.SmtpReplyCode", "550") .formParam("Rule.Actions.member.1.BounceAction.Message", "unavailable") @@ -200,7 +192,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(9) void verifiedBounceSender_andLocalSnsTopic_areAccepted() { - req("VerifyEmailIdentity").formParam("EmailAddress", BOUNCE_SENDER) + query(AUTH, "VerifyEmailIdentity").formParam("EmailAddress", BOUNCE_SENDER) .when().post("/").then().statusCode(200); snsTopicArn = given() @@ -212,7 +204,7 @@ class SesReceiptRuleV1IntegrationTest { .when().post("/").then().statusCode(200) .extract().xmlPath().getString("CreateTopicResponse.CreateTopicResult.TopicArn"); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "actions-ok") .formParam("Rule.Actions.member.1.BounceAction.SmtpReplyCode", "550") .formParam("Rule.Actions.member.1.BounceAction.Message", "unavailable") @@ -221,7 +213,7 @@ class SesReceiptRuleV1IntegrationTest { .when().post("/").then().statusCode(200); // The stored SNS action picks up AWS's UTF-8 encoding default (probed). - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "actions-ok") .when().post("/").then().statusCode(200) .body(containsString("" + snsTopicArn + "")) @@ -235,7 +227,7 @@ class SesReceiptRuleV1IntegrationTest { // An action serialized as an empty structure contributes no keys, so a list can arrive // starting at member.2. AWS pads the gap into an empty action slot and rejects it // because the slot carries no action type (probed). - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "sparse") .formParam("Rule.Actions.member.2.StopAction.Scope", "RuleSet") .when().post("/").then().statusCode(400) @@ -247,19 +239,19 @@ class SesReceiptRuleV1IntegrationTest { @Order(9) void leadingZeroIndex_isParsedUnderItsOriginalSpelling() { // Probed: member.01 on its own is a valid slot 1 and the action must not be dropped. - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "leadzero") .formParam("Rule.Actions.member.01.StopAction.Scope", "RuleSet") .when().post("/").then().statusCode(200); - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "leadzero") .when().post("/").then().statusCode(200) .body(containsString("RuleSet")); // Probed: mixed spellings order by (length, lex), so 01 followed by 2 puts the // one-digit token first and slot 1 is an empty pad. - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "leadzero2") .formParam("Rule.Actions.member.01.AddHeaderAction.HeaderName", "X-A") .formParam("Rule.Actions.member.01.AddHeaderAction.HeaderValue", "v") @@ -272,7 +264,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(9) void stopAction_mustBeLast() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "stopfirst") .formParam("Rule.Actions.member.1.StopAction.Scope", "RuleSet") .formParam("Rule.Actions.member.2.AddHeaderAction.HeaderName", "X-A") @@ -285,12 +277,12 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(9) void nonAsciiDigitIndex_isIgnoredLikeAnUnmodeledParameter() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "fwidx") .formParam("Rule.Actions.member.1.StopAction.Scope", "RuleSet") .when().post("/").then().statusCode(200); - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "fwidx") .when().post("/").then().statusCode(200) .body(containsString("")); @@ -299,7 +291,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(9) void actionIndexZero_isRejectedAsMalformedInput() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "zeroidx") .formParam("Rule.Actions.member.0.StopAction.Scope", "RuleSet") .when().post("/").then().statusCode(400) @@ -310,7 +302,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(9) void malformedWireBoolean_isRejectedAsMalformedInput() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "badbool") .formParam("Rule.Enabled", "bogus") .when().post("/").then().statusCode(400) @@ -318,17 +310,17 @@ class SesReceiptRuleV1IntegrationTest { .body(containsString("boolean must follow xsd1.1 definition")); // Uppercase TRUE is rejected too (probed); the numeric forms are accepted. - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "badbool") .formParam("Rule.ScanEnabled", "TRUE") .when().post("/").then().statusCode(400) .body(containsString("MalformedInput")); - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "numbool") .formParam("Rule.Enabled", "1") .when().post("/").then().statusCode(200); - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "numbool") .when().post("/").then().statusCode(200) .body(containsString("true")); @@ -337,7 +329,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(9) void twoActionTypesInOneMember_areRejected() { - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "multitype") .formParam("Rule.Actions.member.1.StopAction.Scope", "RuleSet") .formParam("Rule.Actions.member.1.AddHeaderAction.HeaderName", "X-A") @@ -352,7 +344,7 @@ class SesReceiptRuleV1IntegrationTest { void overflowingActionIndex_isRejectedNotAServerError() { // A digit run that overflows int implies an index far beyond any contiguous list; the // gap padding turns it into the probed empty-slot rejection instead of a 500. - req("CreateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "CreateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "hugeidx") .formParam("Rule.Actions.member.999999999999999999999.StopAction.Scope", "RuleSet") .when().post("/").then().statusCode(400) @@ -362,7 +354,7 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(9) void topLevelRuleNameParam_getsSmithyValidation() { - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "bad name") .when().post("/").then().statusCode(400) .body(containsString("ValidationError")) @@ -372,18 +364,18 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(10) void updateRule_isFullReplace_andKeepsPosition() { - req("UpdateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "UpdateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "rich") .when().post("/").then().statusCode(200); - req("DescribeReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "rich") .when().post("/").then().statusCode(200) .body(containsString("false")) .body(containsString("Optional")) .body(containsString("")); - req("UpdateReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "UpdateReceiptRule").formParam("RuleSetName", RS) .formParam("Rule.Name", "ghost") .when().post("/").then().statusCode(400) .body(containsString("RuleDoesNotExist")); @@ -392,11 +384,11 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(11) void setRulePosition_movesToFrontWithoutAfter() { - req("SetReceiptRulePosition").formParam("RuleSetName", RS) + query(AUTH, "SetReceiptRulePosition").formParam("RuleSetName", RS) .formParam("RuleName", "rich") .when().post("/").then().statusCode(200); - String body = req("DescribeReceiptRuleSet").formParam("RuleSetName", RS) + String body = query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200).extract().asString(); assertTrue(body.indexOf("rich") < body.indexOf("first")); } @@ -404,14 +396,14 @@ class SesReceiptRuleV1IntegrationTest { @Test @Order(12) void deleteRule_isIdempotent_andRuleSetDeleteCascades() { - req("DeleteReceiptRule").formParam("RuleSetName", RS) + query(AUTH, "DeleteReceiptRule").formParam("RuleSetName", RS) .formParam("RuleName", "ghost") .when().post("/").then().statusCode(200); - req("DeleteReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DeleteReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(200); - req("DescribeReceiptRuleSet").formParam("RuleSetName", RS) + query(AUTH, "DescribeReceiptRuleSet").formParam("RuleSetName", RS) .when().post("/").then().statusCode(400) .body(containsString("RuleSetDoesNotExist")); } diff --git a/src/test/java/io/floci/aws/services/ses/SesSendAddressLengthIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendAddressLengthIntegrationTest.java index 9d6c3b8f66..ad75ba30fe 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendAddressLengthIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendAddressLengthIntegrationTest.java @@ -12,8 +12,6 @@ import static org.hamcrest.Matchers.equalTo; @QuarkusTest class SesSendAddressLengthIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String DOMAIN = "example.com"; private static final String TOO_LONG = "a".repeat(321 - DOMAIN.length() - 1) + "@" + DOMAIN; private static final String EXPECTED_MESSAGE = @@ -23,7 +21,7 @@ class SesSendAddressLengthIntegrationTest { void v1SendEmail_sourceOverLimit_returnsInvalidParameterValue() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendEmail") .formParam("Source", TOO_LONG) .formParam("Destination.ToAddresses.member.1", "success@simulator.amazonses.com") @@ -41,7 +39,7 @@ class SesSendAddressLengthIntegrationTest { void v2SendEmail_fromOverLimit_returnsBadRequestException() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "%s", @@ -61,7 +59,7 @@ class SesSendAddressLengthIntegrationTest { void v1SendRawEmail_destinationOverLimit_returnsInvalidParameterValue() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", "sender@example.com") .formParam("Destinations.member.1", TOO_LONG) @@ -79,7 +77,7 @@ class SesSendAddressLengthIntegrationTest { void v2SendEmail_feedbackForwardingOverLimit_returnsBadRequestException() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -103,7 +101,7 @@ class SesSendAddressLengthIntegrationTest { .getBytes(StandardCharsets.UTF_8)); given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "Destination": {"ToAddresses": ["success@simulator.amazonses.com"], "CcAddresses": ["%s"]}, @@ -122,7 +120,7 @@ class SesSendAddressLengthIntegrationTest { void v2SendBulkEmail_fromOverLimit_returnsInvalidEmailAddress() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "%s", @@ -144,7 +142,7 @@ class SesSendAddressLengthIntegrationTest { void v1SendBulkTemplatedEmail_sourceOverLimit_returnsInvalidEmailAddress() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", TOO_LONG) .formParam("Template", "address-length-missing") diff --git a/src/test/java/io/floci/aws/services/ses/SesSendAddressSyntaxIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendAddressSyntaxIntegrationTest.java index 75c4b56808..0e6b778e7c 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendAddressSyntaxIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendAddressSyntaxIntegrationTest.java @@ -17,8 +17,6 @@ import static org.hamcrest.Matchers.nullValue; @QuarkusTest class SesSendAddressSyntaxIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String TO = "success@simulator.amazonses.com"; // A sender of its own: an identity under example.com would outlive this class and reach the // other SES classes that share the application. @@ -27,7 +25,7 @@ class SesSendAddressSyntaxIntegrationTest { private static void verifySender() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", VERIFIED_SENDER) .when() @@ -40,7 +38,7 @@ class SesSendAddressSyntaxIntegrationTest { void v1SendEmail_sourceWithoutAt_returnsInvalidParameterValue() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendEmail") .formParam("Source", "sender.example.com") .formParam("Destination.ToAddresses.member.1", TO) @@ -58,7 +56,7 @@ class SesSendAddressSyntaxIntegrationTest { void v1SendRawEmail_nonAsciiDomainDestination_returnsInvalidParameterValue() { given() .contentType("application/x-www-form-urlencoded; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", "sender@example.com") .formParam("Destinations.member.1", "success@例え.jp") @@ -76,7 +74,7 @@ class SesSendAddressSyntaxIntegrationTest { void v2SendEmail_nonAsciiLocalRecipient_returnsBadRequestException() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -96,7 +94,7 @@ class SesSendAddressSyntaxIntegrationTest { void v2SendBulkEmail_fromWithEmptyDomain_returnsInvalidEmailAddress() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@", @@ -119,7 +117,7 @@ class SesSendAddressSyntaxIntegrationTest { verifySender(); given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "%2$s", @@ -150,7 +148,7 @@ class SesSendAddressSyntaxIntegrationTest { verifySender(); given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "CreateTemplate") .formParam("Template.TemplateName", "address-syntax-bulk") .formParam("Template.SubjectPart", "s") @@ -162,7 +160,7 @@ class SesSendAddressSyntaxIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", VERIFIED_SENDER) .formParam("Template", "address-syntax-bulk") @@ -182,7 +180,7 @@ class SesSendAddressSyntaxIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "DeleteTemplate") .formParam("TemplateName", "address-syntax-bulk") .when() @@ -195,7 +193,7 @@ class SesSendAddressSyntaxIntegrationTest { void v1SendBulkTemplatedEmail_malformedSourceIsReportedBeforeMissingTemplate() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", "Alice ") .formParam("Template", "address-syntax-missing") @@ -213,7 +211,7 @@ class SesSendAddressSyntaxIntegrationTest { void v2SendBulkEmail_malformedFromIsReportedBeforeMissingTemplate() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender.example.com", @@ -233,7 +231,7 @@ class SesSendAddressSyntaxIntegrationTest { void v2SendEmail_newlineInQuotedLocalPart_returnsInvalidEmailAddress() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "\\"a\\nb\\"@example.com", @@ -253,7 +251,7 @@ class SesSendAddressSyntaxIntegrationTest { void v2SendBulkEmail_malformedFeedbackForwarding_rejectsTheRequest() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -276,7 +274,7 @@ class SesSendAddressSyntaxIntegrationTest { void v1SendBulkTemplatedEmail_malformedReturnPath_rejectsTheRequest() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", "sender@example.com") .formParam("ReturnPath", "bounce@") @@ -301,7 +299,7 @@ class SesSendAddressSyntaxIntegrationTest { void v2SendEmailRaw_malformedFromHeaderWithoutFromEmailAddress(String from, String message) { given() .contentType("application/json; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "Destination": {"ToAddresses": ["%s"]}, @@ -322,7 +320,7 @@ class SesSendAddressSyntaxIntegrationTest { verifySender(); given() .contentType("application/json; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "%s", @@ -344,7 +342,7 @@ class SesSendAddressSyntaxIntegrationTest { given() .contentType("application/json; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "%s", @@ -370,7 +368,7 @@ class SesSendAddressSyntaxIntegrationTest { given() .contentType("application/json; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" {"Content": {"Raw": {"Data": "%s"}}} """.formatted(raw)) @@ -392,7 +390,7 @@ class SesSendAddressSyntaxIntegrationTest { void v1SendRawEmail_malformedFromHeader_keepsJavaMailMessages(String from, String message) { given() .contentType("application/x-www-form-urlencoded; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendRawEmail") .formParam("Destinations.member.1", TO) .formParam("RawMessage.Data", rawMessage(from)) @@ -423,7 +421,7 @@ class SesSendAddressSyntaxIntegrationTest { void v1SendRawEmail_fromHeaderWithoutAtAndSource_isAMissingUserName(String from, String message) { given() .contentType("application/x-www-form-urlencoded; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", "sender@example.com") .formParam("Destinations.member.1", TO) @@ -440,7 +438,7 @@ class SesSendAddressSyntaxIntegrationTest { void v1SendRawEmail_otherFromHeaderViolationIsReportedBeforeMissingUserName() { given() .contentType("application/x-www-form-urlencoded; charset=UTF-8") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", "sender@example.com") .formParam("Destinations.member.1", TO) diff --git a/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV1IntegrationTest.java index eaca9d431a..79dd48830e 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendCustomVerificationEmailV1IntegrationTest.java @@ -1,13 +1,12 @@ package io.floci.aws.services.ses; import io.quarkus.test.junit.QuarkusTest; -import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; -import static io.restassured.RestAssured.given; +import static io.floci.aws.services.ses.SesV1Requests.query; import static org.hamcrest.Matchers.containsString; /** @@ -20,17 +19,10 @@ import static org.hamcrest.Matchers.containsString; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesSendCustomVerificationEmailV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String FROM = "scve-v1-sender@floci.test"; private static final String RECIPIENT = "scve-v1-recipient@floci.test"; private static final String NAME = "scve-v1-template"; - private static RequestSpecification query(String action) { - return given().contentType("application/x-www-form-urlencoded").header("Authorization", AUTH) - .formParam("Action", action); - } - @Test @Order(0) void setup_verifyFromAndCreateTemplate() { diff --git a/src/test/java/io/floci/aws/services/ses/SesSendNullAddressIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendNullAddressIntegrationTest.java index d37a0270d8..1d20ed2104 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendNullAddressIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendNullAddressIntegrationTest.java @@ -17,8 +17,6 @@ import static org.hamcrest.Matchers.nullValue; @QuarkusTest class SesSendNullAddressIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; // A verified sender of its own: an identity under example.com would outlive this class and // reach the other SES classes that share the application. private static final String SENDER = "null-address-sender@floci.test"; @@ -33,7 +31,7 @@ class SesSendNullAddressIntegrationTest { private static ValidatableResponse post(String path, String body) { return given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(body) .when() .post(path) @@ -57,7 +55,7 @@ class SesSendNullAddressIntegrationTest { void verifySender() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", SENDER) .when() diff --git a/src/test/java/io/floci/aws/services/ses/SesSendRawNoDestinationIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendRawNoDestinationIntegrationTest.java index 62ec629124..736d500f3a 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendRawNoDestinationIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendRawNoDestinationIntegrationTest.java @@ -16,8 +16,6 @@ import static org.hamcrest.Matchers.notNullValue; @QuarkusTest class SesSendRawNoDestinationIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String TO = "success@simulator.amazonses.com"; private static final String VERIFIED_SENDER = "no-destination-sender@floci.test"; @@ -35,7 +33,7 @@ class SesSendRawNoDestinationIntegrationTest { void v2SendEmail_rawWithoutDestination_takesRecipientsFromHeaders() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", VERIFIED_SENDER) .when() @@ -45,7 +43,7 @@ class SesSendRawNoDestinationIntegrationTest { String messageId = given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "%s", @@ -67,7 +65,7 @@ class SesSendRawNoDestinationIntegrationTest { void v2SendEmail_rawWithoutAnyRecipient_returnsMissingToHeader() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -86,7 +84,7 @@ class SesSendRawNoDestinationIntegrationTest { void v2SendEmail_rawWithoutAnyRecipient_reportsUnknownConfigurationSetFirst() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "ConfigurationSetName": "no-destination-missing-cs", @@ -105,7 +103,7 @@ class SesSendRawNoDestinationIntegrationTest { void v2SendEmail_rawWithEmptyDestination_returnsMissingToHeader() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -125,7 +123,7 @@ class SesSendRawNoDestinationIntegrationTest { void v2SendEmail_rawWithNonArrayDestinationMember_returnsSerializationException() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -144,7 +142,7 @@ class SesSendRawNoDestinationIntegrationTest { void v2SendEmail_rawWithoutDestination_checksHeaderRecipientSyntax() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -163,7 +161,7 @@ class SesSendRawNoDestinationIntegrationTest { void v2SendEmail_rawWithoutDestination_checksCcHeaderRecipientSyntax() { given() .contentType("application/json") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .body(""" { "FromEmailAddress": "sender@example.com", @@ -182,7 +180,7 @@ class SesSendRawNoDestinationIntegrationTest { void v1SendRawEmail_withoutAnyRecipient_returnsMissingToHeader() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", "sender@example.com") .formParam("RawMessage.Data", rawData("From: sender@example.com\r\n")) diff --git a/src/test/java/io/floci/aws/services/ses/SesSendTemplateLookupOrderIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesSendTemplateLookupOrderIntegrationTest.java index 5da5648eff..fa4b6e9745 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendTemplateLookupOrderIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendTemplateLookupOrderIntegrationTest.java @@ -26,8 +26,6 @@ import static org.hamcrest.Matchers.nullValue; @QuarkusTest class SesSendTemplateLookupOrderIntegrationTest { - private static final String AUTH_V1 = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String UNVERIFIED = "sender@unverified-template-order.floci.test"; private static final String VERIFIED = "sender@template-order.floci.test"; private static final String GHOST_CONFIG_SET = "template-order-ghost-config-set"; @@ -44,7 +42,7 @@ class SesSendTemplateLookupOrderIntegrationTest { void verifySender() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH_V1) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", VERIFIED) .when() @@ -66,7 +64,7 @@ class SesSendTemplateLookupOrderIntegrationTest { private static ValidatableResponse templated(String source, String... params) { return v1(given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH_V1) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendTemplatedEmail") .formParam("Source", source) .formParam("Destination.ToAddresses.member.1", TO) @@ -77,7 +75,7 @@ class SesSendTemplateLookupOrderIntegrationTest { private static ValidatableResponse bulkTemplated(String source, int destinations, String... params) { RequestSpecification spec = given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH_V1) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendBulkTemplatedEmail") .formParam("Source", source) .formParam("Template", V1_GHOST_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 438883a281..8bb11c50fb 100644 --- a/src/test/java/io/floci/aws/services/ses/SesSendVerifiedSenderIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesSendVerifiedSenderIntegrationTest.java @@ -29,8 +29,6 @@ import static org.hamcrest.Matchers.notNullValue; @QuarkusTest class SesSendVerifiedSenderIntegrationTest { - private static final String AUTH_V1 = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/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 = @@ -51,19 +49,8 @@ class SesSendVerifiedSenderIntegrationTest { private static final String DELEGATE_AUTH_V2 = "AWS4-HMAC-SHA256 Credential=" + DELEGATE_ACCOUNT + "/20260101/us-east-1/ses/aws4_request"; - private static RequestSpecification query(String action) { - return query(AUTH_V1, action); - } - - private static RequestSpecification query(String authorization, String action) { - return given() - .contentType("application/x-www-form-urlencoded") - .header("Authorization", authorization) - .formParam("Action", action); - } - private static RequestSpecification sendEmail(String authorization, String source) { - return query(authorization, "SendEmail") + return SesV1Requests.query(authorization, "SendEmail") .formParam("Source", source) .formParam("Destination.ToAddresses.member.1", "to@example.com") .formParam("Message.Subject.Data", "s") @@ -71,13 +58,13 @@ class SesSendVerifiedSenderIntegrationTest { } private static RequestSpecification sendRawEmail(String authorization, String rawMessage) { - return query(authorization, "SendRawEmail") + return SesV1Requests.query(authorization, "SendRawEmail") .formParam("Destinations.member.1", "to@example.com") .formParam("RawMessage.Data", rawMessage); } private static RequestSpecification sendTemplatedEmail(String authorization, String source) { - return query(authorization, "SendTemplatedEmail") + return SesV1Requests.query(authorization, "SendTemplatedEmail") .formParam("Source", source) .formParam("Destination.ToAddresses.member.1", "to@example.com") .formParam("Template", TEMPLATE) @@ -95,19 +82,19 @@ class SesSendVerifiedSenderIntegrationTest { } private static void verifyEmailIdentity(String address) { - query("VerifyEmailIdentity").formParam("EmailAddress", address) + SesV1Requests.query("VerifyEmailIdentity").formParam("EmailAddress", address) .when().post("/").then().statusCode(200); } private static void verifyOwnerAddress() { - query("AWS4-HMAC-SHA256 Credential=" + OWNER_ACCOUNT + "/20260101/us-east-1/email/aws4_request", + SesV1Requests.query("AWS4-HMAC-SHA256 Credential=" + OWNER_ACCOUNT + "/20260101/us-east-1/email/aws4_request", "VerifyEmailIdentity") .formParam("EmailAddress", OWNER_ADDRESS) .when().post("/").then().statusCode(200); } private static void createTemplate(String authorization) { - query(authorization, "CreateTemplate") + SesV1Requests.query(authorization, "CreateTemplate") .formParam("Template.TemplateName", TEMPLATE) .formParam("Template.SubjectPart", "s") .formParam("Template.TextPart", "b") @@ -174,7 +161,7 @@ class SesSendVerifiedSenderIntegrationTest { @Test void v1SendEmail_unverifiedSource_returnsMessageRejected() { - assertMessageRejected(sendEmail(AUTH_V1, UNVERIFIED), UNVERIFIED); + assertMessageRejected(sendEmail(SesV1Requests.AUTH, UNVERIFIED), UNVERIFIED); assertNothingCapturedFrom(UNVERIFIED); } @@ -183,12 +170,12 @@ class SesSendVerifiedSenderIntegrationTest { void v1SendEmail_displayNameSourceWithVerifiedAddress_succeeds() { verifyEmailIdentity(VERIFIED); - assertSent(sendEmail(AUTH_V1, "Verified Sender <" + VERIFIED + ">"), "SendEmail"); + assertSent(sendEmail(SesV1Requests.AUTH, "Verified Sender <" + VERIFIED + ">"), "SendEmail"); } @Test void v1SendRawEmail_unverifiedSource_returnsMessageRejected() { - assertMessageRejected(sendRawEmail(AUTH_V1, rawMessage(UNVERIFIED)).formParam("Source", UNVERIFIED), + assertMessageRejected(sendRawEmail(SesV1Requests.AUTH, rawMessage(UNVERIFIED)).formParam("Source", UNVERIFIED), UNVERIFIED); assertNothingCapturedFrom(UNVERIFIED); @@ -196,14 +183,14 @@ class SesSendVerifiedSenderIntegrationTest { @Test void v1SendRawEmail_withoutSource_unverifiedMimeFrom_returnsMessageRejected() { - assertMessageRejected(sendRawEmail(AUTH_V1, rawMessage(UNVERIFIED)), UNVERIFIED); + assertMessageRejected(sendRawEmail(SesV1Requests.AUTH, rawMessage(UNVERIFIED)), UNVERIFIED); } @Test void v1SendTemplatedEmail_unverifiedSource_returnsMessageRejected() { - createTemplate(AUTH_V1); + createTemplate(SesV1Requests.AUTH); - assertMessageRejected(sendTemplatedEmail(AUTH_V1, UNVERIFIED), UNVERIFIED); + assertMessageRejected(sendTemplatedEmail(SesV1Requests.AUTH, UNVERIFIED), UNVERIFIED); } @Test @@ -256,7 +243,7 @@ class SesSendVerifiedSenderIntegrationTest { SesDomainIdentityTestHelper.createVerified(domain, SesV2Requests.AUTH); String lookalike = "anyone@not-" + domain; - assertMessageRejected(sendEmail(AUTH_V1, lookalike), lookalike); + assertMessageRejected(sendEmail(SesV1Requests.AUTH, lookalike), lookalike); } @Test @@ -265,7 +252,7 @@ class SesSendVerifiedSenderIntegrationTest { String second = "second@unverified-sender.floci.test"; verifyEmailIdentity(first); - assertMessageRejected(sendRawEmail(AUTH_V1, rawMessage(first + ", " + second)), second); + assertMessageRejected(sendRawEmail(SesV1Requests.AUTH, rawMessage(first + ", " + second)), second); assertNothingCapturedFrom(first); } @@ -277,7 +264,7 @@ class SesSendVerifiedSenderIntegrationTest { verifyEmailIdentity(first); verifyEmailIdentity(second); - assertSent(sendRawEmail(AUTH_V1, rawMessage(first + ", " + second)), "SendRawEmail"); + assertSent(sendRawEmail(SesV1Requests.AUTH, rawMessage(first + ", " + second)), "SendRawEmail"); } @Test @@ -285,10 +272,10 @@ class SesSendVerifiedSenderIntegrationTest { // A domain identity stays Pending until its DKIM records are published, and a pending // domain does not verify the addresses under it. String domain = "pending-domain.floci.test"; - query("VerifyDomainIdentity").formParam("Domain", domain) + SesV1Requests.query("VerifyDomainIdentity").formParam("Domain", domain) .when().post("/").then().statusCode(200); - assertMessageRejected(sendEmail(AUTH_V1, "anyone@" + domain), "anyone@" + domain); + assertMessageRejected(sendEmail(SesV1Requests.AUTH, "anyone@" + domain), "anyone@" + domain); } @Test @@ -297,7 +284,7 @@ class SesSendVerifiedSenderIntegrationTest { String returnPath = "bounces@unverified-sender.floci.test"; verifyEmailIdentity(source); - assertMessageRejected(sendEmail(AUTH_V1, source).formParam("ReturnPath", returnPath), returnPath); + assertMessageRejected(sendEmail(SesV1Requests.AUTH, source).formParam("ReturnPath", returnPath), returnPath); assertNothingCapturedFrom(source); } @@ -307,9 +294,9 @@ class SesSendVerifiedSenderIntegrationTest { String source = "rp-templated-" + VERIFIED; String returnPath = "templated-bounces@unverified-sender.floci.test"; verifyEmailIdentity(source); - createTemplate(AUTH_V1); + createTemplate(SesV1Requests.AUTH); - assertMessageRejected(sendTemplatedEmail(AUTH_V1, source).formParam("ReturnPath", returnPath), returnPath); + assertMessageRejected(sendTemplatedEmail(SesV1Requests.AUTH, source).formParam("ReturnPath", returnPath), returnPath); assertNothingCapturedFrom(source); } @@ -354,7 +341,7 @@ class SesSendVerifiedSenderIntegrationTest { String source = "raw-source-" + VERIFIED; verifyEmailIdentity(source); - assertMessageRejected(sendRawEmail(AUTH_V1, rawMessage(UNVERIFIED)).formParam("Source", source), UNVERIFIED); + assertMessageRejected(sendRawEmail(SesV1Requests.AUTH, rawMessage(UNVERIFIED)).formParam("Source", source), UNVERIFIED); assertNothingCapturedFrom(source); } @@ -380,7 +367,7 @@ class SesSendVerifiedSenderIntegrationTest { String sender = "assistant@unverified-sender.floci.test"; verifyEmailIdentity(from); - assertMessageRejected(sendRawEmail(AUTH_V1, rawMessage(from, "Sender: " + sender)), sender); + assertMessageRejected(sendRawEmail(SesV1Requests.AUTH, rawMessage(from, "Sender: " + sender)), sender); assertNothingCapturedFrom(from); } @@ -391,7 +378,7 @@ class SesSendVerifiedSenderIntegrationTest { String returnPath = "raw-bounces@unverified-sender.floci.test"; verifyEmailIdentity(from); - assertMessageRejected(sendRawEmail(AUTH_V1, rawMessage(from, "Return-Path: <" + returnPath + ">")), + assertMessageRejected(sendRawEmail(SesV1Requests.AUTH, rawMessage(from, "Return-Path: <" + returnPath + ">")), returnPath); assertNothingCapturedFrom(from); @@ -407,7 +394,7 @@ class SesSendVerifiedSenderIntegrationTest { verifyEmailIdentity(address); } - assertSent(sendRawEmail(AUTH_V1, rawMessage(from, "Sender: " + sender, "Return-Path: <" + returnPath + ">")) + assertSent(sendRawEmail(SesV1Requests.AUTH, rawMessage(from, "Sender: " + sender, "Return-Path: <" + returnPath + ">")) .formParam("Source", source), "SendRawEmail"); } @@ -415,7 +402,7 @@ class SesSendVerifiedSenderIntegrationTest { void v1SendEmail_twoUnverifiedAddresses_oneErrorNamesBoth() { String returnPath = "both-bounces@unverified-sender.floci.test"; - assertMessageRejected(sendEmail(AUTH_V1, UNVERIFIED).formParam("ReturnPath", returnPath), + assertMessageRejected(sendEmail(SesV1Requests.AUTH, UNVERIFIED).formParam("ReturnPath", returnPath), UNVERIFIED + ", " + returnPath); } @@ -551,7 +538,7 @@ class SesSendVerifiedSenderIntegrationTest { } private static RequestSpecification sendBulkTemplatedEmail(String authorization, String source) { - return query(authorization, "SendBulkTemplatedEmail") + return SesV1Requests.query(authorization, "SendBulkTemplatedEmail") .formParam("Source", source) .formParam("Template", TEMPLATE) .formParam("DefaultTemplateData", "{}") @@ -645,9 +632,9 @@ class SesSendVerifiedSenderIntegrationTest { @Test void v1SendBulkTemplatedEmail_unverifiedSource_returnsMessageRejected() { - createTemplate(AUTH_V1); + createTemplate(SesV1Requests.AUTH); - assertMessageRejected(sendBulkTemplatedEmail(AUTH_V1, UNVERIFIED), UNVERIFIED); + assertMessageRejected(sendBulkTemplatedEmail(SesV1Requests.AUTH, UNVERIFIED), UNVERIFIED); assertNothingCapturedFrom(UNVERIFIED); } 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 4b74a37927..b5ef63a026 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTemplateNameIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTemplateNameIntegrationTest.java @@ -20,8 +20,6 @@ import static org.hamcrest.Matchers.equalTo; @QuarkusTest class SesTemplateNameIntegrationTest { - private static final String V1_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/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."; @@ -47,7 +45,7 @@ class SesTemplateNameIntegrationTest { for (String action : new String[] {"CreateTemplate", "UpdateTemplate"}) { given() .contentType("application/x-www-form-urlencoded; charset=UTF-8") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", action) .formParam("Template.TemplateName", name) .formParam("Template.SubjectPart", "S") @@ -62,7 +60,7 @@ class SesTemplateNameIntegrationTest { for (String action : new String[] {"GetTemplate", "DeleteTemplate", "TestRenderTemplate"}) { given() .contentType("application/x-www-form-urlencoded; charset=UTF-8") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", action) .formParam("TemplateName", name) .formParam("TemplateData", "{}") @@ -135,7 +133,7 @@ class SesTemplateNameIntegrationTest { void theNameIsCheckedBeforeTheContent() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "CreateTemplate") .formParam("Template.TemplateName", "name probe") .formParam("Template.TextPart", "t") @@ -161,7 +159,7 @@ class SesTemplateNameIntegrationTest { void v1SpellsOutAControlCharacterOfTheName() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "GetTemplate") .formParam("TemplateName", "name\tprobe\u0001") .when() @@ -186,7 +184,7 @@ class SesTemplateNameIntegrationTest { String name = "Name_probe-0123456789" + "a".repeat(43); given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "CreateTemplate") .formParam("Template.TemplateName", name) .formParam("Template.SubjectPart", "S") @@ -206,7 +204,7 @@ class SesTemplateNameIntegrationTest { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "GetTemplate") .formParam("TemplateName", name) .when() 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 b172cb99a6..93d8bd4b1a 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTemplateRequiredPartsIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTemplateRequiredPartsIntegrationTest.java @@ -20,8 +20,6 @@ import static org.hamcrest.Matchers.nullValue; @QuarkusTest class SesTemplateRequiredPartsIntegrationTest { - private static final String V1_AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/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."; @@ -99,7 +97,7 @@ class SesTemplateRequiredPartsIntegrationTest { void v1Create_requiresASubject() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "CreateTemplate") .formParam("Template.TemplateName", "required-parts-v1") .formParam("Template.TextPart", "t") @@ -115,7 +113,7 @@ class SesTemplateRequiredPartsIntegrationTest { void v1Create_requiresAPart() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "CreateTemplate") .formParam("Template.TemplateName", "required-parts-v1") .formParam("Template.SubjectPart", "S") @@ -132,7 +130,7 @@ class SesTemplateRequiredPartsIntegrationTest { void v1Update_requiresAPartBeforeTheTemplateIsLookedUp() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", V1_AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "UpdateTemplate") .formParam("Template.TemplateName", "required-parts-ghost") .formParam("Template.SubjectPart", "S") diff --git a/src/test/java/io/floci/aws/services/ses/SesTemplateV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTemplateV1IntegrationTest.java index e322207642..043ed42925 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTemplateV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTemplateV1IntegrationTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.params.provider.MethodSource; import java.util.stream.Stream; +import static io.floci.aws.services.ses.SesV1Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -22,9 +23,6 @@ import static org.hamcrest.Matchers.equalTo; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesTemplateV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - @Test @Order(1) void createTemplate() { diff --git a/src/test/java/io/floci/aws/services/ses/SesTestRenderV1IntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesTestRenderV1IntegrationTest.java index 6590aa94cd..74b8f1e50c 100644 --- a/src/test/java/io/floci/aws/services/ses/SesTestRenderV1IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesTestRenderV1IntegrationTest.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.SesV1Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.containsString; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -14,9 +15,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class SesTestRenderV1IntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - @Test @Order(1) void createTemplate() { diff --git a/src/test/java/io/floci/aws/services/ses/SesV1AccountSendingPausedTest.java b/src/test/java/io/floci/aws/services/ses/SesV1AccountSendingPausedTest.java index 79d23b3dd1..0b8808cf19 100644 --- a/src/test/java/io/floci/aws/services/ses/SesV1AccountSendingPausedTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesV1AccountSendingPausedTest.java @@ -15,9 +15,6 @@ import static org.hamcrest.Matchers.containsString; @QuarkusTest class SesV1AccountSendingPausedTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; - @BeforeEach void disableSending() { given() @@ -44,7 +41,7 @@ class SesV1AccountSendingPausedTest { void sendEmail_paused_returnsAccountSendingPausedException() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendEmail") .formParam("Source", "sender@example.com") .formParam("Destination.ToAddresses.member.1", "recipient@example.com") @@ -61,7 +58,7 @@ class SesV1AccountSendingPausedTest { void sendRawEmail_paused_returnsAccountSendingPausedException() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendRawEmail") .formParam("Source", "sender@example.com") .formParam("Destinations.member.1", "recipient@example.com") @@ -77,7 +74,7 @@ class SesV1AccountSendingPausedTest { void sendTemplatedEmail_paused_returnsAccountSendingPausedException() { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", AUTH) + .header("Authorization", SesV1Requests.AUTH) .formParam("Action", "SendTemplatedEmail") .formParam("Source", "sender@example.com") .formParam("Destination.ToAddresses.member.1", "recipient@example.com") diff --git a/src/test/java/io/floci/aws/services/ses/SesV1Requests.java b/src/test/java/io/floci/aws/services/ses/SesV1Requests.java new file mode 100644 index 0000000000..33e1f151e2 --- /dev/null +++ b/src/test/java/io/floci/aws/services/ses/SesV1Requests.java @@ -0,0 +1,34 @@ +package io.floci.aws.services.ses; + +import io.restassured.specification.RequestSpecification; + +import static io.restassured.RestAssured.given; + +/** + * Builds SES v1 Query requests for the integration tests: a form-encoded body carrying the + * {@code Action} parameter, with an Authorization header scoped to {@code email} in a region. The + * overload without an authorization uses {@link #AUTH} (us-east-1); a test that keeps state in a + * region of its own passes {@link #authFor} of that region to every request. + */ +final class SesV1Requests { + + static final String AUTH = authFor("us-east-1"); + + private SesV1Requests() { + } + + static String authFor(String region) { + return "AWS4-HMAC-SHA256 Credential=AKID/20260101/" + region + "/email/aws4_request"; + } + + static RequestSpecification query(String action) { + return query(AUTH, action); + } + + static RequestSpecification query(String authorization, String action) { + return given() + .contentType("application/x-www-form-urlencoded") + .header("Authorization", authorization) + .formParam("Action", action); + } +} diff --git a/src/test/java/io/floci/aws/services/ses/SesV1TemplateArnIntegrationTest.java b/src/test/java/io/floci/aws/services/ses/SesV1TemplateArnIntegrationTest.java index 00fb8d2c67..67ca484ca9 100644 --- a/src/test/java/io/floci/aws/services/ses/SesV1TemplateArnIntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesV1TemplateArnIntegrationTest.java @@ -11,6 +11,7 @@ import org.junit.jupiter.params.provider.ValueSource; import java.util.stream.Stream; +import static io.floci.aws.services.ses.SesV1Requests.AUTH; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.equalTo; @@ -22,8 +23,6 @@ import static org.hamcrest.Matchers.equalTo; @QuarkusTest class SesV1TemplateArnIntegrationTest { - private static final String AUTH = - "AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/email/aws4_request"; private static final String UNVERIFIED = "sender@unverified-v1-template-arn.floci.test"; private static final String NAME = "v1-arn-ghost"; private static final String TEMPLATE_REQUIRED = 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 df41774a1b..e2a2f158dc 100644 --- a/src/test/java/io/floci/aws/services/ses/SesV2IntegrationTest.java +++ b/src/test/java/io/floci/aws/services/ses/SesV2IntegrationTest.java @@ -1233,8 +1233,7 @@ class SesV2IntegrationTest { for (String region : List.of("us-east-1", "ap-northeast-1")) { given() .contentType("application/x-www-form-urlencoded") - .header("Authorization", - "AWS4-HMAC-SHA256 Credential=AKID/20260101/" + region + "/email/aws4_request") + .header("Authorization", SesV1Requests.authFor(region)) .formParam("Action", "VerifyEmailIdentity") .formParam("EmailAddress", "multi@example.com") .when() diff --git a/src/test/java/io/floci/aws/services/ses/SesV2SerializationErrors.java b/src/test/java/io/floci/aws/services/ses/SesV2SerializationErrors.java index 5792942781..d6797f6bed 100644 --- a/src/test/java/io/floci/aws/services/ses/SesV2SerializationErrors.java +++ b/src/test/java/io/floci/aws/services/ses/SesV2SerializationErrors.java @@ -37,7 +37,7 @@ final class SesV2SerializationErrors { /** An Authorization header signed for {@code region}, for a test that needs its own region state. */ static String authFor(String region) { - return "AWS4-HMAC-SHA256 Credential=AKID/20260101/" + region + "/email/aws4_request"; + return SesV1Requests.authFor(region); } static void assertError(String method, String path, String body, String type, String message) {