You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
motief/tests/validators/test_validator_edgecases.py

56 lines
1.6 KiB

import os
from pathlib import Path
from src.validators.mindmodel_validator import validate_manifest
def test_missing_files_reported(tmp_path):
# create two paths that do not exist
p1 = str(tmp_path / "missing_one.txt")
p2 = str(tmp_path / "missing_two.txt")
manifest = f"""
files:
- path: {p1}
- path: {p2}
"""
mpath = tmp_path / "manifest_missing.yaml"
mpath.write_text(manifest, encoding="utf-8")
report = validate_manifest(str(mpath))
assert "missing_files" in report
# both missing paths should be reported
assert p1 in report["missing_files"]
assert p2 in report["missing_files"]
def test_truncated_evidence_and_secrets_reported(tmp_path):
# entry with truncated evidence (ends with ...)
trunc_path = str(tmp_path / "trunc.txt")
trunc_evidence = "This output was cut off..."
# entry with potential secret (contains PASSWORD)
secret_path = str(tmp_path / "secret.txt")
secret_evidence = "Found PASSWORD=sekret123 in the logs"
manifest = f"""
files:
- path: {trunc_path}
evidence_excerpt: "{trunc_evidence}"
- path: {secret_path}
evidence_excerpt: "{secret_evidence}"
"""
mpath = tmp_path / "manifest_edgecases.yaml"
mpath.write_text(manifest, encoding="utf-8")
report = validate_manifest(str(mpath))
# truncated evidence should report the trunc_path
assert "truncated_evidence" in report
assert any(item.get("path") == trunc_path for item in report["truncated_evidence"])
# potential secrets should report the secret_path
assert "potential_secrets" in report
assert any(item.get("path") == secret_path for item in report["potential_secrets"])