mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
feat(ses): support v2 tenant suppression attributes and tenant-scoped suppression list (#2743)
* feat(ses): support v2 tenant suppression attributes and tenant-scoped suppression list * fix(ses): guard runWithTenant against a null TenantName * fix(ses): collapse an absent TenantName to the service-level message on tenant suppression ops * fix(ses): collapse an absent TenantName to the service-level message on the remaining tenant ops * fix(ses): collapse an empty TenantName to the service-level message on GetTenant/DeleteTenant
This commit is contained in:
1 parent
12a6feb0c9
commit
fc3c28323a
14 files changed
+961
-80
No files matched your search
+103
-11
@@ -19,16 +19,19 @@ import software.amazon.awssdk.services.sesv2.model.DeleteConfigurationSetRequest
|
||||
import software.amazon.awssdk.services.sesv2.model.DeleteEmailIdentityRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.DeleteTenantRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.DeleteTenantResourceAssociationRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.GetSuppressedDestinationResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.GetTenantRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.GetTenantResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListResourceTenantsRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListResourceTenantsResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListSuppressedDestinationsResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListTenantResourcesFilterKey;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListTenantResourcesRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListTenantResourcesResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListTenantsRequest;
|
||||
import software.amazon.awssdk.services.sesv2.model.ListTenantsResponse;
|
||||
import software.amazon.awssdk.services.sesv2.model.NotFoundException;
|
||||
import software.amazon.awssdk.services.sesv2.model.SuppressionListReason;
|
||||
import software.amazon.awssdk.services.sesv2.model.Tag;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -37,15 +40,19 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* SDK compatibility test for the SES v2 tenant APIs: the CRUD (CreateTenant / GetTenant /
|
||||
* ListTenants / DeleteTenant) and the resource associations (CreateTenantResourceAssociation /
|
||||
* DeleteTenantResourceAssociation / ListTenantResources / ListResourceTenants), one ordered flow
|
||||
* against a live Floci instance. One AWS quirk drives the association assertions: the service's wire
|
||||
* values for ResourceType — in responses and as the RESOURCE_TYPE filter value — are the ARN
|
||||
* segments (identity / configuration-set / template), not the SDK's EMAIL_IDENTITY-style enum
|
||||
* constants. Real AWS rejects the enum spelling as a filter and returns values the SDK maps to
|
||||
* UNKNOWN_TO_SDK_VERSION, so the test asserts resourceTypeAsString. Tenants are reversible
|
||||
* (create + delete), so cleanup restores the account.
|
||||
* SDK compatibility test for the SES v2 tenant APIs, one ordered flow against a live Floci
|
||||
* instance: the CRUD (CreateTenant / GetTenant / ListTenants / DeleteTenant), the resource
|
||||
* associations (CreateTenantResourceAssociation / DeleteTenantResourceAssociation /
|
||||
* ListTenantResources / ListResourceTenants), and tenant suppression (PutTenantSuppressionAttributes
|
||||
* plus the TenantName-scoped suppression-list operations). One AWS quirk drives the association
|
||||
* assertions: the service's wire values for ResourceType — in responses and as the RESOURCE_TYPE
|
||||
* filter value — are the ARN segments (identity / configuration-set / template), not the SDK's
|
||||
* EMAIL_IDENTITY-style enum constants. Real AWS rejects the enum spelling as a filter and returns
|
||||
* values the SDK maps to UNKNOWN_TO_SDK_VERSION, so the test asserts resourceTypeAsString. The
|
||||
* suppression block asserts the all-or-nothing attribute pair (a bare TenantName clears it), the
|
||||
* per-tenant list fully separate from the account list, the non-idempotent tenant-scoped delete,
|
||||
* and the DeleteTenant cascade. Tenants are reversible (create + delete), so cleanup restores the
|
||||
* account.
|
||||
*/
|
||||
@DisplayName("SES v2 Tenants")
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@@ -54,6 +61,8 @@ class SesTenantTest {
|
||||
private static final String TENANT = "compat-tenant-alpha";
|
||||
private static final String IDENTITY = "compat-assoc.example.com";
|
||||
private static final String CONFIG_SET = "compat-assoc-cs";
|
||||
private static final String TENANT_ADDR = "compat-sup-tenant@example.com";
|
||||
private static final String ACCOUNT_ADDR = "compat-sup-acct@example.com";
|
||||
|
||||
private static SesV2Client sesV2;
|
||||
private static String identityArn;
|
||||
@@ -65,6 +74,8 @@ class SesTenantTest {
|
||||
sesV2.createEmailIdentity(CreateEmailIdentityRequest.builder().emailIdentity(IDENTITY).build());
|
||||
sesV2.createConfigurationSet(CreateConfigurationSetRequest.builder()
|
||||
.configurationSetName(CONFIG_SET).build());
|
||||
sesV2.putSuppressedDestination(r -> r.emailAddress(ACCOUNT_ADDR)
|
||||
.reason(SuppressionListReason.BOUNCE));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@@ -79,6 +90,7 @@ class SesTenantTest {
|
||||
sesV2.deleteConfigurationSet(DeleteConfigurationSetRequest.builder()
|
||||
.configurationSetName(CONFIG_SET).build());
|
||||
sesV2.deleteEmailIdentity(DeleteEmailIdentityRequest.builder().emailIdentity(IDENTITY).build());
|
||||
sesV2.deleteSuppressedDestination(r -> r.emailAddress(ACCOUNT_ADDR));
|
||||
sesV2.close();
|
||||
}
|
||||
}
|
||||
@@ -238,17 +250,97 @@ class SesTenantTest {
|
||||
|
||||
@Test
|
||||
@Order(15)
|
||||
void deleteTenant_cascadesRemainingAssociations_thenGetIsNotFound() {
|
||||
void putTenantSuppressionAttributes_setsPair_getTenantReturnsThem() {
|
||||
sesV2.putTenantSuppressionAttributes(r -> r.tenantName(TENANT)
|
||||
.suppressedReasonsWithStrings("BOUNCE", "COMPLAINT")
|
||||
.suppressionScope("TENANT"));
|
||||
GetTenantResponse resp = sesV2.getTenant(GetTenantRequest.builder().tenantName(TENANT).build());
|
||||
assertThat(resp.tenant().suppressionAttributes().suppressedReasonsAsStrings())
|
||||
.containsExactly("BOUNCE", "COMPLAINT");
|
||||
assertThat(resp.tenant().suppressionAttributes().suppressionScopeAsString()).isEqualTo("TENANT");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
void putTenantSuppressionAttributes_halfPair_throwsBadRequest() {
|
||||
assertThatThrownBy(() -> sesV2.putTenantSuppressionAttributes(r -> r.tenantName(TENANT)
|
||||
.suppressedReasonsWithStrings("BOUNCE")))
|
||||
.isInstanceOf(BadRequestException.class)
|
||||
.hasMessageContaining("SuppressedReasons cannot be specified without SuppressionScope.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(17)
|
||||
void putTenantSuppressionAttributes_bareTenantName_clearsTheBlock() {
|
||||
sesV2.putTenantSuppressionAttributes(r -> r.tenantName(TENANT));
|
||||
GetTenantResponse resp = sesV2.getTenant(GetTenantRequest.builder().tenantName(TENANT).build());
|
||||
assertThat(resp.tenant().suppressionAttributes()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(18)
|
||||
void tenantSuppressionList_isSeparateFromAccountList() {
|
||||
sesV2.putSuppressedDestination(r -> r.emailAddress(TENANT_ADDR)
|
||||
.reason(SuppressionListReason.BOUNCE).tenantName(TENANT));
|
||||
|
||||
GetSuppressedDestinationResponse got = sesV2.getSuppressedDestination(
|
||||
r -> r.emailAddress(TENANT_ADDR).tenantName(TENANT));
|
||||
assertThat(got.suppressedDestination().tenantName()).isEqualTo(TENANT);
|
||||
|
||||
assertThatThrownBy(() -> sesV2.getSuppressedDestination(r -> r.emailAddress(TENANT_ADDR)))
|
||||
.isInstanceOf(NotFoundException.class)
|
||||
.hasMessageContaining("on your suppression list");
|
||||
assertThatThrownBy(() -> sesV2.getSuppressedDestination(
|
||||
r -> r.emailAddress(ACCOUNT_ADDR).tenantName(TENANT)))
|
||||
.isInstanceOf(NotFoundException.class)
|
||||
.hasMessageContaining("on your tenant suppression list");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(19)
|
||||
void tenantSuppressionList_listsOnlyTenantEntries() {
|
||||
ListSuppressedDestinationsResponse resp =
|
||||
sesV2.listSuppressedDestinations(r -> r.tenantName(TENANT));
|
||||
assertThat(resp.suppressedDestinationSummaries()).hasSize(1);
|
||||
assertThat(resp.suppressedDestinationSummaries().get(0).emailAddress()).isEqualTo(TENANT_ADDR);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(20)
|
||||
void tenantSuppressionOps_missingTenant_throwNotFound() {
|
||||
assertThatThrownBy(() -> sesV2.putSuppressedDestination(r -> r.emailAddress(TENANT_ADDR)
|
||||
.reason(SuppressionListReason.BOUNCE).tenantName("compat-sup-ghost")))
|
||||
.isInstanceOf(NotFoundException.class)
|
||||
.hasMessageContaining("The requested tenant <compat-sup-ghost> does not exist.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(21)
|
||||
void tenantSuppressionDelete_isNotIdempotent() {
|
||||
sesV2.deleteSuppressedDestination(r -> r.emailAddress(TENANT_ADDR).tenantName(TENANT));
|
||||
// Unlike the resource associations, a second tenant-scoped delete is a NotFound.
|
||||
assertThatThrownBy(() -> sesV2.deleteSuppressedDestination(
|
||||
r -> r.emailAddress(TENANT_ADDR).tenantName(TENANT)))
|
||||
.isInstanceOf(NotFoundException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(22)
|
||||
void deleteTenant_cascadesAssociationsAndSuppressionEntries_thenGetIsNotFound() {
|
||||
sesV2.putSuppressedDestination(r -> r.emailAddress(TENANT_ADDR)
|
||||
.reason(SuppressionListReason.COMPLAINT).tenantName(TENANT));
|
||||
sesV2.deleteTenant(DeleteTenantRequest.builder().tenantName(TENANT).build());
|
||||
ListResourceTenantsResponse resp = sesV2.listResourceTenants(
|
||||
ListResourceTenantsRequest.builder().resourceArn(identityArn).build());
|
||||
assertThat(resp.resourceTenants()).isEmpty();
|
||||
assertThatThrownBy(() -> sesV2.listSuppressedDestinations(r -> r.tenantName(TENANT)))
|
||||
.isInstanceOf(NotFoundException.class);
|
||||
assertThatThrownBy(() -> sesV2.getTenant(GetTenantRequest.builder().tenantName(TENANT).build()))
|
||||
.isInstanceOf(NotFoundException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(16)
|
||||
@Order(23)
|
||||
void deleteTenant_missing_throwsNotFound() {
|
||||
assertThatThrownBy(() -> sesV2.deleteTenant(DeleteTenantRequest.builder()
|
||||
.tenantName("compat-tenant-does-not-exist").build()))
|
||||
|
||||
Reference in new issue
Block a user