diff options
Diffstat (limited to 'packages/meshbay-hub/tests/test_session_renewal.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_session_renewal.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/meshbay-hub/tests/test_session_renewal.py b/packages/meshbay-hub/tests/test_session_renewal.py index 7b8c108..ecf9ac5 100644 --- a/packages/meshbay-hub/tests/test_session_renewal.py +++ b/packages/meshbay-hub/tests/test_session_renewal.py @@ -50,7 +50,7 @@ pytestmark = pytest.mark.skipif( def _run(scenario: str, app: Path = APP) -> dict: proc = subprocess.run( ["node", str(HARNESS), str(app), json.dumps({"scenario": scenario})], - capture_output=True, text=True, timeout=60) + capture_output=True, text=True, encoding="utf-8", timeout=60) assert proc.returncode == 0, f"{proc.stdout}\n{proc.stderr}" return json.loads(proc.stdout.strip().splitlines()[-1]) @@ -59,14 +59,14 @@ def _run(scenario: str, app: Path = APP) -> dict: def broken(tmp_path_factory): """The client as it shipped: the rotated refresh token dropped.""" out = tmp_path_factory.mktemp("session") / "broken.js" - src = APP.read_text() + src = APP.read_text(encoding="utf-8") replaced = src.replace( " refreshToken: data.refresh_token || _auth.refreshToken,", " refreshToken: _auth.refreshToken,") assert replaced != src, ( "could not reconstruct the defect — the line it hinged on has moved, " "and the A/B below would be comparing the fix against itself") - out.write_text(replaced) + out.write_text(replaced, encoding="utf-8") return out @@ -186,13 +186,13 @@ def test_the_session_is_much_longer_than_the_token(): def test_renewal_happens_before_expiry_not_after(): """A margin, so the first click after a long film does not pay for a 401.""" - src = APP.read_text() + src = APP.read_text(encoding="utf-8") import re margin = int(re.search(r"const TOKEN_RENEW_MARGIN_S = (\d+)", src).group(1)) assert margin >= 300, ( f"{margin} s of margin against a one-hour token is thin: a backgrounded " "tab has its timers throttled and may not check for minutes") - assert "visibilitychange" in APP_JS.read_text(), ( + assert "visibilitychange" in APP_JS.read_text(encoding="utf-8"), ( "nothing re-checks when the tab comes back, which is exactly when the " "token is most likely to have aged out unnoticed") @@ -213,7 +213,7 @@ def test_renewing_does_not_tear_down_the_webrtc_connection(): Signing in or out must still re-run it, so the dependency is whether there is a token, not which one. """ - src = GROUP_PAGE.read_text() + src = GROUP_PAGE.read_text(encoding="utf-8") i = src.index("means tearing down the WebRTC connection") deps = src[i:src.index(");", i)] assert "Boolean(token)" in deps, ( @@ -228,7 +228,7 @@ def test_the_connection_signs_its_offer_with_a_live_token(): It signs the offer relayed through the hub, where an expired one is a 401 and no connection at all. """ - src = GROUP_PAGE.read_text() + src = GROUP_PAGE.read_text(encoding="utf-8") connect = src[src.index("const connect = async () => {"):] connect = connect[:connect.index("\n };")] assert "await ensureFreshToken()" in connect, ( |