Repository navigation
UTS: answer batch publish and revokeTokens mocks with the BatchResult envelope - #589
Open
owenpearson wants to merge 2 commits into
Open
owenpearson wants to merge 2 commits into
owenpearson wants to merge 2 commits into
Conversation
batch_publish.md mocked the response the server sends below protocol version 3: a bare per-channel result, or a flat array of them. At the CSV2b version POST /messages returns HTTP 201 and an array holding one BatchResult envelope per BatchPublishSpec, which is what RSC22b means by "the response will still be an array". Add a Server Response Format section, wrap every batch result fixture in the envelope (RSC22c3, RSC22c4, RSC22c5, BPR2a, BPR2b, BPR2c, BPR2c1, BPF2a, BPF2b, BatchResult1, RSC22_Batch2), read the BPR/BPF fields through result.results[0], and check RSC22_Headers1's X-Ably-Version against a pattern of at least 5 instead of pinning 2, the version that gets the legacy format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eleven revokeTokens mocks stubbed HTTP 200 and a bare array of results, the legacy format the file's own Server Response Format section says no current SDK sees, while RSA17c_1 and TRS2_1 assert envelope fields. Wrap them in a single BatchResult envelope with HTTP 201, as the header describes, and do the same to the two unreachable RSA17d mocks. RSA17c_2's mixed response is also moved from 200 to 201, which is what the header and the server give for a mixed batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #559
Stacked on #537 (
fix/uts-publish-body-assertions) and must merge after it. #537 pinsuseBinaryProtocol: falsein the body-reading sections of these same two files, RSC22_Headers1 included, so itsContent-Type: application/jsonline is already consistent and is not touched here.What was wrong
batch_publish.mdmocked the response the server sends below protocol version 3: a bare per-channel result object, or a flat array of per-channel results, and RSC22_Headers1 pinnedX-Ably-Version: 2, the version that gets that format. An SDK that sends the CSV2b protocol version (RSC7e) and returnsBatchResults as RSC22b says cannot pass those mocks, and one that passes them is parsing a response it will never receive.revoke_tokens.mdhad the same fault in the mocks that answer an all-success batch.The shape
Measured against the sandbox in #559, and used by ably-python's batch publish (ably/ably-pubsub-python#727), which sends version 5:
POST /messagesreturns HTTP 201 and an array holding oneBatchResultenvelope perBatchPublishSpec, each{successCount, failureCount, results}(BAR2). A single spec sent as a bare object gets an array of one, which is the array RSC22b says the REST API still returns. All-success, mixed and all-failure batches all answer 201 in this format.serials(BPR2c) was added to the spec at protocol version 5, so the fixtures here are the version 5 response.revokeTokensreturns oneBatchResult(RSA17c), not one per spec, so its mocks become a single envelope object, as the file's existing Server Response Format section and its RSA17c_2/RSA17c_3/TRF2_1 mocks already show.Changes
uts/rest/unit/batch_publish.mdbatch_presence.md's, describing the envelope array, the single-spec case, status codes,serials, and the legacy format (version 2 or below: one flat array across all specs, noserials, 400/40020 withbatchResponsewhen any channel fails).successCount: 1, failureCount: 1) and RSC22_Batch2. RSC22c5 and RSC22_Batch2 previously said only "respond with results for each channel"; they now give the fixture.batchPublishand read the fields throughresult.results[0]; BatchResult1 readsresult.results[0]/[1]rather thanresult[0]/[1]. RSC22c4 names its two specs so "each result corresponds to the respective spec" can be checked.X-Ably-Versionis the CSV2b version, matching[0-9]+and at least 5, instead of2.uts/rest/unit/auth/revoke_tokens.md200with a bare array of results (RSA17g_1, RSA17b_1, RSA17b_2, RSA17c_1, TRS2_1, RSA17e_1, RSA17e_2, RSA17f_1, RSA17f_2, RSA17f_3, RSA17_Auth_1) now answer201with aBatchResultenvelope. The issue named two of them (RSA17c_1 and TRS2_1, which assert envelope fields); the other nine only read the request, but carried the same legacy body.200, []) are never reached, since token auth is rejected before any request; they get an empty envelope so no legacy body is left in the file.No Test IDs changed.
npm run lintpasses.🤖 Generated with Claude Code