///|
test "audit reports missing title" {
assert_true(has_audit(audit_problem(unwrap_problem("{}")), MissingTitle))
}
///|
test "audit reports missing status" {
assert_true(has_audit(audit_problem(unwrap_problem("{}")), MissingStatus))
}
///|
test "audit reports relative type" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"type\":\"relative\"}")),
RelativeTypeUri,
),
)
}
///|
test "audit reports relative instance" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"instance\":\"/i\"}")),
RelativeInstanceUri,
),
)
}
///|
test "audit stays quiet for absolute uri references" {
let r = audit_problem(
unwrap_problem(
"{\"type\":\"urn:x\",\"instance\":\"https://e/i\",\"title\":\"T\",\"status\":400}",
),
)
assert_false(has_audit(r, RelativeTypeUri))
assert_false(has_audit(r, RelativeInstanceUri))
}
///|
test "audit reports short extension name" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"x\":1}")),
SuspiciousExtensionName,
),
)
}
///|
test "audit reports punctuation extension name" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"bad-name\":1}")),
SuspiciousExtensionName,
),
)
}
///|
test "audit accepts portable extension name" {
assert_false(
has_audit(
audit_problem(unwrap_problem("{\"request_id\":1}")),
SuspiciousExtensionName,
),
)
}
///|
test "audit reports sensitive extension name" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"stacktrace\":\"x\"}")),
SensitiveLookingExtension,
),
)
}
///|
test "audit reports token extension name" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"token\":\"x\"}")),
SensitiveLookingExtension,
),
)
}
///|
test "audit reports stack trace text heuristic" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"detail\":\"stack trace follows\"}")),
DebugInformationRisk,
),
)
}
///|
test "about blank title mismatch is advisory" {
assert_true(
has_audit(
audit_problem(unwrap_problem("{\"status\":404,\"title\":\"Missing\"}")),
AboutBlankTitleMismatch,
),
)
}
///|
test "about blank common title matches" {
assert_false(
has_audit(
audit_problem(unwrap_problem("{\"status\":404,\"title\":\"Not Found\"}")),
AboutBlankTitleMismatch,
),
)
}
///|
test "localized about blank title remains a valid model" {
assert_true(
is_valid_problem(unwrap_problem("{\"status\":404,\"title\":\"未找到\"}")),
)
}