mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
test(ses): share a v2 request helper across the SES integration tests (#9128)
* test(ses): share a v2 request helper across the SES integration tests
This commit is contained in:
1 parent
7ae2339100
commit
c8304eb002
16 files changed
+96
-141
No files matched your search
@@ -20,9 +20,7 @@ final class SesDomainIdentityTestHelper {
|
||||
}
|
||||
|
||||
static String createVerified(String domain, String sesAuthorization) {
|
||||
List<String> tokens = given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", sesAuthorization)
|
||||
List<String> tokens = SesV2Requests.v2(sesAuthorization)
|
||||
.body("{\"EmailIdentity\": \"" + domain + "\"}")
|
||||
.when()
|
||||
.post("/v2/email/identities")
|
||||
|
||||
@@ -29,8 +29,7 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
class SesImportJobPagingIntegrationTest {
|
||||
|
||||
private static final String REGION = "eu-central-2";
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/" + REGION + "/ses/aws4_request";
|
||||
private static final String AUTH = SesV2Requests.authFor(REGION);
|
||||
private static final String BUCKET = "ses-import-job-paging-it";
|
||||
private static final String PAGE_SIZE_BELOW_ONE = "Value '0' at 'pageSize' failed to satisfy constraint: "
|
||||
+ "Member must have value greater than or equal to 1";
|
||||
@@ -42,7 +41,7 @@ class SesImportJobPagingIntegrationTest {
|
||||
private static final List<String> created = new ArrayList<>();
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
return SesV2Requests.v2(AUTH);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-16
@@ -8,7 +8,9 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.DESTINATION;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.ENTRY;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.post;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
@@ -20,25 +22,10 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
@QuarkusTest
|
||||
class SesInlineTemplateRequiredFieldsIntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String UNVERIFIED = "sender@unverified-inline-template.floci.test";
|
||||
private static final String TO = "success@simulator.amazonses.com";
|
||||
private static final String DESTINATION = "\"Destination\": {\"ToAddresses\": [\"" + TO + "\"]}";
|
||||
private static final String ENTRY = "{" + DESTINATION + "}";
|
||||
private static final String SUBJECT_ONLY = "{\"Subject\": \"s\"}";
|
||||
private static final String MESSAGE = "Template is missing required fields.";
|
||||
|
||||
private static ValidatableResponse post(String path, String body) {
|
||||
return given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH)
|
||||
.body(body)
|
||||
.when()
|
||||
.post(path)
|
||||
.then();
|
||||
}
|
||||
|
||||
private static String template(String templateContent) {
|
||||
return "{\"Template\": {\"TemplateContent\": " + templateContent + ", \"TemplateData\": \"{}\"}}";
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
class SesRecommendationV2IntegrationTest {
|
||||
|
||||
private static final String REGION = "eu-south-2";
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/" + REGION + "/ses/aws4_request";
|
||||
private static final String AUTH = SesV2Requests.authFor(REGION);
|
||||
private static final String DOMAIN = "recommend-it.floci.test";
|
||||
private static final String ARN = "arn:aws:ses:" + REGION + ":000000000000:identity/" + DOMAIN;
|
||||
private static final String PATH = "/v2/email/vdm/recommendations";
|
||||
@@ -36,7 +35,7 @@ class SesRecommendationV2IntegrationTest {
|
||||
private static String zoneId;
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
return SesV2Requests.v2(AUTH);
|
||||
}
|
||||
|
||||
private static void addTxtRecord(String name, String value) {
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -28,8 +27,6 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesReputationEntityV2IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String PREFIX = "arn:aws:ses:us-east-1:000000000000:tenant/floci-rep-it-";
|
||||
private static final String POLICY_PREFIX = "arn:aws:ses:us-east-1:aws:reputation-policy/";
|
||||
private static final String INVALID_IDENTIFIER = "Provided resource identifier is invalid";
|
||||
@@ -39,7 +36,7 @@ class SesReputationEntityV2IntegrationTest {
|
||||
|
||||
// The reference is sent percent-encoded as the SDKs send it, so RestAssured must not encode it again.
|
||||
private static RequestSpecification v2() {
|
||||
return given().urlEncodingEnabled(false).contentType("application/json").header("Authorization", AUTH);
|
||||
return SesV2Requests.v2().urlEncodingEnabled(false);
|
||||
}
|
||||
|
||||
private static String entityPath(String type, String reference) {
|
||||
|
||||
+10
-21
@@ -6,6 +6,9 @@ import io.restassured.specification.RequestSpecification;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.floci.aws.services.ses.SesV2Requests.ENTRY;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.TO;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.post;
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@@ -23,19 +26,15 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
@QuarkusTest
|
||||
class SesSendTemplateLookupOrderIntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
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 TO = "success@simulator.amazonses.com";
|
||||
private static final String GHOST_CONFIG_SET = "template-order-ghost-config-set";
|
||||
private static final String GHOST_TEMPLATE =
|
||||
"{\"Template\": {\"TemplateName\": \"template-order-ghost\", \"TemplateData\": \"{}\"}}";
|
||||
private static final String INLINE_TEMPLATE =
|
||||
"{\"Template\": {\"TemplateContent\": {\"Subject\": \"s\", \"Text\": \"b\"}, \"TemplateData\": \"{}\"}}";
|
||||
private static final String VALID_ENTRY = "{\"Destination\": {\"ToAddresses\": [\"" + TO + "\"]}}";
|
||||
private static final String NOT_VERIFIED_MESSAGE =
|
||||
"Email address is not verified. The following identities failed the check in region US-EAST-1: ";
|
||||
private static final String V1_GHOST_TEMPLATE = "template-order-v1-ghost";
|
||||
@@ -54,16 +53,6 @@ class SesSendTemplateLookupOrderIntegrationTest {
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
private static ValidatableResponse post(String path, String body) {
|
||||
return given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH)
|
||||
.body(body)
|
||||
.when()
|
||||
.post(path)
|
||||
.then();
|
||||
}
|
||||
|
||||
private static ValidatableResponse bulk(String sender, String content, String members, String entries) {
|
||||
return post("/v2/email/outbound-bulk-emails", "{\"FromEmailAddress\": \"" + sender + "\", " + members
|
||||
+ "\"DefaultContent\": " + content + ", \"BulkEmailEntries\": [" + entries + "]}");
|
||||
@@ -136,44 +125,44 @@ class SesSendTemplateLookupOrderIntegrationTest {
|
||||
|
||||
@Test
|
||||
void sendBulkEmail_unverifiedSenderPrecedesUnknownTemplate() {
|
||||
assertNotVerified(bulk(UNVERIFIED, GHOST_TEMPLATE, "", VALID_ENTRY), UNVERIFIED);
|
||||
assertNotVerified(bulk(UNVERIFIED, GHOST_TEMPLATE, "", ENTRY), UNVERIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendBulkEmail_unverifiedSenderPrecedesUnknownTemplateArn() {
|
||||
assertNotVerified(bulk(UNVERIFIED, "{\"Template\": {\"TemplateArn\": "
|
||||
+ "\"arn:aws:ses:us-east-1:000000000000:template/template-order-ghost\", \"TemplateData\": \"{}\"}}",
|
||||
"", VALID_ENTRY), UNVERIFIED);
|
||||
"", ENTRY), UNVERIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendBulkEmail_unknownConfigurationSetPrecedesUnverifiedSender() {
|
||||
assertConfigSetNotFound(bulk(UNVERIFIED, INLINE_TEMPLATE,
|
||||
"\"ConfigurationSetName\": \"" + GHOST_CONFIG_SET + "\", ", VALID_ENTRY));
|
||||
"\"ConfigurationSetName\": \"" + GHOST_CONFIG_SET + "\", ", ENTRY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendBulkEmail_verifiedSender_unknownTemplate() {
|
||||
assertTemplateNotFound(bulk(VERIFIED, GHOST_TEMPLATE, "", VALID_ENTRY));
|
||||
assertTemplateNotFound(bulk(VERIFIED, GHOST_TEMPLATE, "", ENTRY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendBulkEmail_unknownConfigurationSetPrecedesUnknownTemplate() {
|
||||
assertConfigSetNotFound(bulk(VERIFIED, GHOST_TEMPLATE,
|
||||
"\"ConfigurationSetName\": \"" + GHOST_CONFIG_SET + "\", ", VALID_ENTRY));
|
||||
"\"ConfigurationSetName\": \"" + GHOST_CONFIG_SET + "\", ", ENTRY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendBulkEmail_unverifiedFeedbackForwardingAddressPrecedesUnknownTemplate() {
|
||||
assertNotVerified(bulk(VERIFIED, GHOST_TEMPLATE,
|
||||
"\"FeedbackForwardingEmailAddress\": \"" + UNVERIFIED + "\", ", VALID_ENTRY), UNVERIFIED);
|
||||
"\"FeedbackForwardingEmailAddress\": \"" + UNVERIFIED + "\", ", ENTRY), UNVERIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void sendBulkEmail_unknownTemplatePrecedesMalformedEntryAndReplyTo() {
|
||||
assertTemplateNotFound(bulk(VERIFIED, GHOST_TEMPLATE, "",
|
||||
"{\"Destination\": {\"ToAddresses\": [\"bad\"]}}"));
|
||||
assertTemplateNotFound(bulk(VERIFIED, GHOST_TEMPLATE, "\"ReplyToAddresses\": [\"bad\"], ", VALID_ENTRY));
|
||||
assertTemplateNotFound(bulk(VERIFIED, GHOST_TEMPLATE, "\"ReplyToAddresses\": [\"bad\"], ", ENTRY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.nio.charset.StandardCharsets;
|
||||
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.equalTo;
|
||||
import static org.hamcrest.Matchers.everyItem;
|
||||
@@ -95,13 +96,6 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
""".formatted(from);
|
||||
}
|
||||
|
||||
private static RequestSpecification v2Request(String authorization, String body) {
|
||||
return given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", authorization)
|
||||
.body(body);
|
||||
}
|
||||
|
||||
private static void verifyEmailIdentity(String address) {
|
||||
query("VerifyEmailIdentity").formParam("EmailAddress", address)
|
||||
.when().post("/").then().statusCode(200);
|
||||
@@ -216,14 +210,14 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
|
||||
@Test
|
||||
void v2SendEmail_simple_unverifiedFrom_returnsMessageRejected() {
|
||||
assertMessageRejectedV2(v2Request(AUTH_V2, simpleBody(UNVERIFIED)), UNVERIFIED);
|
||||
assertMessageRejectedV2(v2(AUTH_V2).body(simpleBody(UNVERIFIED)), UNVERIFIED);
|
||||
|
||||
assertNothingCapturedFrom(UNVERIFIED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void v2SendEmail_raw_unverifiedMimeFrom_returnsMessageRejected() {
|
||||
assertMessageRejectedV2(v2Request(AUTH_V2, """
|
||||
assertMessageRejectedV2(v2(AUTH_V2).body("""
|
||||
{
|
||||
"Destination": {"ToAddresses": ["to@example.com"]},
|
||||
"Content": {"Raw": {"Data": "%s"}}
|
||||
@@ -233,11 +227,11 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
|
||||
@Test
|
||||
void v2SendEmail_verifiedEmailIdentity_succeeds() {
|
||||
v2Request(AUTH_V2, "{\"EmailIdentity\": \"v2-" + VERIFIED + "\"}")
|
||||
v2(AUTH_V2).body("{\"EmailIdentity\": \"v2-" + VERIFIED + "\"}")
|
||||
.when()
|
||||
.post("/v2/email/identities");
|
||||
|
||||
assertSentV2(v2Request(AUTH_V2, simpleBody("v2-" + VERIFIED)));
|
||||
assertSentV2(v2(AUTH_V2).body(simpleBody("v2-" + VERIFIED)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,7 +239,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
String domain = "verified-domain.floci.test";
|
||||
SesDomainIdentityTestHelper.createVerified(domain, AUTH_V2);
|
||||
|
||||
assertSentV2(v2Request(AUTH_V2, simpleBody("anyone@" + domain)));
|
||||
assertSentV2(v2(AUTH_V2).body(simpleBody("anyone@" + domain)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -255,7 +249,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
String domain = "verified-parent.floci.test";
|
||||
SesDomainIdentityTestHelper.createVerified(domain, AUTH_V2);
|
||||
|
||||
assertSentV2(v2Request(AUTH_V2, simpleBody("anyone@a.b." + domain)));
|
||||
assertSentV2(v2(AUTH_V2).body(simpleBody("anyone@a.b." + domain)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -328,7 +322,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
String feedback = "v2-bounces@unverified-sender.floci.test";
|
||||
verifyEmailIdentity(source);
|
||||
|
||||
assertMessageRejectedV2(v2Request(AUTH_V2, """
|
||||
assertMessageRejectedV2(v2(AUTH_V2).body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
"FeedbackForwardingEmailAddress": "%s",
|
||||
@@ -346,7 +340,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
String feedback = "v2-raw-bounces@unverified-sender.floci.test";
|
||||
verifyEmailIdentity(source);
|
||||
|
||||
assertMessageRejectedV2(v2Request(AUTH_V2, """
|
||||
assertMessageRejectedV2(v2(AUTH_V2).body("""
|
||||
{
|
||||
"FeedbackForwardingEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["to@example.com"]},
|
||||
@@ -373,7 +367,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
String source = "raw-v2-source-" + VERIFIED;
|
||||
verifyEmailIdentity(source);
|
||||
|
||||
assertSentV2(v2Request(AUTH_V2, """
|
||||
assertSentV2(v2(AUTH_V2).body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
"Destination": {"ToAddresses": ["to@example.com"]},
|
||||
@@ -530,7 +524,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
void v2SendEmail_fromAndFeedbackForwardingIdentityArnsOfAnotherAccount_succeeds() {
|
||||
verifyOwnerAddress();
|
||||
|
||||
assertSentV2(v2Request(DELEGATE_AUTH_V2, """
|
||||
assertSentV2(v2(DELEGATE_AUTH_V2).body("""
|
||||
{
|
||||
"FromEmailAddress": "%s",
|
||||
"FromEmailAddressIdentityArn": "%s",
|
||||
@@ -548,7 +542,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
// X-SES-FROM-ARN headers specified in raw email message content."
|
||||
verifyOwnerAddress();
|
||||
|
||||
assertSentV2(v2Request(DELEGATE_AUTH_V2, """
|
||||
assertSentV2(v2(DELEGATE_AUTH_V2).body("""
|
||||
{
|
||||
"FromEmailAddressIdentityArn": "%s",
|
||||
"Destination": {"ToAddresses": ["to@example.com"]},
|
||||
@@ -593,7 +587,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
|
||||
@Test
|
||||
void v2SendBulkEmail_unverifiedFrom_rejectsTheWholeCall() {
|
||||
assertBulkMessageRejectedV2(v2Request(AUTH_V2, bulkBody(UNVERIFIED)), UNVERIFIED);
|
||||
assertBulkMessageRejectedV2(v2(AUTH_V2).body(bulkBody(UNVERIFIED)), UNVERIFIED);
|
||||
|
||||
assertNothingCapturedFrom(UNVERIFIED);
|
||||
}
|
||||
@@ -604,7 +598,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
String feedback = "bulk-bounces@unverified-sender.floci.test";
|
||||
verifyEmailIdentity(source);
|
||||
|
||||
assertBulkMessageRejectedV2(v2Request(AUTH_V2, bulkBody(source,
|
||||
assertBulkMessageRejectedV2(v2(AUTH_V2).body(bulkBody(source,
|
||||
"\"FeedbackForwardingEmailAddress\": \"" + feedback + "\",",
|
||||
"[{\"Destination\": {\"ToAddresses\": [\"to@example.com\"]}}]")), feedback);
|
||||
|
||||
@@ -614,7 +608,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
@Test
|
||||
void v2SendBulkEmail_noEntryHasARecipient_senderIsNotChecked() {
|
||||
// AWS fails each entry on its missing destination and never reaches the sender check.
|
||||
v2Request(AUTH_V2, bulkBody(UNVERIFIED, "", "[{\"Destination\": {}}]"))
|
||||
v2(AUTH_V2).body(bulkBody(UNVERIFIED, "", "[{\"Destination\": {}}]"))
|
||||
.when()
|
||||
.post("/v2/email/outbound-bulk-emails")
|
||||
.then()
|
||||
@@ -627,7 +621,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
String source = "bulk-" + VERIFIED;
|
||||
verifyEmailIdentity(source);
|
||||
|
||||
v2Request(AUTH_V2, bulkBody(source))
|
||||
v2(AUTH_V2).body(bulkBody(source))
|
||||
.when()
|
||||
.post("/v2/email/outbound-bulk-emails")
|
||||
.then()
|
||||
@@ -639,7 +633,7 @@ class SesSendVerifiedSenderIntegrationTest {
|
||||
void v2SendBulkEmail_fromAndFeedbackForwardingIdentityArnsOfAnotherAccount_succeeds() {
|
||||
verifyOwnerAddress();
|
||||
|
||||
v2Request(DELEGATE_AUTH_V2, bulkBody(OWNER_ADDRESS,
|
||||
v2(DELEGATE_AUTH_V2).body(bulkBody(OWNER_ADDRESS,
|
||||
"\"FromEmailAddressIdentityArn\": \"" + OWNER_IDENTITY_ARN + "\","
|
||||
+ "\"FeedbackForwardingEmailAddress\": \"" + OWNER_ADDRESS + "\","
|
||||
+ "\"FeedbackForwardingEmailAddressIdentityArn\": \"" + OWNER_IDENTITY_ARN + "\",",
|
||||
|
||||
+4
-6
@@ -22,10 +22,8 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesSuppressedDestinationPagingIntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/me-south-1/ses/aws4_request";
|
||||
private static final String OTHER_REGION_AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/eu-north-1/ses/aws4_request";
|
||||
private static final String AUTH = SesV2Requests.authFor("me-south-1");
|
||||
private static final String OTHER_REGION_AUTH = SesV2Requests.authFor("eu-north-1");
|
||||
private static final String PATH = "/v2/email/suppression/addresses";
|
||||
private static final String ADDRESSES = "SuppressedDestinationSummaries.EmailAddress";
|
||||
private static final String TENANT = "page-tenant";
|
||||
@@ -102,7 +100,7 @@ class SesSuppressedDestinationPagingIntegrationTest {
|
||||
@Test
|
||||
@Order(6)
|
||||
void aTenantListPagesOnItsOwnTokens() {
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
SesV2Requests.v2(AUTH)
|
||||
.body("{\"TenantName\":\"" + TENANT + "\"}")
|
||||
.when().post("/v2/email/tenants").then().statusCode(200);
|
||||
put("tenant-a@example.com", "BOUNCE", TENANT);
|
||||
@@ -135,7 +133,7 @@ class SesSuppressedDestinationPagingIntegrationTest {
|
||||
|
||||
private static void put(String address, String reason, String tenant) {
|
||||
String tenantMember = tenant == null ? "" : ",\"TenantName\":\"" + tenant + "\"";
|
||||
given().contentType("application/json").header("Authorization", AUTH)
|
||||
SesV2Requests.v2(AUTH)
|
||||
.body("{\"EmailAddress\":\"" + address + "\",\"Reason\":\"" + reason + "\"" + tenantMember + "}")
|
||||
.when().put(PATH).then().statusCode(200);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.DESTINATION;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.ENTRY;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.post;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
@@ -21,15 +23,10 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
@QuarkusTest
|
||||
class SesTemplateSelectorIntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String SEND = "/v2/email/outbound-emails";
|
||||
private static final String BULK = "/v2/email/outbound-bulk-emails";
|
||||
private static final String UNVERIFIED = "sender@unverified-template-selector.floci.test";
|
||||
private static final String FROM = "\"FromEmailAddress\": \"" + UNVERIFIED + "\"";
|
||||
private static final String DESTINATION =
|
||||
"\"Destination\": {\"ToAddresses\": [\"success@simulator.amazonses.com\"]}";
|
||||
private static final String ENTRY = "{" + DESTINATION + "}";
|
||||
private static final String ENTRIES = "\"BulkEmailEntries\": [" + ENTRY + "]";
|
||||
private static final String BAD_DESTINATION = "\"Destination\": {\"ToAddresses\": [\"not an address\"]}";
|
||||
private static final String NAME = "\"TemplateName\": \"selector-ghost\"";
|
||||
@@ -46,16 +43,6 @@ class SesTemplateSelectorIntegrationTest {
|
||||
private static final String BULK_COUNT =
|
||||
"You must specify at least 1 destination, and no more than 50 destinations";
|
||||
|
||||
private static ValidatableResponse post(String path, String body) {
|
||||
return given()
|
||||
.contentType("application/json")
|
||||
.header("Authorization", AUTH)
|
||||
.body(body)
|
||||
.when()
|
||||
.post(path)
|
||||
.then();
|
||||
}
|
||||
|
||||
private static String template(String... members) {
|
||||
return "{\"Template\": {" + String.join(", ", members) + "}}";
|
||||
}
|
||||
|
||||
@@ -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.SesV2Requests.v2;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
@@ -26,8 +25,6 @@ import static org.hamcrest.Matchers.startsWith;
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesTenantAssociationV2IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String TENANT = "floci-assoc-tenant";
|
||||
private static final String TENANT_B = "floci-assoc-tenant-b";
|
||||
private static final String IDENTITY = "floci-assoc.example.com";
|
||||
@@ -38,10 +35,6 @@ class SesTenantAssociationV2IntegrationTest {
|
||||
private static final String CONFIG_SET_ARN = ARN_PREFIX + "configuration-set/" + CONFIG_SET;
|
||||
private static final String TEMPLATE_ARN = ARN_PREFIX + "template/" + TEMPLATE;
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
}
|
||||
|
||||
private static void associate(String tenant, String arn) {
|
||||
v2().body("{\"TenantName\":\"" + tenant + "\",\"ResourceArn\":\"" + arn + "\"}")
|
||||
.when().post("/v2/email/tenants/resources").then().statusCode(200);
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
@@ -34,8 +33,7 @@ class SesTenantPagingIntegrationTest {
|
||||
private static final String REGION = "af-south-1";
|
||||
// Only a token is sent there and it is refused, so no state lands in this region.
|
||||
private static final String OTHER_REGION = "eu-west-1";
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/" + REGION + "/ses/aws4_request";
|
||||
private static final String AUTH = SesV2Requests.authFor(REGION);
|
||||
private static final String ARN_PREFIX = "arn:aws:ses:" + REGION + ":000000000000:";
|
||||
private static final String PAGE_SIZE_BELOW_ONE = "Value '0' at 'pageSize' failed to satisfy constraint: "
|
||||
+ "Member must have value greater than or equal to 1";
|
||||
@@ -45,7 +43,7 @@ class SesTenantPagingIntegrationTest {
|
||||
+ "Member must have length greater than or equal to 1";
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
return SesV2Requests.v2(AUTH);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,8 +144,7 @@ class SesTenantPagingIntegrationTest {
|
||||
String token = v2().body("{\"PageSize\":1}")
|
||||
.when().post("/v2/email/tenants/list").then().statusCode(200).extract().path("NextToken");
|
||||
|
||||
given().contentType("application/json")
|
||||
.header("Authorization", AUTH.replace(REGION, OTHER_REGION))
|
||||
SesV2Requests.v2(SesV2Requests.authFor(OTHER_REGION))
|
||||
.body("{\"NextToken\":\"" + token + "\"}")
|
||||
.when().post("/v2/email/tenants/list").then().statusCode(400)
|
||||
.body("__type", equalTo("BadRequestException"))
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.floci.aws.services.ses;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
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,8 @@ import org.junit.jupiter.api.TestMethodOrder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
@@ -24,8 +24,6 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesTenantSendOrderV2IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String TENANT = "floci-order-tenant";
|
||||
private static final String DOMAIN = "floci-order.example.com";
|
||||
private static final String FROM = "sender@" + DOMAIN;
|
||||
@@ -40,10 +38,6 @@ class SesTenantSendOrderV2IntegrationTest {
|
||||
private static final String SIMPLE =
|
||||
"\"Content\":{\"Simple\":{\"Subject\":{\"Data\":\"s\"},\"Body\":{\"Text\":{\"Data\":\"t\"}}}}";
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
}
|
||||
|
||||
private static String member(String name, String value) {
|
||||
return "\"" + name + "\":\"" + value + "\",";
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -11,7 +10,8 @@ import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.AUTH;
|
||||
import static io.floci.aws.services.ses.SesV2Requests.v2;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
@@ -29,8 +29,6 @@ import static org.hamcrest.Matchers.notNullValue;
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesTenantSendV2IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String TENANT = "floci-send-tenant";
|
||||
private static final String DOMAIN = "floci-send.example.com";
|
||||
private static final String FROM = "no-reply@" + DOMAIN;
|
||||
@@ -38,10 +36,6 @@ class SesTenantSendV2IntegrationTest {
|
||||
private static final String TEMPLATE = "floci-send-tpl";
|
||||
private static final String ARN_PREFIX = "arn:aws:ses:us-east-1:000000000000:";
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
}
|
||||
|
||||
private static String simpleSend(String tenantName, String configSetLine) {
|
||||
return "{\"FromEmailAddress\":\"" + FROM + "\","
|
||||
+ "\"Destination\":{\"ToAddresses\":[\"success@simulator.amazonses.com\"]},"
|
||||
|
||||
@@ -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.SesV2Requests.v2;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
@@ -26,16 +25,10 @@ import static org.hamcrest.Matchers.nullValue;
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesTenantSuppressionV2IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String TENANT = "floci-sup-tenant";
|
||||
private static final String TENANT_ADDR = "floci-sup-tenant@example.com";
|
||||
private static final String ACCOUNT_ADDR = "floci-sup-acct@example.com";
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void createTenant_withSuppressionAttributes_rendersThem() {
|
||||
|
||||
@@ -2,13 +2,12 @@ package io.floci.aws.services.ses;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.path.json.JsonPath;
|
||||
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.SesV2Requests.v2;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
|
||||
@@ -23,18 +22,12 @@ import static org.hamcrest.Matchers.hasSize;
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
class SesTenantTagV2IntegrationTest {
|
||||
|
||||
private static final String AUTH =
|
||||
"AWS4-HMAC-SHA256 Credential=AKID/20260101/us-east-1/ses/aws4_request";
|
||||
private static final String TENANT = "floci-tag-tenant";
|
||||
private static final String ARN_PREFIX = "arn:aws:ses:us-east-1:000000000000:";
|
||||
|
||||
private static String tenantArn;
|
||||
private static String tenantId;
|
||||
|
||||
private static RequestSpecification v2() {
|
||||
return given().contentType("application/json").header("Authorization", AUTH);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
void createTenantWithTags_visibleThroughListTagsForResource() {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package io.floci.aws.services.ses;
|
||||
|
||||
import io.restassured.response.ValidatableResponse;
|
||||
import io.restassured.specification.RequestSpecification;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
|
||||
/**
|
||||
* Builds SES v2 REST JSON requests for the integration tests: a JSON body with an Authorization
|
||||
* header scoped to SES in a region. The overloads without an authorization use {@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 SesV2Requests {
|
||||
|
||||
static final String AUTH = authFor("us-east-1");
|
||||
static final String TO = "success@simulator.amazonses.com";
|
||||
static final String DESTINATION = "\"Destination\": {\"ToAddresses\": [\"" + TO + "\"]}";
|
||||
static final String ENTRY = "{" + DESTINATION + "}";
|
||||
|
||||
private SesV2Requests() {
|
||||
}
|
||||
|
||||
static String authFor(String region) {
|
||||
return "AWS4-HMAC-SHA256 Credential=AKID/20260101/" + region + "/ses/aws4_request";
|
||||
}
|
||||
|
||||
static RequestSpecification v2() {
|
||||
return v2(AUTH);
|
||||
}
|
||||
|
||||
static RequestSpecification v2(String authorization) {
|
||||
return given().contentType("application/json").header("Authorization", authorization);
|
||||
}
|
||||
|
||||
static ValidatableResponse post(String path, String body) {
|
||||
return post(AUTH, path, body);
|
||||
}
|
||||
|
||||
static ValidatableResponse post(String authorization, String path, String body) {
|
||||
return v2(authorization).body(body).when().post(path).then();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user