mirror of
https://github.com/floci-io/floci.git
synced 2026-11-25 06:47:41 -05:00
* feat(ses): publish SES events to SNS configuration set destinations Add SES V2 event publishing to SnsDestination targets configured on a ConfigurationSet. When SendEmail / SendRawEmail / SendTemplatedEmail / SendBulkEmail is invoked with a ConfigurationSetName, Floci builds the matching AWS-format event payload (a `mail` block plus an event-type- specific block) and publishes it to each enabled SNS destination whose MatchingEventTypes includes that event. Events emitted - SEND on every successful send. - DELIVERY / BOUNCE / COMPLAINT / REJECT when a recipient matches the corresponding AWS mailbox simulator address (success@ / bounce@ / complaint@ / suppressionlist@simulator.amazonses.com). - Per-event-type recipient lists (delivery.recipients, bounce.bouncedRecipients, complaint.complainedRecipients) are filtered to only the simulator address that triggered the event and emitted in their canonical trimmed form; mail.destination carries the full envelope. Wire-level fidelity - Event payload mirrors the AWS SES SNS notification format documented at https://docs.aws.amazon.com/ses/latest/dg/event-publishing-retrieving-sns-examples.html. - mail.tags includes user-supplied EmailTags / DefaultEmailTags / ReplacementTags (V2) and Tags.member.N / DefaultTags.member.N / Destinations.member.N.ReplacementTags (V1 Query). Each tag emits as {Name: [Value]}. - mail.headers[] appends user-supplied Content.Simple.Headers and Content.Template.Headers after the auto-emitted From/To/Cc/Subject; null/blank Names are rejected with "The header name must be specified." (BadRequestException 400). - V2 SendBulkEmail BulkEmailEntries accept ReplacementTags (merged by Name onto DefaultEmailTags) and ReplacementHeaders (merged case-insensitively per RFC 5322 onto DefaultContent.Template.Headers). - mail.sendingAccountId resolves from EmulatorConfig.defaultAccountId(). - ConfigurationSet existence is validated up-front on sendEmail / sendRawEmail / sendBulkTemplatedEmail — an unknown name fails fast with ConfigurationSetDoesNotExist (V2 controller remaps to NotFoundException 404, V1 returns 400) before any message is stored or relayed. Validation errors aligned with live AWS - EmailTags blank Name: BadRequestException 400 "The tag name must be specified." (V2) / InvalidParameterValue 400 same message (V1). - ConfigurationSetName not found: same error code, status, and message as AWS. Raw email handling - For V2 SendEmail with Raw content (and V1 SendRawEmail), when the caller did not provide Destinations, Floci falls back to To/Cc/Bcc parsed from the raw MIME via SmtpRelay.parseRawHeaders (extracted from the existing relay logic). MIME parsing is only invoked when needed (no explicit Destinations or event publishing active). Internal shape - New records: model/MessageTag (Name, Value, for EmailTags) and model/MessageHeader (Name, Value, for Content.Headers) — kept distinct from the resource-tag Tag (Key, Value). - SesEventPublisher dispatches to SnsService; non-SNS destination types log a warning and are skipped (Firehose / EventBridge / CloudWatch / Pinpoint), and missing SnsDestination.TopicArn likewise warns instead of silently dropping. Failures preserve the throwable in the warn log. Tests - SesEventPayloadTest covers mail/commonHeaders/headers/tags shape, per-event filtering, and the headers/tags propagation paths. - SesServiceMergeEmailTagsTest / SesServiceMergeHeadersTest pin Bulk Default vs per-entry merge semantics (tags by Name case-sensitive, headers by Name case-insensitive per RFC 5322). - SesEventPublishingV2IntegrationTest exercises Send / Delivery / Bounce / SendOnly / mixed-recipient / disabled-destination / V1-MIME-fallback / EmailTags / V1-Tags / Simple.Headers paths end-to-end through SES -> SNS -> SQS. - compatibility-tests/sdk-test-java/SesEventPublishingTest validates SendEmail with EmailTags/Headers and SendBulkEmail with per-entry ReplacementHeaders override using AWS Java SDK V2 clients. * fix(ses): address Copilot review on upstream PR #1106 - SesService.validateConfigurationSet: clarify the Javadoc — the helper always throws with httpStatus = 400, and the V2 controller's remapV1Exception is what turns ConfigurationSetDoesNotExist into NotFoundException 404. The previous "(404 in V2, 400 in V1)" hint read as if the helper itself picked the status, which is misleading. - SesController.parseEmailTagsArray: reject non-object entries with "<fieldName> entries must be JSON objects.", mirroring the existing parseHeadersArray check. Previously a string/number element would hit the blank-Name path and report a less specific message. - SesService.mergeHeaders / mergeEmailTags: also skip entries whose name is the empty string, not just null. Both parsers reject blank names at the boundary, but defending the merge helpers keeps them safe for direct callers (e.g., future tests) and matches the intent of the boundary validation.
sdk-test-java
Compatibility tests for Floci using the AWS SDK for Java v2 (2.31.8).
Runs 313 tests across 16 test classes against a live Floci instance — no mocks.
Services Covered
| Test class | Description |
|---|---|
SsmTest |
Parameter Store — put, get, path, tags |
SqsTest |
Queues, send/receive/delete, DLQ, visibility |
SnsTest |
Topics, subscriptions, publish, SQS delivery |
S3Test |
Buckets, objects, tagging, copy, multipart, batch delete |
DynamoDbTest |
Tables, CRUD, batch, TTL, tags, streams |
DynamoDbScanConditionTests |
Scan filter and condition expressions |
LambdaTest |
Create/invoke/update/delete functions |
IamTest |
Users, roles, policies, access keys |
StsTest |
GetCallerIdentity, AssumeRole, GetSessionToken |
SecretsManagerTest |
Create/get/put/list/delete secrets, versioning, tags |
KmsTest |
Keys, aliases, encrypt/decrypt, data keys, sign/verify |
CloudWatchTest |
PutMetricData, ListMetrics, GetMetricStatistics, alarms |
CloudFormationVirtualHostTests |
Virtual host style S3 access via CloudFormation |
ApigwSfnJsonataCrudlTests |
API Gateway + Step Functions JSONata CRUDL integration |
ApiGatewayV2WebSocketAndExtendedOpsTest |
API GW v2 WebSocket APIs, Update ops, Route/Integration Responses, Models, Tagging |
Ec2Tests |
EC2 instances, VPCs, security groups, subnets |
EcsTests |
ECS clusters, task definitions, services |
Adding a New Test
Create a standard JUnit 5 test class in src/test/java/com/floci/test/. Tests run against a live Floci instance using real AWS SDK clients.
Requirements
- Java 17+
- Maven
Running
# All tests
mvn test -q
# Specific test class
mvn test -Dtest=S3Test
# Via just (from compatibility-tests/)
just test-java
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_ENDPOINT |
http://localhost:4566 |
Floci emulator endpoint |
AWS credentials are always test / test / us-east-1.
Docker
docker build -t floci-sdk-java .
docker run --rm --network host floci-sdk-java
# Custom endpoint (macOS/Windows)
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-java