usesuper::*;use serde_json::json;/// RULE: a phone report never carries a credential. Every line of it — the/// app's log, the core's, the state — passes the same redaction the reported/// state does, so a log line that printed a bearer token reaches the owner's/// database as `Bearer ‹redacted›` (procedure c47ae4d4; owner, 12 Oct 2026).#[test]fn a_log_line_with_a_bearer_token_reaches_the_report_redacted() {let text = report_text("Phone report · 12 Oct 16:02", &[Section::new("App log", vec!["16:02:01.000 sync GET /v1/x Authorization: Bearer x".to_string()]),Section::new("Core log", vec!["2026-10-12T10:32:01Z info client fetched https://mac.local/v1/pair?code=123456".to_string()], ), ], ); assert!(text.contains("Bearer ‹redacted›"), "{text}"); assert!(!text.contains("Bearer x"), "{text}"); assert!(!text.contains("123456"), "{text}"); assert!(text.starts_with("Phone report · 12 Oct 16:02\n"));}/// RULE: a registry file is printed only as JSON with every credential-named/// value replaced — a device key or a token kept beside the connection never/// reaches the report, and a file that is not JSON is not printed at all.#[test]fn a_registry_file_keeps_ids_and_loses_credential_values() {let dir = tempfile::tempdir().expect("temp dir");let path = dir.path().join("connection.json"); std::fs::write( &path, json!({"mode": "remote","baseUrl": "https://mac.local:8790","workspaceId": "ws-1","deviceKey": "AAAAsecretkeymaterial","places": [{ "id": "ws-2", "accessToken": "tok-123", "pairingCode": "998877" }], }) .to_string(), ) .expect("write");let text = registry_file(&path).join("\n"); assert!(text.contains("ws-1") && text.contains("ws-2"), "{text}");for secret in ["AAAAsecretkeymaterial", "tok-123", "998877"] { assert!(!text.contains(secret), "{secret} leaked: {text}"); } std::fs::write(&path, "Bearer abc not json").expect("write");let text = registry_file(&path).join("\n"); assert!(!text.contains("abc"), "{text}");}#[test]fn a_log_keeps_its_newest_lines() {let lines: Vec<String> = (0..LOG_LINES + 7).map(|n| n.to_string()).collect();let kept = tail(lines); assert_eq!(kept.len(), LOG_LINES); assert_eq!(kept.first().map(String::as_str), Some("7"));}