-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add createApnsBroadcast (RSH1d) and liveActivity methods in PushAdmin
#500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ttypic
wants to merge
1
commit into
main
Choose a base branch
from
AIT-794/live-activity
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+621
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,204 @@ | ||
| # PushAdmin createApnsBroadcast Tests | ||
|
|
||
| Spec points: `RSH1`, `RSH1d` | ||
|
|
||
| ## Test Type | ||
| Unit test with mocked HTTP client | ||
|
|
||
| ## Mock HTTP Infrastructure | ||
|
|
||
| See `uts/test/rest/unit/helpers/mock_http.md` for the full Mock HTTP Infrastructure specification. | ||
|
|
||
| --- | ||
|
|
||
| ## RSH1d — createApnsBroadcast sends POST to /push/apnsBroadcastChannels | ||
|
|
||
| **Test ID**: `rest/unit/RSH1d/create-apns-broadcast-post-0` | ||
|
|
||
| **Spec requirement:** RSH1d — `createApnsBroadcast(options)` issues a `POST` request to `/push/apnsBroadcastChannels`. | ||
|
|
||
| Tests that `push.admin.createApnsBroadcast()` sends a POST to the correct path. | ||
|
|
||
| ### Setup | ||
| ```pseudo | ||
| captured_requests = [] | ||
|
|
||
| mock_http = MockHttpClient( | ||
| onConnectionAttempt: (conn) => conn.respond_with_success(), | ||
| onRequest: (req) => { | ||
| captured_requests.append(req) | ||
| req.respond_with(201, { "id": "broadcast-1", "apnsChannelId": "apns-1" }) | ||
| } | ||
| ) | ||
| install_mock(mock_http) | ||
|
|
||
| client = Rest(options: ClientOptions(key: "appId.keyId:keySecret")) | ||
| ``` | ||
|
|
||
| ### Test Steps | ||
| ```pseudo | ||
| AWAIT client.push.admin.createApnsBroadcast( | ||
| options: { "messageStoragePolicy": 1 } | ||
| ) | ||
| ``` | ||
|
|
||
| ### Assertions | ||
| ```pseudo | ||
| ASSERT captured_requests.length == 1 | ||
|
|
||
| request = captured_requests[0] | ||
| ASSERT request.method == "POST" | ||
| ASSERT request.url.path == "/push/apnsBroadcastChannels" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## RSH1d — createApnsBroadcast body contains messageStoragePolicy | ||
|
|
||
| **Test ID**: `rest/unit/RSH1d/message-storage-policy-1` | ||
|
|
||
| **Spec requirement:** RSH1d — the request body contains the `messageStoragePolicy`. | ||
|
|
||
| Tests that the supplied `messageStoragePolicy` is serialized into the request body. | ||
|
|
||
| ### Setup | ||
| ```pseudo | ||
| captured_requests = [] | ||
|
|
||
| mock_http = MockHttpClient( | ||
| onConnectionAttempt: (conn) => conn.respond_with_success(), | ||
| onRequest: (req) => { | ||
| captured_requests.append(req) | ||
| req.respond_with(201, { "id": "broadcast-1", "apnsChannelId": "apns-1" }) | ||
| } | ||
| ) | ||
| install_mock(mock_http) | ||
|
|
||
| client = Rest(options: ClientOptions(key: "appId.keyId:keySecret")) | ||
| ``` | ||
|
|
||
| ### Test Steps | ||
| ```pseudo | ||
| AWAIT client.push.admin.createApnsBroadcast( | ||
| options: { "messageStoragePolicy": 0 } | ||
| ) | ||
| ``` | ||
|
|
||
| ### Assertions | ||
| ```pseudo | ||
| ASSERT captured_requests.length == 1 | ||
|
|
||
| body = parse_json(captured_requests[0].body) | ||
| ASSERT body["messageStoragePolicy"] == 0 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## RSH1d — createApnsBroadcast returns id and apnsChannelId | ||
|
|
||
| **Test ID**: `rest/unit/RSH1d/returns-ids-2` | ||
|
|
||
| **Spec requirement:** RSH1d — returns the created broadcast as `{ id, apnsChannelId }`. | ||
|
|
||
| Tests that the `id` and `apnsChannelId` are parsed from the response body and returned. | ||
|
|
||
| ### Setup | ||
| ```pseudo | ||
| mock_http = MockHttpClient( | ||
| onConnectionAttempt: (conn) => conn.respond_with_success(), | ||
| onRequest: (req) => req.respond_with(201, { | ||
| "id": "broadcast-xyz", | ||
| "apnsChannelId": "apple-channel-abc" | ||
| }) | ||
| ) | ||
| install_mock(mock_http) | ||
|
|
||
| client = Rest(options: ClientOptions(key: "appId.keyId:keySecret")) | ||
| ``` | ||
|
|
||
| ### Test Steps | ||
| ```pseudo | ||
| result = AWAIT client.push.admin.createApnsBroadcast( | ||
| options: { "messageStoragePolicy": 1 } | ||
| ) | ||
| ``` | ||
|
|
||
| ### Assertions | ||
| ```pseudo | ||
| ASSERT result.id == "broadcast-xyz" | ||
| ASSERT result.apnsChannelId == "apple-channel-abc" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## RSH1d — createApnsBroadcast request includes an auth header | ||
|
|
||
| **Test ID**: `rest/unit/RSH1d/auth-header-3` | ||
|
|
||
| **Spec requirement:** RSH1d — the request is authenticated. | ||
|
|
||
| Tests that the request carries a Basic authorization header derived from the API key. | ||
|
|
||
| ### Setup | ||
| ```pseudo | ||
| captured_requests = [] | ||
|
|
||
| mock_http = MockHttpClient( | ||
| onConnectionAttempt: (conn) => conn.respond_with_success(), | ||
| onRequest: (req) => { | ||
| captured_requests.append(req) | ||
| req.respond_with(201, { "id": "broadcast-1", "apnsChannelId": "apns-1" }) | ||
| } | ||
| ) | ||
| install_mock(mock_http) | ||
|
|
||
| client = Rest(options: ClientOptions(key: "appId.keyId:keySecret")) | ||
| ``` | ||
|
|
||
| ### Test Steps | ||
| ```pseudo | ||
| AWAIT client.push.admin.createApnsBroadcast( | ||
| options: { "messageStoragePolicy": 1 } | ||
| ) | ||
| ``` | ||
|
|
||
| ### Assertions | ||
| ```pseudo | ||
| ASSERT captured_requests.length == 1 | ||
| ASSERT captured_requests[0].headers["Authorization"] STARTS_WITH "Basic " | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## RSH1d — createApnsBroadcast propagates server error | ||
|
|
||
| **Test ID**: `rest/unit/RSH1d/server-error-4` | ||
|
|
||
| **Spec requirement:** RSH1d — a server error response is propagated to the caller. | ||
|
|
||
| Tests that an error response from the server is surfaced to the caller. | ||
|
|
||
| ### Setup | ||
| ```pseudo | ||
| mock_http = MockHttpClient( | ||
| onConnectionAttempt: (conn) => conn.respond_with_success(), | ||
| onRequest: (req) => req.respond_with(400, { | ||
| "error": { | ||
| "code": 40000, | ||
| "statusCode": 400, | ||
| "message": "Invalid request" | ||
| } | ||
| }) | ||
| ) | ||
| install_mock(mock_http) | ||
|
|
||
| client = Rest(options: ClientOptions(key: "appId.keyId:keySecret")) | ||
| ``` | ||
|
|
||
| ### Test Steps and Assertions | ||
| ```pseudo | ||
| AWAIT client.push.admin.createApnsBroadcast( | ||
| options: { "messageStoragePolicy": 1 } | ||
| ) FAILS WITH error | ||
| ASSERT error.code == 40000 | ||
| ``` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we combine several of these tests? They're doing the same thing, just with different assertions