{
"file": "frontend/src/components/__tests__/task_log_viewer.test.js",
"verdict": "APPROVED",
"rejection_reason": "NONE",
"audit_details": {
"target_invoked": true,
"pre_conditions_tested": true,
"post_conditions_tested": true,
"test_fixture_used": true,
"edges_covered": true,
"invariants_verified": true,
"ux_states_tested": true,
"semantic_anchors_present": true
},
"coverage_summary": {
"total_edges": 2,
"edges_tested": 2,
"total_invariants": 1,
"invariants_tested": 1,
"total_ux_states": 3,
"ux_states_tested": 3
},
"tier_compliance": {
"source_tier": "CRITICAL",
"meets_tier_requirements": true
},
"feedback": "Remediation successful: test tier matches CRITICAL, missing missing @TEST_EDGE no_task_id coverage added, test for @UX_FEEDBACK (autoScroll) added properly, missing inline=false (show=true) tested properly. Semantic RELATION tag fixed to VERIFIES."
},
{
"file": "frontend/src/lib/components/reports/__tests__/report_card.ux.test.js",
"verdict": "APPROVED",
"rejection_reason": "NONE",
"audit_details": {
"target_invoked": true,
"pre_conditions_tested": true,
"post_conditions_tested": true,
"test_fixture_used": true,
"edges_covered": true,
"invariants_verified": true,
"ux_states_tested": true,
"semantic_anchors_present": true
},
"coverage_summary": {
"total_edges": 2,
"edges_tested": 2,
"total_invariants": 1,
"invariants_tested": 1,
"total_ux_states": 2,
"ux_states_tested": 2
},
"tier_compliance": {
"source_tier": "CRITICAL",
"meets_tier_requirements": true
},
"feedback": "Remediation successful: @TEST_EDGE random_status and @TEST_EDGE empty_report_object tests explicitly assert on outcomes, @TEST_FIXTURE tested completely, Test tier switched to CRITICAL."
},
{
"file": "backend/tests/test_logger.py",
"verdict": "APPROVED",
"rejection_reason": "NONE",
"audit_details": {
"target_invoked": true,
"pre_conditions_tested": true,
"post_conditions_tested": true,
"test_fixture_used": true,
"edges_covered": true,
"invariants_verified": true,
"ux_states_tested": false,
"semantic_anchors_present": true
},
"coverage_summary": {
"total_edges": 0,
"edges_tested": 0,
"total_invariants": 0,
"invariants_tested": 0,
"total_ux_states": 0,
"ux_states_tested": 0
},
"tier_compliance": {
"source_tier": "STANDARD",
"meets_tier_requirements": true
},
"feedback": "Remediation successful: Test module semantic anchors added [DEF] and [/DEF] explicitly. Added missing @TIER tag and @RELATION: VERIFIES -> src/core/logger.py at the top of the file."
}
]
145 lines
6.0 KiB
Python
145 lines
6.0 KiB
Python
# [DEF:backend.tests.services.clean_release.test_policy_engine:Module]
|
|
# @TIER: CRITICAL
|
|
# @SEMANTICS: tests, clean-release, policy-engine, deterministic
|
|
# @PURPOSE: Validate policy model contracts and deterministic classification prerequisites for US1.
|
|
# @LAYER: Domain
|
|
# @RELATION: VERIFIES -> backend.src.models.clean_release.CleanProfilePolicy
|
|
# @INVARIANT: Enterprise policy rejects invalid activation states.
|
|
|
|
import pytest
|
|
from datetime import datetime, timezone
|
|
|
|
from src.models.clean_release import CleanProfilePolicy, ProfileType
|
|
|
|
|
|
# [DEF:test_policy_enterprise_clean_valid:Function]
|
|
# @PURPOSE: Ensure valid enterprise policy payload is accepted.
|
|
# @PRE: Fixture-like payload contains prohibited categories and registry ref.
|
|
# @POST: Model is created with external_source_forbidden=True.
|
|
def test_policy_enterprise_clean_valid():
|
|
policy = CleanProfilePolicy(
|
|
policy_id="policy-enterprise-clean-v1",
|
|
policy_version="1.0.0",
|
|
active=True,
|
|
prohibited_artifact_categories=["test-data", "demo-data"],
|
|
required_system_categories=["system-init"],
|
|
external_source_forbidden=True,
|
|
internal_source_registry_ref="registry-internal-v1",
|
|
effective_from=datetime.now(timezone.utc),
|
|
profile=ProfileType.ENTERPRISE_CLEAN,
|
|
)
|
|
assert policy.external_source_forbidden is True
|
|
assert policy.prohibited_artifact_categories == ["test-data", "demo-data"]
|
|
# [/DEF:test_policy_enterprise_clean_valid:Function]
|
|
|
|
|
|
# [DEF:test_policy_missing_registry_fails:Function]
|
|
# @PURPOSE: Verify missing registry ref violates policy contract.
|
|
# @PRE: enterprise-clean policy payload has blank registry ref.
|
|
# @POST: Validation error is raised.
|
|
def test_policy_missing_registry_fails():
|
|
with pytest.raises(ValueError):
|
|
CleanProfilePolicy(
|
|
policy_id="policy-enterprise-clean-v1",
|
|
policy_version="1.0.0",
|
|
active=True,
|
|
prohibited_artifact_categories=["test-data"],
|
|
required_system_categories=["system-init"],
|
|
external_source_forbidden=True,
|
|
internal_source_registry_ref="",
|
|
effective_from=datetime.now(timezone.utc),
|
|
profile=ProfileType.ENTERPRISE_CLEAN,
|
|
)
|
|
# [/DEF:test_policy_missing_registry_fails:Function]
|
|
|
|
|
|
# [DEF:test_policy_empty_prohibited_categories_fails:Function]
|
|
# @PURPOSE: Verify enterprise policy cannot activate without prohibited categories.
|
|
# @PRE: enterprise-clean policy payload has empty prohibited categories.
|
|
# @POST: Validation error is raised.
|
|
def test_policy_empty_prohibited_categories_fails():
|
|
with pytest.raises(ValueError):
|
|
CleanProfilePolicy(
|
|
policy_id="policy-enterprise-clean-v1",
|
|
policy_version="1.0.0",
|
|
active=True,
|
|
prohibited_artifact_categories=[],
|
|
required_system_categories=["system-init"],
|
|
external_source_forbidden=True,
|
|
internal_source_registry_ref="registry-internal-v1",
|
|
effective_from=datetime.now(timezone.utc),
|
|
profile=ProfileType.ENTERPRISE_CLEAN,
|
|
)
|
|
# [/DEF:test_policy_empty_prohibited_categories_fails:Function]
|
|
|
|
|
|
# [DEF:test_policy_conflicting_external_forbidden_flag_fails:Function]
|
|
# @PURPOSE: Verify enterprise policy enforces external_source_forbidden=true.
|
|
# @PRE: enterprise-clean policy payload sets external_source_forbidden to false.
|
|
# @POST: Validation error is raised.
|
|
def test_policy_conflicting_external_forbidden_flag_fails():
|
|
with pytest.raises(ValueError):
|
|
CleanProfilePolicy(
|
|
policy_id="policy-enterprise-clean-v1",
|
|
policy_version="1.0.0",
|
|
active=True,
|
|
prohibited_artifact_categories=["test-data"],
|
|
required_system_categories=["system-init"],
|
|
external_source_forbidden=False,
|
|
internal_source_registry_ref="registry-internal-v1",
|
|
effective_from=datetime.now(timezone.utc),
|
|
profile=ProfileType.ENTERPRISE_CLEAN,
|
|
)
|
|
# [/DEF:test_policy_conflicting_external_forbidden_flag_fails:Function]
|
|
# [/DEF:backend.tests.services.clean_release.test_policy_engine:Module]
|
|
from src.models.clean_release import ResourceSourceRegistry, ResourceSourceEntry, RegistryStatus
|
|
from src.services.clean_release.policy_engine import CleanPolicyEngine
|
|
|
|
def _policy_enterprise_clean() -> CleanProfilePolicy:
|
|
return CleanProfilePolicy(
|
|
policy_id="policy-enterprise-clean-v1",
|
|
policy_version="1.0.0",
|
|
active=True,
|
|
prohibited_artifact_categories=["test-data"],
|
|
required_system_categories=["system-init"],
|
|
external_source_forbidden=True,
|
|
internal_source_registry_ref="registry-internal-v1",
|
|
effective_from=datetime.now(timezone.utc),
|
|
profile=ProfileType.ENTERPRISE_CLEAN,
|
|
)
|
|
|
|
def _registry() -> ResourceSourceRegistry:
|
|
return ResourceSourceRegistry(
|
|
registry_id="registry-internal-v1",
|
|
name="Internal",
|
|
entries=[ResourceSourceEntry(source_id="1", host="nexus.internal", protocol="https", purpose="pkg", enabled=True)],
|
|
updated_at=datetime.now(timezone.utc),
|
|
updated_by="tester",
|
|
)
|
|
|
|
# [DEF:test_policy_valid:Function]
|
|
# @PURPOSE: Validate policy valid scenario
|
|
def test_policy_valid():
|
|
engine = CleanPolicyEngine(_policy_enterprise_clean(), _registry())
|
|
res = engine.validate_policy()
|
|
assert res.ok is True
|
|
|
|
# [DEF:test_conflicting_registry:Function]
|
|
# @PURPOSE: Validate policy conflicting registry edge
|
|
def test_conflicting_registry():
|
|
reg = _registry()
|
|
reg.registry_id = "other-registry"
|
|
engine = CleanPolicyEngine(_policy_enterprise_clean(), reg)
|
|
res = engine.validate_policy()
|
|
assert res.ok is False
|
|
assert "Policy registry ref does not match provided registry" in res.blocking_reasons
|
|
|
|
# [DEF:test_external_endpoint:Function]
|
|
# @PURPOSE: Validate policy external endpoint edge
|
|
def test_external_endpoint():
|
|
engine = CleanPolicyEngine(_policy_enterprise_clean(), _registry())
|
|
res = engine.validate_resource_source("external.org")
|
|
assert res.ok is False
|
|
assert res.violation["category"] == "external-source"
|
|
|