mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(ses): build regional SES v2 test requests with SesV2Requests.v2(AUTH) (#9320)
The SES v2 integration tests that declare a regional AUTH now build their requests with a statically imported SesV2Requests.v2(AUTH) instead of spelling out given().contentType("application/json").header("Authorization", AUTH), 124 blocks across 16 classes. Each class keeps its own AUTH constant, and no request changes.
This commit is contained in:
1 parent
d57fceb434
commit
014256293c
16 files changed
+140
-129
No files matched your search
@@ -6,6 +6,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
@@ -40,7 +41,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
void putDetails_roundTripsThroughGetAccount() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"MailType":"TRANSACTIONAL","WebsiteURL":"https://example.com",
|
||||
"ContactLanguage":"EN","UseCaseDescription":"transactional mail",
|
||||
@@ -63,7 +64,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Order(2)
|
||||
void putDetails_missingBothRequired_reportsAggregatedError() {
|
||||
// AWS reports both null violations at once (mailType before websiteURL).
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
@@ -75,7 +76,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(3)
|
||||
void putDetails_missingWebsiteUrl_reportsSingleError() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value at 'websiteURL' failed to "
|
||||
@@ -85,7 +86,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(4)
|
||||
void putDetails_invalidMailTypeEnum_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"SPAM\",\"WebsiteURL\":\"https://example.com\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value at 'mailType' failed to "
|
||||
@@ -95,7 +96,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(5)
|
||||
void putDetails_invalidContactLanguageEnum_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"ContactLanguage\":\"FR\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
@@ -106,7 +107,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(6)
|
||||
void putDetails_blankWebsiteUrl_returnsLengthError() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value at 'websiteURL' failed to "
|
||||
@@ -116,7 +117,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(7)
|
||||
void putDetails_nonUrlWebsite_returnsFormatError() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"not a url\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("message", equalTo("Url contains invalid format"));
|
||||
@@ -127,7 +128,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
void putDetails_nonStringTypedMember_returnsBadRequest() {
|
||||
// A present-but-wrong-type typed member is rejected rather than coerced (asText would turn 123
|
||||
// into "123"), matching the identity/configuration-set string members.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":123,\"WebsiteURL\":\"https://example.com\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
@@ -136,7 +137,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(9)
|
||||
void putDetails_nonArrayAdditionalContacts_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"AdditionalContactEmailAddresses\":\"ops@example.com\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
@@ -146,7 +147,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(10)
|
||||
void putDetails_nonBooleanProductionAccess_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"ProductionAccessEnabled\":\"abc\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
@@ -158,7 +159,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Order(11)
|
||||
void putDetails_websiteUrlTooLong_returnsLengthError() {
|
||||
String longUrl = "https://example.com/" + "a".repeat(1001);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"" + longUrl + "\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value at 'websiteURL' failed to "
|
||||
@@ -169,7 +170,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Order(12)
|
||||
void putDetails_useCaseDescriptionTooLong_returnsLengthError() {
|
||||
String longDesc = "x".repeat(5001);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"UseCaseDescription\":\"" + longDesc + "\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
@@ -180,7 +181,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(13)
|
||||
void putDetails_tooManyContacts_returnsLengthError() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"AdditionalContactEmailAddresses\":[\"a1@example.com\",\"a2@example.com\","
|
||||
+ "\"a3@example.com\",\"a4@example.com\",\"a5@example.com\"]}")
|
||||
@@ -193,7 +194,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(14)
|
||||
void putDetails_emptyContactsList_returnsLengthError() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"AdditionalContactEmailAddresses\":[]}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
@@ -205,7 +206,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(15)
|
||||
void putDetails_contactElementTooShort_returnsElementConstraint() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"https://example.com\","
|
||||
+ "\"AdditionalContactEmailAddresses\":[\"a@b\"]}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
@@ -221,7 +222,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
void putDetails_multipleLengthViolations_areAggregated() {
|
||||
String longUrl = "https://example.com/" + "a".repeat(1001);
|
||||
String longDesc = "x".repeat(5001);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"MailType\":\"TRANSACTIONAL\",\"WebsiteURL\":\"" + longUrl + "\","
|
||||
+ "\"UseCaseDescription\":\"" + longDesc + "\"}")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
@@ -235,7 +236,7 @@ class SesAccountDetailsV2IntegrationTest {
|
||||
@Order(17)
|
||||
void putDetails_malformedJson_returnsSerializationException() {
|
||||
// AWS reports a malformed JSON body as a SerializationException, not BadRequestException.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{ not json")
|
||||
.when().post("/v2/email/account/details").then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
@@ -38,7 +39,7 @@ class SesAccountVdmV2IntegrationTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
void putVdm_enablesAndRoundTripsThroughGetAccount() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"VdmAttributes":{"VdmEnabled":"ENABLED",
|
||||
"DashboardAttributes":{"EngagementMetrics":"ENABLED"},
|
||||
@@ -56,7 +57,7 @@ class SesAccountVdmV2IntegrationTest {
|
||||
@Test
|
||||
@Order(2)
|
||||
void putVdm_invalidEnum_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"MAYBE\"}}")
|
||||
.when().put("/v2/email/account/vdm").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
@@ -65,7 +66,7 @@ class SesAccountVdmV2IntegrationTest {
|
||||
@Test
|
||||
@Order(3)
|
||||
void putVdm_missingVdmEnabled_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{}}")
|
||||
.when().put("/v2/email/account/vdm").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
@@ -74,7 +75,7 @@ class SesAccountVdmV2IntegrationTest {
|
||||
@Test
|
||||
@Order(4)
|
||||
void putVdm_emptyBody_returnsBadRequest() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.when().put("/v2/email/account/vdm").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
@@ -84,7 +85,7 @@ class SesAccountVdmV2IntegrationTest {
|
||||
void putVdm_enabledWithoutNested_defaultsNestedToDisabled() {
|
||||
// Enabling VDM without supplying the optional members: AWS surfaces both nested objects with
|
||||
// their DISABLED defaults once VdmEnabled is ENABLED.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"ENABLED\"}}")
|
||||
.when().put("/v2/email/account/vdm").then().statusCode(200);
|
||||
|
||||
@@ -99,7 +100,7 @@ class SesAccountVdmV2IntegrationTest {
|
||||
@Order(8)
|
||||
void putVdm_disabled_omitsNestedAttributes() {
|
||||
// Disabling VDM drops the nested objects again, and restores this region to DISABLED.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"DISABLED\"}}")
|
||||
.when().put("/v2/email/account/vdm").then().statusCode(200);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@@ -170,7 +171,7 @@ class SesBooleanCoercionV2IntegrationTest {
|
||||
}
|
||||
|
||||
private static ValidatableResponse send(String method, String path, String body) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH).body(body)
|
||||
return v2(AUTH).body(body)
|
||||
.when().request(method, path).then();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
@@ -126,7 +127,7 @@ class SesConfigurationSetPagingIntegrationTest {
|
||||
}
|
||||
|
||||
private static void create(String name) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"ConfigurationSetName\": \"" + name + "\"}")
|
||||
.when().post("/v2/email/configuration-sets").then().statusCode(200);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -31,7 +32,7 @@ class SesContactPagingIntegrationTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
void createAListAndContactsOutOfAddressOrder() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"ContactListName\":\"" + LIST + "\"}")
|
||||
.when().post("/v2/email/contact-lists").then().statusCode(200);
|
||||
for (String name : new String[] {"page-b", "page-c", "page-a"}) {
|
||||
@@ -122,13 +123,13 @@ class SesContactPagingIntegrationTest {
|
||||
}
|
||||
|
||||
private static void create(String name) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"" + name + "@example.com\"}")
|
||||
.when().post(CONTACTS).then().statusCode(200);
|
||||
}
|
||||
|
||||
private static ValidatableResponse list(String body) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH).body(body)
|
||||
return v2(AUTH).body(body)
|
||||
.when().post(CONTACTS + "/list").then();
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
@@ -37,7 +38,7 @@ class SesCustomVerificationEmailTemplatePagingIntegrationTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
void createTemplatesOutOfNameOrder() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailIdentity\": \"" + FROM + "\"}")
|
||||
.when().post("/v2/email/identities").then().statusCode(200);
|
||||
for (String name : new String[] {"page-b", "page-c", "page-a"}) {
|
||||
@@ -131,7 +132,7 @@ class SesCustomVerificationEmailTemplatePagingIntegrationTest {
|
||||
}
|
||||
|
||||
private static void create(String name) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"TemplateName": "%s",
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
@@ -31,7 +32,7 @@ class SesDedicatedIpPagingIntegrationTest {
|
||||
@Order(1)
|
||||
void createPoolsOutOfNameOrder() {
|
||||
for (String name : new String[] {"page-b", "page-c", "page-a"}) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"PoolName\": \"" + name + "\"}")
|
||||
.when().post(POOLS).then().statusCode(200);
|
||||
}
|
||||
|
||||
+7
-7
@@ -3,7 +3,7 @@ package io.floci.aws.services.ses;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ class SesEmailAddressInsightsV2IntegrationTest {
|
||||
|
||||
@Test
|
||||
void answersEveryVerdictWithoutVdm() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"admin@example.com\"}")
|
||||
.when().post(PATH).then().statusCode(200)
|
||||
.body("MailboxValidation.IsValid.ConfidenceVerdict", equalTo("LOW"))
|
||||
@@ -33,7 +33,7 @@ class SesEmailAddressInsightsV2IntegrationTest {
|
||||
|
||||
@Test
|
||||
void malformedAddressAnswersOkWithLowVerdicts() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"no-at-sign\"}")
|
||||
.when().post(PATH).then().statusCode(200)
|
||||
.body("MailboxValidation.IsValid.ConfidenceVerdict", equalTo("LOW"))
|
||||
@@ -42,7 +42,7 @@ class SesEmailAddressInsightsV2IntegrationTest {
|
||||
|
||||
@Test
|
||||
void pathWithoutTrailingSlashIsServed() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"alice@gmail.com\"}")
|
||||
.when().post("/v2/email/email-address-insights").then().statusCode(200)
|
||||
.body("MailboxValidation.IsValid.ConfidenceVerdict", equalTo("HIGH"));
|
||||
@@ -50,7 +50,7 @@ class SesEmailAddressInsightsV2IntegrationTest {
|
||||
|
||||
@Test
|
||||
void emptyAddressIsRejected() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"\"}")
|
||||
.when().post(PATH).then().statusCode(400)
|
||||
.header("x-amzn-ErrorType", equalTo("BadRequestException"))
|
||||
@@ -59,7 +59,7 @@ class SesEmailAddressInsightsV2IntegrationTest {
|
||||
|
||||
@Test
|
||||
void missingAddressIsRejected() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{}")
|
||||
.when().post(PATH).then().statusCode(400)
|
||||
.body("message", equalTo("Email address must not be null nor empty"));
|
||||
@@ -67,7 +67,7 @@ class SesEmailAddressInsightsV2IntegrationTest {
|
||||
|
||||
@Test
|
||||
void nonStringAddressIsASerializationError() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":1}")
|
||||
.when().post(PATH).then().statusCode(400)
|
||||
.header("x-amzn-ErrorType", equalTo("SerializationException"));
|
||||
|
||||
+3
-6
@@ -13,6 +13,7 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -27,18 +28,14 @@ class SesExportJobS3AuthEnforcementIntegrationTest {
|
||||
|
||||
@Test
|
||||
void completedExportUrlCanBeFetchedWhenS3AuthIsEnforced() {
|
||||
given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"ENABLED\"}}")
|
||||
.when()
|
||||
.put("/v2/email/account/vdm")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
String jobId = given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH)
|
||||
String jobId = v2(AUTH)
|
||||
.body("""
|
||||
{"ExportDataSource": {"MessageInsightsDataSource":
|
||||
{"StartDate": %d, "EndDate": %d}},
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -47,7 +48,7 @@ class SesExportJobV2IntegrationTest {
|
||||
}
|
||||
|
||||
private static Response create(String body) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH)
|
||||
return v2(AUTH)
|
||||
.body(body)
|
||||
.when().post("/v2/email/export-jobs");
|
||||
}
|
||||
@@ -100,10 +101,10 @@ class SesExportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
void enableVdmAndVerifyTheSender() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"ENABLED\"}}")
|
||||
.when().put("/v2/email/account/vdm").then().statusCode(200);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailIdentity\":\"" + SENDER + "\"}")
|
||||
.when().post("/v2/email/identities").then().statusCode(200);
|
||||
}
|
||||
@@ -201,7 +202,7 @@ class SesExportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(6)
|
||||
void exportJob_writesTheInsightsFileAndServesItBehindAPresignedUrl() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["reader@example.com"]},
|
||||
@@ -265,7 +266,7 @@ class SesExportJobV2IntegrationTest {
|
||||
String finished = create(insightsSource()).then().statusCode(200).extract().path("JobId");
|
||||
assertEquals("COMPLETED", awaitTerminal(finished));
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.when().put("/v2/email/export-jobs/" + finished + "/cancel").then().statusCode(400)
|
||||
.body("message", equalTo(
|
||||
"Cannot cancel an export job that has a <COMPLETED> status."));
|
||||
@@ -279,14 +280,14 @@ class SesExportJobV2IntegrationTest {
|
||||
.when().get("/v2/email/export-jobs/" + unknown).then().statusCode(404)
|
||||
.header("x-amzn-ErrorType", equalTo("NotFoundException"))
|
||||
.body("message", equalTo("Job ID: <" + unknown + "> not found"));
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.when().put("/v2/email/export-jobs/" + unknown + "/cancel").then().statusCode(404)
|
||||
.body("message", equalTo("Job ID: <" + unknown + "> not found"));
|
||||
|
||||
given().header("Authorization", AUTH)
|
||||
.when().get("/v2/email/export-jobs/no-such-job").then().statusCode(400)
|
||||
.body("message", equalTo("Invalid JobId"));
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.when().put("/v2/email/export-jobs/no-such-job/cancel").then().statusCode(400)
|
||||
.body("message", equalTo("Invalid JobId"));
|
||||
}
|
||||
@@ -294,16 +295,16 @@ class SesExportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(10)
|
||||
void listExportJobs_filtersAndPaginates() {
|
||||
given().contentType("application/json").header("Authorization", AUTH).body("{}")
|
||||
v2(AUTH).body("{}")
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(200)
|
||||
.body("ExportJobs.JobStatus", everyItem(equalTo("COMPLETED")));
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"ExportSourceType\": \"METRICS_DATA\"}")
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(200)
|
||||
.body("ExportJobs", hasSize(1));
|
||||
|
||||
String nextToken = given().contentType("application/json").header("Authorization", AUTH)
|
||||
String nextToken = v2(AUTH)
|
||||
.body("{\"PageSize\": 1}")
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(200)
|
||||
.body("ExportJobs", hasSize(1))
|
||||
@@ -314,17 +315,17 @@ class SesExportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(11)
|
||||
void insightsExport_filtersOnTheTenantTheSendNamed() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"TenantName\": \"export-tenant\"}")
|
||||
.when().post("/v2/email/tenants").then().statusCode(200);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"TenantName": "export-tenant",
|
||||
"ResourceArn": "arn:aws:ses:eu-west-2:000000000000:identity/%s"}
|
||||
""".formatted(SENDER))
|
||||
.when().post("/v2/email/tenants/resources").then().statusCode(200);
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s", "TenantName": "export-tenant",
|
||||
"Destination": {"ToAddresses": ["in-tenant@example.com"]},
|
||||
@@ -412,17 +413,17 @@ class SesExportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(14)
|
||||
void malformedPagingAndResultLimitsAreRefused() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"PageSize\": \"ten\"}")
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"))
|
||||
.body("message", equalTo("STRING_VALUE can not be converted to an Integer"));
|
||||
// The body is deserialized before any member is validated, so a mistyped member wins.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"JobStatus\": \"BOGUS\", \"PageSize\": \"ten\"}")
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"ExportSourceType\": \"BOGUS\", \"NextToken\": 5}")
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
@@ -486,26 +487,26 @@ class SesExportJobV2IntegrationTest {
|
||||
@Order(16)
|
||||
void listExportJobs_boundsPagingTheWaySesDoes() {
|
||||
for (String size : new String[] {"0", "101", "250"}) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"PageSize\": %s}".formatted(size))
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
.body("message", equalTo("PageSize must be between 1 and 100"));
|
||||
}
|
||||
for (String token : new String[] {"garbage", ""}) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"NextToken\": \"%s\"}".formatted(token))
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(400)
|
||||
.body("message", equalTo("Failed to deserialize token. "));
|
||||
}
|
||||
|
||||
String token = given().contentType("application/json").header("Authorization", AUTH)
|
||||
String token = v2(AUTH)
|
||||
.body("{\"PageSize\": 1}")
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(200)
|
||||
.extract().path("NextToken");
|
||||
assertNotNull(token, "the fixture needs more than one job for this to mean anything");
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"PageSize\": 100, \"NextToken\": \"%s\"}".formatted(token))
|
||||
.when().post("/v2/email/list-export-jobs").then().statusCode(200)
|
||||
.body("$", hasKey("NextToken"))
|
||||
@@ -586,7 +587,7 @@ class SesExportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(20)
|
||||
void cleanUpVdmAndIdentity() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"DISABLED\"}}")
|
||||
.when().put("/v2/email/account/vdm");
|
||||
given().header("Authorization", AUTH)
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
@@ -154,7 +155,7 @@ class SesIdentityPagingIntegrationTest {
|
||||
}
|
||||
|
||||
private static void create(String identity) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailIdentity\": \"" + identity + "\"}")
|
||||
.when().post("/v2/email/identities").then().statusCode(200);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -42,7 +43,7 @@ class SesImportJobV2IntegrationTest {
|
||||
@Order(0)
|
||||
void setupBucketAndContactList() {
|
||||
given().when().put("/" + BUCKET).then().statusCode(200);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"ContactListName":"%s","Topics":[
|
||||
{"TopicName":"Sports","DisplayName":"Sports","DefaultSubscriptionStatus":"OPT_OUT"},
|
||||
@@ -56,7 +57,7 @@ class SesImportJobV2IntegrationTest {
|
||||
void createImportJob_suppressionCsv_runsToCompletedAndFillsTheList() {
|
||||
putObject("suppress.csv", "alice@example.com,BOUNCE\nbob@example.com,COMPLAINT\ncarol@example.com,SPAM\n");
|
||||
|
||||
suppressionJobId = given().contentType("application/json").header("Authorization", AUTH)
|
||||
suppressionJobId = v2(AUTH)
|
||||
.body("""
|
||||
{"ImportDataSource":{"S3Url":"s3://%s/suppress.csv","DataFormat":"CSV"},
|
||||
"ImportDestination":{"SuppressionListDestination":{"SuppressionListImportAction":"PUT"}}}
|
||||
@@ -95,7 +96,7 @@ class SesImportJobV2IntegrationTest {
|
||||
{"emailAddress":"dave@example.com","unsubscribeAll":true}
|
||||
""");
|
||||
|
||||
contactJobId = given().contentType("application/json").header("Authorization", AUTH)
|
||||
contactJobId = v2(AUTH)
|
||||
.body("""
|
||||
{"ImportDataSource":{"S3Url":"s3://%s/contacts.json","DataFormat":"JSON"},
|
||||
"ImportDestination":{"ContactListDestination":{"ContactListName":"%s","ContactListImportAction":"PUT"}}}
|
||||
@@ -124,20 +125,20 @@ class SesImportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(3)
|
||||
void listImportJobs_returnsSummariesAndFiltersByDestinationType() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.when().post("/v2/email/import-jobs/list").then().statusCode(200)
|
||||
.body("ImportJobs.JobId", hasItems(suppressionJobId, contactJobId))
|
||||
.body("ImportJobs.find { it.JobId == '" + contactJobId + "' }.JobStatus", equalTo("COMPLETED"))
|
||||
.body("ImportJobs.find { it.JobId == '" + contactJobId + "' }.ImportDataSource", nullValue())
|
||||
.body("NextToken", nullValue());
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"ImportDestinationType\":\"SUPPRESSION_LIST\",\"PageSize\":10}")
|
||||
.when().post("/v2/email/import-jobs/list").then().statusCode(200)
|
||||
.body("ImportJobs.JobId", hasItems(suppressionJobId))
|
||||
.body("ImportJobs.JobId", not(hasItems(contactJobId)));
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"ImportDestinationType\":\"EXPORT\"}")
|
||||
.when().post("/v2/email/import-jobs/list").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
@@ -146,7 +147,7 @@ class SesImportJobV2IntegrationTest {
|
||||
@Test
|
||||
@Order(4)
|
||||
void createImportJob_missingObject_failsTheJob() {
|
||||
String jobId = given().contentType("application/json").header("Authorization", AUTH)
|
||||
String jobId = v2(AUTH)
|
||||
.body("""
|
||||
{"ImportDataSource":{"S3Url":"s3://%s/does-not-exist.csv","DataFormat":"CSV"},
|
||||
"ImportDestination":{"SuppressionListDestination":{"SuppressionListImportAction":"DELETE"}}}
|
||||
@@ -187,17 +188,17 @@ class SesImportJobV2IntegrationTest {
|
||||
""".formatted(BUCKET);
|
||||
|
||||
for (String body : new String[] {badFormat, bothDestinations, noDataSource}) {
|
||||
given().contentType("application/json").header("Authorization", AUTH).body(body)
|
||||
v2(AUTH).body(body)
|
||||
.when().post("/v2/email/import-jobs").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
}
|
||||
given().contentType("application/json").header("Authorization", AUTH).body(trailingTokens)
|
||||
v2(AUTH).body(trailingTokens)
|
||||
.when().post("/v2/email/import-jobs").then().statusCode(400)
|
||||
.body("__type", equalTo("SerializationException"));
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.when().post("/v2/email/import-jobs").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"));
|
||||
given().contentType("application/json").header("Authorization", AUTH).body(unknownList)
|
||||
v2(AUTH).body(unknownList)
|
||||
.when().post("/v2/email/import-jobs").then().statusCode(404)
|
||||
.body("__type", equalTo("NotFoundException"));
|
||||
}
|
||||
|
||||
+11
-10
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
@@ -40,7 +41,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(0)
|
||||
void setup_contactList() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"ContactListName": "%s",
|
||||
@@ -57,7 +58,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Order(1)
|
||||
void sendWithListManagementOptions_autoCreatesAbsentRecipient() {
|
||||
String recipient = "lmo-newcontact@floci.test";
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -78,7 +79,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(2)
|
||||
void sendWithUnknownContactList_returns404() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -94,7 +95,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(3)
|
||||
void listManagementOptionsWithoutContactListName_returns400() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -110,7 +111,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(4)
|
||||
void listManagementOptionsWithNonStringTopicName_returnsSerializationException() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -128,7 +129,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Order(5)
|
||||
void singleRecipientSend_replacesUnsubscribePlaceholderWithFunctionalUrl() {
|
||||
String recipient = "lmo-unsub-body@floci.test";
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -178,7 +179,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Order(8)
|
||||
void unsubscribeEndpoint_get_rendersConfirmationWithoutOptingOut() {
|
||||
String recipient = "lmo-get@floci.test";
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"" + recipient + "\",\"TopicPreferences\":["
|
||||
+ "{\"TopicName\":\"Sports\",\"SubscriptionStatus\":\"OPT_IN\"}]}")
|
||||
.when().post("/v2/email/contact-lists/" + LIST + "/contacts").then().statusCode(200);
|
||||
@@ -210,7 +211,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
String recipient = "lmo-unsafe-hdr@floci.test";
|
||||
// A user-supplied header whose value carries CR/LF must not survive on any surface: the SMTP
|
||||
// relay already drops it, and the stored SentEmail (GET /_aws/ses) must not retain it either.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -236,7 +237,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
// AWS enforces Content.Simple.Headers[].Value as a required member: a header object that omits
|
||||
// Value is rejected with BadRequestException and a Smithy constraint message, rather than being
|
||||
// silently dropped.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -255,7 +256,7 @@ class SesListManagementOptionsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(11)
|
||||
void send_headerMissingName_isRejectedLikeAws() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
@@ -76,7 +77,7 @@ class SesMessageInsightsV2IntegrationTest {
|
||||
void enableVdmAndVerifyTheSender() {
|
||||
enableVdm(AUTH);
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailIdentity\":\"" + SENDER + "\"}")
|
||||
.when().post("/v2/email/identities").then().statusCode(200);
|
||||
}
|
||||
@@ -178,7 +179,7 @@ class SesMessageInsightsV2IntegrationTest {
|
||||
String encoded = Base64.getEncoder()
|
||||
.encodeToString(raw.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
String messageId = given().contentType("application/json").header("Authorization", AUTH)
|
||||
String messageId = v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["raw@example.com"]},
|
||||
@@ -194,7 +195,7 @@ class SesMessageInsightsV2IntegrationTest {
|
||||
|
||||
// The MIME parser yields "" for a missing Subject header; the member must stay absent.
|
||||
String noSubject = "From: " + SENDER + "\r\nTo: raw@example.com\r\n\r\nhi\r\n";
|
||||
String noSubjectId = given().contentType("application/json").header("Authorization", AUTH)
|
||||
String noSubjectId = v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["raw@example.com"]},
|
||||
@@ -215,7 +216,7 @@ class SesMessageInsightsV2IntegrationTest {
|
||||
// Account-level suppression defaults to [BOUNCE, COMPLAINT], so no configuration set is
|
||||
// needed for the entry to take effect on the send.
|
||||
for (String entry : new String[] {"suppressed@example.com:COMPLAINT", "bounced@example.com:BOUNCE"}) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"%s\",\"Reason\":\"%s\"}"
|
||||
.formatted(entry.split(":")[0], entry.split(":")[1]))
|
||||
.when().put("/v2/email/suppression/addresses").then().statusCode(200);
|
||||
@@ -292,7 +293,7 @@ class SesMessageInsightsV2IntegrationTest {
|
||||
+ "Subject: rejected-mime-subject\r\n"
|
||||
+ SesRawMessage.HEADER_MESSAGE_TAGS + ": campaign=fromheader\r\n\r\n"
|
||||
+ SesTestSignature.value() + "\r\n";
|
||||
String messageId = given().contentType("application/json").header("Authorization", AUTH)
|
||||
String messageId = v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["raw@example.com"]},
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.time.Instant;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
@@ -58,7 +59,7 @@ class SesMetricsV2IntegrationTest {
|
||||
}
|
||||
|
||||
private static Response post(String queriesJson) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH)
|
||||
return v2(AUTH)
|
||||
.body("{\"Queries\": [" + queriesJson + "]}")
|
||||
.when().post("/v2/email/metrics/batch");
|
||||
}
|
||||
@@ -73,7 +74,7 @@ class SesMetricsV2IntegrationTest {
|
||||
}
|
||||
|
||||
private static Response dimensionQuery(String dimension, String value) {
|
||||
return given().contentType("application/json").header("Authorization", AUTH)
|
||||
return v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "v", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": {"%s": "%s"},
|
||||
@@ -88,7 +89,7 @@ class SesMetricsV2IntegrationTest {
|
||||
}
|
||||
|
||||
private static void send(String destination) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
@@ -104,7 +105,7 @@ class SesMetricsV2IntegrationTest {
|
||||
@Order(0)
|
||||
void batchGetMetricData_vdmDisabled_reportsTheGateBeforeItValidatesTheRequest() {
|
||||
// The body is invalid in three ways; with VDM off none of that is reached.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"Queries\": []}")
|
||||
.when().post("/v2/email/metrics/batch").then().statusCode(404)
|
||||
.body("message", containsString(
|
||||
@@ -114,10 +115,10 @@ class SesMetricsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(1)
|
||||
void enableVdmAndVerifyTheSender() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"ENABLED\"}}")
|
||||
.when().put("/v2/email/account/vdm").then().statusCode(200);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"EmailIdentity\":\"" + SENDER + "\"}")
|
||||
.when().post("/v2/email/identities").then().statusCode(200);
|
||||
}
|
||||
@@ -181,7 +182,7 @@ class SesMetricsV2IntegrationTest {
|
||||
|
||||
// A window ending at the first bucket stops before it.
|
||||
long firstBucket = timestamps.get(0).longValue();
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "before", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": %d, "EndDate": %d}]}
|
||||
@@ -193,7 +194,7 @@ class SesMetricsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(6)
|
||||
void batchGetMetricData_filtersOnTheIdentityDimension() {
|
||||
Response response = given().contentType("application/json").header("Authorization", AUTH)
|
||||
Response response = v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "mine", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": {"EMAIL_IDENTITY": "example.com"},
|
||||
@@ -214,11 +215,11 @@ class SesMetricsV2IntegrationTest {
|
||||
void batchGetMetricData_filtersOnTheConfigurationSetEverySendPathResolves() {
|
||||
// One send down each of the three paths, all naming the same set. A regression in any one
|
||||
// of the three assignments shows up here as a count below three.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"ConfigurationSetName\": \"metrics-set\"}")
|
||||
.when().post("/v2/email/configuration-sets").then().statusCode(200);
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s", "ConfigurationSetName": "metrics-set",
|
||||
"Destination": {"ToAddresses": ["simple@example.com"]},
|
||||
@@ -228,7 +229,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.when().post("/v2/email/outbound-emails").then().statusCode(200);
|
||||
|
||||
String raw = "From: " + SENDER + "\r\nTo: raw@example.com\r\nSubject: r\r\n\r\nhi\r\n";
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s", "ConfigurationSetName": "metrics-set",
|
||||
"Destination": {"ToAddresses": ["raw@example.com"]},
|
||||
@@ -237,7 +238,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.encodeToString(raw.getBytes(StandardCharsets.UTF_8))))
|
||||
.when().post("/v2/email/outbound-emails").then().statusCode(200);
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"TemplateName": "metrics-cvet", "FromEmailAddress": "%s",
|
||||
"TemplateSubject": "verify", "TemplateContent": "<p>verify</p>",
|
||||
@@ -245,14 +246,14 @@ class SesMetricsV2IntegrationTest {
|
||||
"FailureRedirectionURL": "https://example.com/no"}
|
||||
""".formatted(SENDER))
|
||||
.when().post("/v2/email/custom-verification-email-templates").then().statusCode(200);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"EmailAddress": "cvet@example.com", "TemplateName": "metrics-cvet",
|
||||
"ConfigurationSetName": "metrics-set"}
|
||||
""")
|
||||
.when().post("/v2/email/outbound-custom-verification-emails").then().statusCode(200);
|
||||
|
||||
Response response = given().contentType("application/json").header("Authorization", AUTH)
|
||||
Response response = v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "set", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": {"CONFIGURATION_SET": "metrics-set"},
|
||||
@@ -268,7 +269,7 @@ class SesMetricsV2IntegrationTest {
|
||||
|
||||
// A send naming a blank set resolves to no set, so it must not join any set's count. A
|
||||
// blank dimension value cannot be used to check that: AWS refuses one outright.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s", "ConfigurationSetName": "",
|
||||
"Destination": {"ToAddresses": ["blank@example.com"]},
|
||||
@@ -277,7 +278,7 @@ class SesMetricsV2IntegrationTest {
|
||||
""".formatted(SENDER))
|
||||
.when().post("/v2/email/outbound-emails").then().statusCode(200);
|
||||
|
||||
Response after = given().contentType("application/json").header("Authorization", AUTH)
|
||||
Response after = v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "set", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": {"CONFIGURATION_SET": "metrics-set"},
|
||||
@@ -293,17 +294,17 @@ class SesMetricsV2IntegrationTest {
|
||||
void batchGetMetricData_filtersOnTheTenantTheSendNamed() {
|
||||
// Without a send that actually names a tenant, dropping the setTenantName assignments
|
||||
// would leave every positive tenant metric at zero and the suite green.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"TenantName\": \"metrics-tenant\"}")
|
||||
.when().post("/v2/email/tenants").then().statusCode(200);
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"TenantName": "metrics-tenant",
|
||||
"ResourceArn": "arn:aws:ses:sa-east-1:000000000000:identity/%s"}
|
||||
""".formatted(SENDER))
|
||||
.when().post("/v2/email/tenants/resources").then().statusCode(200);
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s", "TenantName": "metrics-tenant",
|
||||
"Destination": {"ToAddresses": ["tenant@example.com"]},
|
||||
@@ -314,7 +315,7 @@ class SesMetricsV2IntegrationTest {
|
||||
|
||||
// The raw path stores the tenant too, and only a raw send covers its own assignment.
|
||||
String raw = "From: " + SENDER + "\r\nTo: tenant-raw@example.com\r\nSubject: t\r\n\r\nhi\r\n";
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"FromEmailAddress": "%s", "TenantName": "metrics-tenant",
|
||||
"Destination": {"ToAddresses": ["tenant-raw@example.com"]},
|
||||
@@ -323,7 +324,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.encodeToString(raw.getBytes(StandardCharsets.UTF_8))))
|
||||
.when().post("/v2/email/outbound-emails").then().statusCode(200);
|
||||
|
||||
Response response = given().contentType("application/json").header("Authorization", AUTH)
|
||||
Response response = v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "mine", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": {"TENANT_NAME": "metrics-tenant"},
|
||||
@@ -341,7 +342,7 @@ class SesMetricsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(9)
|
||||
void batchGetMetricData_validatesInTheProbedOrder() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"Queries\": []}")
|
||||
.when().post("/v2/email/metrics/batch").then().statusCode(400)
|
||||
.body("message", equalTo("1 validation error detected: Value at 'queries' failed "
|
||||
@@ -355,7 +356,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.body("message", containsString("Member must have length less than or equal to 10"));
|
||||
|
||||
// A duplicate id outranks both the reversed dates and the interval cap.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "same", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": %d, "EndDate": %d},
|
||||
@@ -367,7 +368,7 @@ class SesMetricsV2IntegrationTest {
|
||||
|
||||
// TENANT_NAME is a valid dimension on AWS even though the pinned SDK model omits it, so it
|
||||
// must not be refused as unsupported.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "tenant", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": {"TENANT_NAME": "no-such-tenant"},
|
||||
@@ -377,7 +378,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.body("Results[0].Values", empty());
|
||||
|
||||
// An unknown dimension name outranks the member constraints.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "d", "Namespace": "VDM", "Metric": "NOT_A_METRIC",
|
||||
"Dimensions": {"NOT_A_DIMENSION": "x"},
|
||||
@@ -387,7 +388,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.body("message", equalTo("Unsupported dimension provided."));
|
||||
|
||||
// Member constraints aggregate into one message, metric first, then namespace, then id.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "", "Namespace": "NOT_VDM", "Metric": "NOT_A_METRIC",
|
||||
"StartDate": %d, "EndDate": %d}]}
|
||||
@@ -414,7 +415,7 @@ class SesMetricsV2IntegrationTest {
|
||||
goodValue("EMAIL_IDENTITY", "UPPER@Example.COM");
|
||||
goodValue("ISP", "Not-An_Isp");
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "same-instant", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": %d, "EndDate": %d}]}
|
||||
@@ -422,7 +423,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.when().post("/v2/email/metrics/batch").then().statusCode(400)
|
||||
.body("message", equalTo("Expected start date to be before the end date."));
|
||||
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "wide", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": %d, "EndDate": %d}]}
|
||||
@@ -432,7 +433,7 @@ class SesMetricsV2IntegrationTest {
|
||||
+ "Please partition your requested interval."));
|
||||
|
||||
// Four keys became reachable when TENANT_NAME was added; the model caps the map at three.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "four", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": {"ISP": "UNKNOWN_ISP", "EMAIL_IDENTITY": "example.com",
|
||||
@@ -445,7 +446,7 @@ class SesMetricsV2IntegrationTest {
|
||||
+ "Member must have length less than or equal to 3"));
|
||||
|
||||
// Probed request-wide: a bad dimension value in any query outranks a bad date in any other.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "dates", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": %d, "EndDate": %d},
|
||||
@@ -457,7 +458,7 @@ class SesMetricsV2IntegrationTest {
|
||||
.body("message", equalTo("Invalid email identity provided."));
|
||||
|
||||
// A timestamp outside Instant's range is the caller's problem, not a server error.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "huge", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": 1, "EndDate": 999999999999999999}]}
|
||||
@@ -466,7 +467,7 @@ class SesMetricsV2IntegrationTest {
|
||||
|
||||
// A window that parses but sits within a day of Instant's upper bound must still answer,
|
||||
// rather than overflowing while the aggregation window is widened.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "edge", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": "+1000000000-12-01T00:00:00Z",
|
||||
@@ -476,13 +477,13 @@ class SesMetricsV2IntegrationTest {
|
||||
.body("Results[0].Values", empty());
|
||||
|
||||
// A list member that is not an array is a deserialization failure too, not an empty list.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"Queries\": {}}")
|
||||
.when().post("/v2/email/metrics/batch").then().statusCode(400)
|
||||
.body("message", equalTo("Start of structure or map found where not expected."));
|
||||
|
||||
// A map member that is not an object is a deserialization failure, not an absent filter.
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "shape", "Namespace": "VDM", "Metric": "SEND",
|
||||
"Dimensions": [],
|
||||
@@ -494,7 +495,7 @@ class SesMetricsV2IntegrationTest {
|
||||
// Sixty days exactly is accepted. Both ends come from one reading of the clock, so a
|
||||
// second boundary between two calls cannot turn this into sixty days and one second.
|
||||
long capEnd = end();
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"Queries": [{"Id": "cap", "Namespace": "VDM", "Metric": "SEND",
|
||||
"StartDate": %d, "EndDate": %d}]}
|
||||
@@ -505,7 +506,7 @@ class SesMetricsV2IntegrationTest {
|
||||
@Test
|
||||
@Order(10)
|
||||
void cleanUpVdmAndIdentity() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("{\"VdmAttributes\":{\"VdmEnabled\":\"DISABLED\"}}")
|
||||
.when().put("/v2/email/account/vdm");
|
||||
given().header("Authorization", AUTH)
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
@@ -39,7 +40,7 @@ class SesTemplatePagingIntegrationTest {
|
||||
// The test-scope MutableClock advances on every read, so each template gets a later
|
||||
// creation time and the order below is by time, not by the name tiebreak.
|
||||
for (String name : new String[] {"page-b", "page-c", "page-a"}) {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
v2(AUTH)
|
||||
.body("""
|
||||
{"TemplateName": "%s", "TemplateContent": {"Subject": "s", "Text": "t"}}
|
||||
""".formatted(name))
|
||||
|
||||
Reference in new issue
Block a user