Skip to content
This repository was archived by the owner on Jul 1, 2026. It is now read-only.

feat(sns): mobile-push endpoint attribute APIs, dedup, and endpoint publish - #1

Merged
sjincho merged 2 commits into
mainfrom
feat/sns-platform-endpoints
Jun 19, 2026
Merged

feat(sns): mobile-push endpoint attribute APIs, dedup, and endpoint publish#1
sjincho merged 2 commits into
mainfrom
feat/sns-platform-endpoints

Conversation

@sjincho

@sjincho sjincho commented Jun 19, 2026

Copy link
Copy Markdown

Summary

MiniStack's SNS mobile-push support was incomplete versus real AWS (and LocalStack), which broke consumers using device-token push flows — registering a device endpoint, reading/refreshing its attributes, and publishing to it. Missing or incorrect before this PR:

  • GetEndpointAttributes / SetEndpointAttributes / DeleteEndpoint returned InvalidAction (not implemented).
  • CreatePlatformEndpoint always created a new endpoint and ignored the top-level CustomUserData parameter.
  • DeletePlatformApplication returned InvalidAction.
  • Publish to a platform-endpoint TargetArn returned Topic does not exist.

(Drove this: a device-token push pipeline — a register-push-device service and an app-push Lambda — where 15 tests failed against stock MiniStack.)

Change

ministack/services/sns.py only:

  • Add GetEndpointAttributes, SetEndpointAttributes, DeleteEndpoint, DeletePlatformApplication.
  • CreatePlatformEndpoint: store CustomUserData; AWS dedup-by-Token — idempotent return when Token+attributes match, otherwise InvalidParameter "Endpoint <arn> already exists with the same Token, but different attributes."
  • Publish: accept a platform-endpoint TargetArn (returns a MessageId; no delivery, matching emulator behavior).
  • Endpoints already live in _platform_endpoints (persisted via get_state/restore_state), so no state-contract change; reset() unchanged.
  • CHANGELOG entry + README SNS action list updated. (AWS API-reference URLs are cited inline in the code comments and the commit body.)

Test plan

  • pytest tests/test_sns.py -k "platform or endpoint" — 12 new tests pass (create/dedup/CustomUserData; Get/Set/Delete incl. NotFound + idempotent delete; DeletePlatformApplication cascade; publish-to-endpoint).
  • Full tests/test_sns.py regression-free — the only 2 failures (*_http_subscription_*) reproduce identically on main (env without aiohttp), unrelated to this change.
  • ruff check ministack/services/sns.py tests/test_sns.py — clean.
  • Verified against the real consumer suite + AWS SDK round-trips (create → get/set → delete→NotFound → duplicate-token error → publish) against an image built from this branch.

Fork-only for now; not yet proposed upstream.

@datadog-official

This comment has been minimized.

@sjincho
sjincho force-pushed the feat/sns-platform-endpoints branch 2 times, most recently from e3116d7 to 8284c6e Compare June 19, 2026 07:15
sjincho and others added 2 commits June 19, 2026 20:27
…ublish

Mobile-push support was missing several SNS actions/behaviors that real AWS
(and LocalStack) provide, so consumers using device-token push flows broke:

- GetEndpointAttributes / SetEndpointAttributes / DeleteEndpoint were not
  implemented (returned InvalidAction).
- CreatePlatformEndpoint always created a new endpoint and ignored the
  top-level CustomUserData parameter.
- DeletePlatformApplication was not implemented.
- Publish to a platform-endpoint TargetArn failed with "Topic does not exist".

Implements the missing actions and AWS-accurate CreatePlatformEndpoint dedup:
idempotent return on matching Token+attributes, otherwise an InvalidParameter
"Endpoint <arn> already exists with the same Token, but different attributes."
Endpoints stay in the existing _platform_endpoints store (already persisted via
get_state/restore_state), so no state-contract change.

Behaviors per the AWS docs:
  https://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformEndpoint.html
  https://docs.aws.amazon.com/sns/latest/api/API_GetEndpointAttributes.html
  https://docs.aws.amazon.com/sns/latest/api/API_SetEndpointAttributes.html
  https://docs.aws.amazon.com/sns/latest/api/API_DeleteEndpoint.html
  https://docs.aws.amazon.com/sns/latest/api/API_DeletePlatformApplication.html
  https://docs.aws.amazon.com/sns/latest/api/API_Publish.html
  https://aws.amazon.com/blogs/mobile/mobile-token-management-with-amazon-sns

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Integration tests for the new behaviors: CreatePlatformEndpoint token dedup
(idempotent vs different-attributes error) and CustomUserData storage;
Get/Set/DeleteEndpoint incl. NotFound and idempotent delete;
DeletePlatformApplication cascading to its endpoints; and Publish to a
platform-endpoint TargetArn. Generic/AWS-accurate, no consumer coupling.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sjincho
sjincho force-pushed the feat/sns-platform-endpoints branch from 8284c6e to db50777 Compare June 19, 2026 11:28
@sjincho
sjincho marked this pull request as ready for review June 19, 2026 11:42
@sjincho
sjincho merged commit f66369b into main Jun 19, 2026
1 check passed
@sjincho
sjincho deleted the feat/sns-platform-endpoints branch June 19, 2026 11:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant