ably/specification#507 fixes several UTS spec errors that the test/uts suite currently works around with local adaptations. Once it merges, a few derived tests should be re-translated from the corrected spec text (per the spec-first process in uts/docs/writing-derived-tests.md). Blocked on ably/specification#507 — nothing to do until that lands.
Context: the spec errors were confirmed while deriving the same UTS tests in ably-rust; where ably-js and ably-rust behaviour differed, the features spec was used as the authority (details in the spec PR).
1. RTN15h1 unit test — add the missing errorReason.code assertion
test/uts/realtime/unit/connection/connection_failures.test.ts (~line 414, RTN15h1 - token error without renewal causes FAILED) asserts FAILED and errorReason non-null but omits the code check. The UTS spec asserted 40142 (pass-through), which contradicted RSA4a2 and the proxy spec; #507 corrects it to 40171. Add:
expect(client.connection.errorReason!.code).to.equal(40171);
expect(client.connection.errorReason!.statusCode).to.equal(401);
(The proxy test connection_resume.test.ts ~line 447 already asserts 40171 — this makes the unit test consistent. ably-js already implements the 40171 substitution, so this should pass as-is.)
2. RTP15c — re-translate to the corrected two-client shape
test/uts/realtime/unit/presence/realtime_presence_enter.test.ts (~line 962, RTP15c - enterClient has no side effects on normal enter). The UTS setup used clientId: "*" in ClientOptions, which RSA7c forbids; the current ably-js adaptation uses an identified client (clientId: 'admin') calling enterClient('other-user'). That only passes because ably-js performs no client-side RTP15f check — per RTP15f an identified client's enterClient with a different clientId must indicate an error (client-side or via server NACK), so with a real server this flow would NACK.
#507 rewrites the spec test with two clients — an identified client doing the plain enter(), and an unidentified (key-auth, no clientId) client doing enterClient/leaveClient — since per RTP8j + RTP15f no single clientId permits both operations. Re-translate to that shape.
3. RTP8j wildcard test — re-translate to the wildcard-token setup
Same file, ~line 309 (RTP8j - enter with wildcard clientId errors). The current adaptation asserts that new Ably.Realtime({clientId: '*'}) throws at construction — that validates RSA7c, not RTP8j (the test never reaches enter()). #507 changes the spec setup to obtain the wildcard state the way it actually arises: token auth with a TokenDetails whose clientId is "*", then asserting enter() errors while CONNECTED. Re-translate accordingly (a separate RSA7c construction-time test is still worthwhile if not already covered elsewhere).
4. Comment refresh on the enterClient-only tests (no behaviour change)
The tests at ~lines 542-1202 already use key auth without clientId (// Use key auth without clientId (instead of wildcard "*")) — #507 makes that the spec's normative setup rather than an ably-js adaptation, so the NOTE comments describing it as a deviation from the spec can be removed/simplified.
5. FYI — RSP5g fixture now usable
test/uts/rest/unit/presence/rest_presence.test.ts has the RSP5g cipher test skipped (TODO: Implement when cipher infrastructure is available). The spec's encrypted_data fixture was a corrupt truncation of the canonical ably-common value — anyone implementing the test against the old string would decrypt garbage. #507 restores the canonical 48-byte string (test-resources/crypto-data-128.json, the {"example":{"json":"Object"}} item) and adds a value-level assertion, so the TODO is unblocked whenever cipher test infrastructure exists.
🤖 Generated with Claude Code
┆Issue is synchronized with this Jira Task by Unito
ably/specification#507 fixes several UTS spec errors that the
test/utssuite currently works around with local adaptations. Once it merges, a few derived tests should be re-translated from the corrected spec text (per the spec-first process inuts/docs/writing-derived-tests.md). Blocked on ably/specification#507 — nothing to do until that lands.Context: the spec errors were confirmed while deriving the same UTS tests in ably-rust; where ably-js and ably-rust behaviour differed, the features spec was used as the authority (details in the spec PR).
1. RTN15h1 unit test — add the missing errorReason.code assertion
test/uts/realtime/unit/connection/connection_failures.test.ts(~line 414,RTN15h1 - token error without renewal causes FAILED) asserts FAILED anderrorReasonnon-null but omits the code check. The UTS spec asserted40142(pass-through), which contradicted RSA4a2 and the proxy spec; #507 corrects it to40171. Add:(The proxy test
connection_resume.test.ts~line 447 already asserts 40171 — this makes the unit test consistent. ably-js already implements the 40171 substitution, so this should pass as-is.)2. RTP15c — re-translate to the corrected two-client shape
test/uts/realtime/unit/presence/realtime_presence_enter.test.ts(~line 962,RTP15c - enterClient has no side effects on normal enter). The UTS setup usedclientId: "*"in ClientOptions, which RSA7c forbids; the current ably-js adaptation uses an identified client (clientId: 'admin') callingenterClient('other-user'). That only passes because ably-js performs no client-side RTP15f check — per RTP15f an identified client'senterClientwith a different clientId must indicate an error (client-side or via server NACK), so with a real server this flow would NACK.#507 rewrites the spec test with two clients — an identified client doing the plain
enter(), and an unidentified (key-auth, no clientId) client doingenterClient/leaveClient— since per RTP8j + RTP15f no single clientId permits both operations. Re-translate to that shape.3. RTP8j wildcard test — re-translate to the wildcard-token setup
Same file, ~line 309 (
RTP8j - enter with wildcard clientId errors). The current adaptation asserts thatnew Ably.Realtime({clientId: '*'})throws at construction — that validates RSA7c, not RTP8j (the test never reachesenter()). #507 changes the spec setup to obtain the wildcard state the way it actually arises: token auth with aTokenDetailswhoseclientIdis"*", then assertingenter()errors while CONNECTED. Re-translate accordingly (a separate RSA7c construction-time test is still worthwhile if not already covered elsewhere).4. Comment refresh on the enterClient-only tests (no behaviour change)
The tests at ~lines 542-1202 already use key auth without clientId (
// Use key auth without clientId (instead of wildcard "*")) — #507 makes that the spec's normative setup rather than an ably-js adaptation, so the NOTE comments describing it as a deviation from the spec can be removed/simplified.5. FYI — RSP5g fixture now usable
test/uts/rest/unit/presence/rest_presence.test.tshas the RSP5g cipher test skipped (TODO: Implement when cipher infrastructure is available). The spec'sencrypted_datafixture was a corrupt truncation of the canonical ably-common value — anyone implementing the test against the old string would decrypt garbage. #507 restores the canonical 48-byte string (test-resources/crypto-data-128.json, the{"example":{"json":"Object"}}item) and adds a value-level assertion, so the TODO is unblocked whenever cipher test infrastructure exists.🤖 Generated with Claude Code
┆Issue is synchronized with this Jira Task by Unito