Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions internal/schema/conformance_report_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,36 @@ func TestConformanceReportExampleAndCLIValidateSchema(t *testing.T) {
if err := sch.Validate(v); err != nil {
t.Fatalf("schema validation failed for example: %v", err)
}
exampleReport, ok := v.(map[string]interface{})
if !ok {
t.Fatalf("unexpected example report shape")
}
if int(exampleReport["total"].(float64)) != 11 {
t.Fatalf("expected example total 11, got %v", exampleReport["total"])
}
if int(exampleReport["passed"].(float64)) != 11 {
t.Fatalf("expected example passed 11, got %v", exampleReport["passed"])
}
exampleCases, ok := exampleReport["cases"].([]interface{})
if !ok || len(exampleCases) != 11 {
t.Fatalf("expected example 11 cases, got %v", exampleReport["cases"])
}
foundUnsupportedCanonicalizationProfile := false
for _, c := range exampleCases {
caseReport, ok := c.(map[string]interface{})
if !ok {
t.Fatalf("unexpected example case shape")
}
if caseReport["name"] == "unsupported_canonicalization_profile_error" {
foundUnsupportedCanonicalizationProfile = true
if caseReport["expected_result"] != "ERROR" || caseReport["reason_code"] != "UNSUPPORTED_CANONICALIZATION_PROFILE" {
t.Fatalf("unexpected unsupported canonicalization profile case: %v", caseReport)
}
}
}
if !foundUnsupportedCanonicalizationProfile {
t.Fatalf("missing unsupported_canonicalization_profile_error in example report")
}

// Run CLI to produce JSON output and validate
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
Expand Down
46 changes: 26 additions & 20 deletions testdata/core_2_conformance/report_expected_basic.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"report_version": "core-2-conformance-report-v1",
"status": "PASS",
"total": 10,
"passed": 10,
"total": 11,
"passed": 11,
"failed": 0,
"cases": [
{
Expand All @@ -19,61 +19,67 @@
"reason_code": "HASH_MISMATCH",
"error": null
},
{
"name": "inside_payload_mutation_detected",
"case_passed": true,
"expected_result": "FAIL",
"reason_code": "HASH_MISMATCH",
"error": null
},
{
"name": "invalid_schema_error",
"case_passed": true,
"expected_result": "ERROR",
"reason_code": "INVALID_SNAPSHOT_SCHEMA",
"error": null
}
,
},
{
"name": "missing_required_field_error",
"name": "malformed_json_error",
"case_passed": true,
"expected_result": "ERROR",
"reason_code": "INVALID_SNAPSHOT_SCHEMA",
"error": null
},
{
"name": "malformed_json_error",
"name": "missing_required_field_error",
"case_passed": true,
"expected_result": "ERROR",
"reason_code": "INVALID_SNAPSHOT_SCHEMA",
"error": null
},
{
"name": "unknown_reason_code_error",
"name": "outside_metadata_ignored",
"case_passed": true,
"expected_result": "ERROR",
"reason_code": "INTERNAL_ERROR",
"expected_result": "PASS",
"reason_code": "STATE_RECONSTRUCTED",
"error": null
},
{
"name": "unsupported_hash_algorithm_error",
"name": "unknown_reason_code_error",
"case_passed": true,
"expected_result": "ERROR",
"reason_code": "UNSUPPORTED_HASH_ALGORITHM",
"reason_code": "INTERNAL_ERROR",
"error": null
},
{
"name": "wrong_profile_fail",
"name": "unsupported_canonicalization_profile_error",
"case_passed": true,
"expected_result": "FAIL",
"reason_code": "RECONSTRUCTION_RULE_MISMATCH",
"expected_result": "ERROR",
"reason_code": "UNSUPPORTED_CANONICALIZATION_PROFILE",
"error": null
},
{
"name": "inside_payload_mutation_detected",
"name": "unsupported_hash_algorithm_error",
"case_passed": true,
"expected_result": "FAIL",
"reason_code": "HASH_MISMATCH",
"expected_result": "ERROR",
"reason_code": "UNSUPPORTED_HASH_ALGORITHM",
"error": null
},
{
"name": "outside_metadata_ignored",
"name": "wrong_profile_fail",
"case_passed": true,
"expected_result": "PASS",
"reason_code": "STATE_RECONSTRUCTED",
"expected_result": "FAIL",
"reason_code": "RECONSTRUCTION_RULE_MISMATCH",
"error": null
}
]
Expand Down
Loading