6270d8c956
Testing / remote-protocol-compat (0.16.0) (push) Successful in 1m1s
Testing / remote-protocol-compat (0.15.0) (push) Successful in 1m3s
Testing / test (push) Failing after 1m15s
Build & Publish Package / publish (push) Successful in 51s
Package Extension / package-extension (push) Successful in 1m6s
- Add SSH-style server identity keys and known-host verification for remote serve endpoints. - Add remote add/list/remove commands for explicit endpoint persistence. - Fix remote clients listing to fan out through target discovery instead of ambiguous auto-routing. - Add URL glob matching for tabs filter and count with extension tests. - Add n8n credential pinning for server public keys or SHA256 fingerprints. - Remove obsolete compat shim behavior while keeping empty compat seams for future protocol changes. - Bump browser-cli to 0.16.4 and n8n node to 0.3.1. - Cover known-hosts, remote registry, compat seams, n8n protocol verification, and URL matching with tests.
49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
"""Compat shim framework.
|
|
|
|
The registries are empty today (no legacy-client shim has been needed since the
|
|
first public release, 0.14.1), so every adapter must be a verbatim pass-through
|
|
regardless of client version. These tests lock that in and exercise the
|
|
empty-registry short-circuit so the seam can't silently start mutating traffic.
|
|
"""
|
|
import browser_cli.compat as compat
|
|
from browser_cli.compat import adapt_auth, adapt_request, adapt_response
|
|
|
|
def test_registries_are_empty():
|
|
assert compat.commands._COMPAT == []
|
|
assert compat.auth._AUTH_COMPAT == []
|
|
|
|
def test_adapt_auth_is_passthrough_for_any_version():
|
|
msg = {"id": "1", "command": "tabs.list", "pubkey": "ABCdef", "args": {"x": 1}}
|
|
for version in ("0.9.0", "0.14.1", "0.16.4", "99.0.0"):
|
|
out = adapt_auth(msg, version)
|
|
assert out == msg
|
|
# pubkey casing is NOT normalized anymore (the old <0.9.3 shim is gone)
|
|
assert out["pubkey"] == "ABCdef"
|
|
|
|
def test_adapt_request_is_passthrough():
|
|
msg = {"command": "tabs.query", "args": {"search": "docs"}}
|
|
assert adapt_request(msg, "0.9.0") == msg
|
|
assert adapt_request(msg, "0.16.4") == msg
|
|
|
|
def test_adapt_response_is_passthrough():
|
|
resp = b'{"id":"1","success":true,"data":[]}'
|
|
assert adapt_response(resp, "tabs.list", "0.9.0") == resp
|
|
assert adapt_response(resp, "tabs.list", "0.16.4") == resp
|
|
|
|
def test_empty_guard_skips_version_parsing(monkeypatch):
|
|
"""With empty registries the adapters return before parse_version runs."""
|
|
called = False
|
|
|
|
def _boom(_v):
|
|
nonlocal called
|
|
called = True
|
|
raise AssertionError("parse_version should not be called on an empty registry")
|
|
|
|
monkeypatch.setattr(compat.auth, "parse_version", _boom)
|
|
monkeypatch.setattr(compat.commands, "parse_version", _boom)
|
|
|
|
assert adapt_auth({"a": 1}, "0.9.0") == {"a": 1}
|
|
assert adapt_request({"a": 1}, "0.9.0") == {"a": 1}
|
|
assert adapt_response(b"x", "cmd", "0.9.0") == b"x"
|
|
assert called is False
|