test V2R1C5 privacy migrator reset parsing
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from __future__ import annotations
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
SOURCE=Path(__file__).parents[2]/"tools"/"v2r1c4_owner_privacy_snapshot.py"
|
||||
spec=importlib.util.spec_from_file_location("privacy_snapshot",SOURCE); module=importlib.util.module_from_spec(spec); assert spec.loader; spec.loader.exec_module(module)
|
||||
|
||||
def test_privacy_migrator_accepts_rfc3339_fractional_seconds(tmp_path):
|
||||
raw=b"owner@example.invalid"; names=["state.jsonl.reset.2026-07-16T06-46-12Z","state.jsonl.reset.2026-07-16T06-46-12.4Z","state.jsonl.reset.2026-07-16T06-46-12.490123Z"]
|
||||
for name in names:
|
||||
path=tmp_path/name; path.write_bytes(raw); assert module.is_valid_reset_filename(name); assert module.replace_file(path,raw,b"principal:pseudonym") == 1; assert path.read_bytes()==b"principal:pseudonym"
|
||||
|
||||
def test_privacy_migrator_rejects_malformed_suffix(tmp_path):
|
||||
raw=b"owner@example.invalid"
|
||||
for name in ("state.jsonl.reset.2026-07-16T06-46-12.490X","state.jsonl.reset.2026-07-16T06-46-12.1234567890Z","state.jsonl.reset.2026-99-99T06-46-12Z"):
|
||||
path=tmp_path/name; path.write_bytes(raw); assert not module.is_valid_reset_filename(name)
|
||||
with pytest.raises(module.MigrationBlocked,match="raw_owner_in_unapproved_binary_file"): module.replace_file(path,raw,b"principal:pseudonym")
|
||||
|
||||
def test_binary_allowlist_fails_closed(tmp_path):
|
||||
path=tmp_path/"owner.bin"; raw=b"owner@example.invalid"; path.write_bytes(raw)
|
||||
with pytest.raises(module.MigrationBlocked,match="raw_owner_in_unapproved_binary_file"): module.replace_file(path,raw,b"principal:pseudonym")
|
||||
Reference in New Issue
Block a user