mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-12 23:10:59 +01:00
Some checks are pending
crdt_sync_dart tests / test (push) Waiting to run
crdt_sync_flutter tests / test (push) Waiting to run
crdt-sync pre-commit / pre-commit (push) Waiting to run
crdt-sync tests / test (push) Waiting to run
dependency freshness / dependencies on newest stable (push) Waiting to run
design_system tests / test (push) Waiting to run
file length / file-length (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
palette drift / palette (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
shared gate tests / gate unit tests (push) Waiting to run
sync_settings_ui tests / test (push) Waiting to run
Byte-compatible with crdt_sync_dart 0.14.0, proven by golden vectors in both directions. EncryptingStore, -e2e layout, one-time copy, and open_encrypted_client for the Python daemons. Dev pins bumped. Todo: fda71ed1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
# Copyright (c) 2026 Krzysztof Rudnicki
|
|
"""tool/e2e_vectors writes vectors that Python itself can open."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
import runpy
|
|
|
|
import pytest
|
|
|
|
from crdt_sync import open_log_text, unlock_e2e
|
|
from crdt_sync.tests.conftest import FakeStore
|
|
from tool import e2e_vectors
|
|
|
|
|
|
def test_vectors_open_with_the_stated_passphrase() -> None:
|
|
vec = e2e_vectors.vectors()
|
|
key = unlock_e2e(
|
|
FakeStore({"vec/e2e": str(vec["header"])}),
|
|
path_prefix="vec/notes-e2e",
|
|
passphrase=str(vec["passphrase"]),
|
|
e2e_path="vec/e2e",
|
|
)
|
|
assert key.master.hex() == vec["master_hex"]
|
|
path = str(vec["path"])
|
|
opened = open_log_text(str(vec["envelope"]), key.cipher(), path=path)
|
|
assert json.loads(opened) == json.loads(str(vec["log"]))
|
|
assert open_log_text(str(vec["whole"]), key.cipher(), path=path) == "not a log"
|
|
|
|
|
|
def test_main_prints_json(capsys: pytest.CaptureFixture[str]) -> None:
|
|
assert e2e_vectors.main() == 0
|
|
assert "master_hex" in json.loads(capsys.readouterr().out)
|
|
|
|
|
|
def test_module_entry_point(capsys: pytest.CaptureFixture[str]) -> None:
|
|
with pytest.raises(SystemExit) as exc:
|
|
runpy.run_path(str(Path(e2e_vectors.__file__)), run_name="__main__")
|
|
assert exc.value.code == 0
|
|
assert "envelope" in capsys.readouterr().out
|