Repository navigation
test(cli): e2e for init apns against the mock API and a mock of Apple - #2026
Conversation
The mock API keeps messaging providers and project platforms per project, so the harness can run the built binary on a project folder: the first run creates both APNs providers and the Apple platform and prints the next steps, a rerun changes nothing, and a malformed bundle ID, an unknown --provider and an unknown --environment fail.
The mock keeps providers and platforms in a volume that docker compose down leaves in place, so a fixed project made every run after the first see the earlier run's providers and fail its first-run checks.
🟢 Tier S · Ready to mergeAdds persistent mock Appwrite APNs and Apple endpoints and exercises Latest changes: The latest commit moves the Apple host override out of the CLI template and copies it into only the e2e-generated build, replacing the e2e-tag build with a standard build.
📂 Walkthrough · 5
Reviewed the commits since |
…PLE_HOST The e2e tests run init apns against a mock of Apple, so the sign-in, App Store Connect and Developer portal hosts can all be set to one base URL. Unset, they stay Apple's servers.
The mock API gains Apple's sign-in, session, team, key and App ID endpoints under /apple, kept per Apple ID. The harness signs in with an Apple ID and password, creates the key and registers the App ID, then reuses the saved sign-in to check the App ID on a rerun, turn on Push Notifications for an existing App ID, and create keys until the team has no free slot.
…ns-apple-e2e test(cli): e2e for init apns against a mock of Apple
APPWRITE_APPLE_HOST could send an Apple ID and password to any server from the shipped CLI. It now lives in a file built only with the e2e tag, which the CLI e2e suite passes; release builds always talk to Apple.
The findings that requested changes are resolved. See the summary comment for what is still open.
| @@ -0,0 +1,20 @@ | |||
| //go:build e2e | |||
There was a problem hiding this comment.
can this file be test only? meaning it only loads for local testing and not in the released sdk. i think we already have a pattern for this
There was a problem hiding this comment.
Yes, done in 869867e, following the same pattern as the conformance harness: the file moved to tests/e2e/languages/cli/applehosts.go, and CLIGo126Test copies it into the generated CLI's internal/cmd before go build. It's no longer in getFiles(), so the generated SDK doesn't contain it, and the build tag is gone. What's left in the SDK is the e2eAppleHosts hook, which is nil unless that file is present, so a released CLI always uses Apple's hosts.
The override is no longer generated into the SDK. Like the conformance harness, it lives under tests/e2e/languages/cli and CLIGo126Test copies it into the generated CLI before building, so released SDKs never contain it.
dfaebd0
into
messaging-provider-cli-init-apns
What does this PR do?
Adds e2e coverage for
appwrite init apns(#2015) to the CLI suite,Tests / CLIGo126. Stacked on #2015.Mock API
mock-server/app/http.phpgains the endpointsinit apnscalls:GET /v1/messaging/providersproviderquery, as the CLI asksPOST /v1/messaging/providers/apnsPATCH /v1/messaging/providers/apns/:providerIdGET /v1/project/platformsPOST /v1/project/platforms/applebundleIdentifierThe state is kept per project (
x-appwrite-project) in a file, because the Swoole workers share no memory and a rerun has to see what the first run created.Mock Apple
The CLI gains a hidden
APPWRITE_APPLE_HOSTvariable that points Apple's sign-in, App Store Connect and Developer portal at one base URL. When it's unset, the CLI uses Apple's servers. The mock API serves Apple under/apple, with state kept per Apple ID:E2ETEAM123..p8..nopushalready exists with Push Notifications off.Harness
tests/e2e/languages/cli/main.goruns the built binary in a temporary project folder holding anappwrite.config.jsonand a generated.p8key. It checks what the binary prints and its exit status, then printsCLI_INIT_APNS:passed:--key-path,--team-id,--bundle-id). It creates both APNs providers and the Apple platform, and prints the next steps (the Appwrite push provider, and the Notification Service Extension). The App ID check is skipped, since there's no terminal and no Apple sign-in.--bundle-id, an unknown--provider, and an unknown--environmenteach fail.Harness: Apple (
CLI_INIT_APNS_APPLE:passed)APPWRITE_APPLE_IDandAPPWRITE_APPLE_PASSWORD, creates the key (saved into the project folder), creates both providers and registers the App ID with Push Notifications.--register-app-idturns on Push Notifications for an existing App ID.Not covered
Apple's password check (SRP verification) and the two-factor prompt, which needs a terminal, are covered by the Go tests against a fake Apple server (
internal/apns/appwrite/adapter_test.go). Expo and fastlane run Apple's own tools.Test Plan
gofmtandgo veton the harness;php -lon the mock API;go build,go vetandgo test ./internal/...on the generated CLI; Generation suite and Twig lint.Tests / CLIGo126on CI. Per the repository's practice, the Docker e2e runs on CI only.Related PRs and Issues
appwrite init apns).