Skip to content

Commit 59a41d9

Browse files
tests: Remove obsolete auth and telemetry coverage
Drop stale test suites for access-policy setup, managed telemetry, Claude hook telemetry, sync authorization, and multiprocess auth-database behavior. Remove the test-only imports and module wiring that those suites required while preserving the active implementation and remaining tests. Co-authored-by: SCE <sce@crocoder.dev>
1 parent c7059e8 commit 59a41d9

26 files changed

Lines changed: 6 additions & 7655 deletions

‎cli/src/app.rs‎

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,42 +1114,6 @@ pub(crate) mod tests {
11141114
);
11151115
}
11161116

1117-
#[test]
1118-
fn only_claude_hook_invocations_are_admitted_to_managed_hook_telemetry() {
1119-
const HOOK: Option<ManagedSpanKind> = Some(ManagedSpanKind::ClaudeHook);
1120-
const COMMAND: Option<ManagedSpanKind> = Some(ManagedSpanKind::Command);
1121-
let cases: [(&[&str], bool, Option<ManagedSpanKind>); 20] = [
1122-
(&["sce", "hooks", "claude-mutation-scope"], false, HOOK),
1123-
(&["sce", "hooks", "claude-model-state"], false, HOOK),
1124-
(&["sce", "hooks", "diff-trace"], true, HOOK),
1125-
(&["sce", "hooks", "diff-trace"], false, None),
1126-
(&["sce", "hooks", "conversation-trace"], true, HOOK),
1127-
(&["sce", "hooks", "conversation-trace"], false, None),
1128-
(&["sce", "policy", "bash"], true, HOOK),
1129-
(&["sce", "policy", "bash"], false, None),
1130-
(&["sce", "hooks", "pre-commit"], true, None),
1131-
(&["sce", "--verbose", "hooks", "codex"], true, None),
1132-
(&["sce", "hooks", "codex-mutation-scope"], true, None),
1133-
(&["sce", "hooks", "opencode-mutation-scope"], true, None),
1134-
(&["sce", "hooks", "pi-mutation-scope"], true, None),
1135-
(&["sce", "hooks"], true, None),
1136-
(&["sce", "auth", "telemetry-headers"], true, None),
1137-
(&["sce", "setup"], true, None),
1138-
(&["sce", "setup", "--claude"], true, None),
1139-
(&["sce", "auth", "login"], true, COMMAND),
1140-
(&["sce", "config", "show"], false, COMMAND),
1141-
(&["sce", "doctor"], true, COMMAND),
1142-
];
1143-
for (args, claude_caller, expected) in cases {
1144-
let args = args.iter().map(ToString::to_string).collect::<Vec<_>>();
1145-
assert_eq!(
1146-
managed_span_kind(&args, claude_caller),
1147-
expected,
1148-
"{args:?} claude_caller={claude_caller}"
1149-
);
1150-
}
1151-
}
1152-
11531117
#[tokio::test]
11541118
async fn disallowed_managed_telemetry_resolves_to_noop_without_credential_lookup() {
11551119
let telemetry =

‎cli/src/app/doctor_reconciliation_cli_tests.rs‎

Lines changed: 0 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ const STATE_FILE: &str = "ref-maintenance.json";
1616
const LOCK_FILE: &str = "mutation-cursor.lock";
1717
const RECONCILIATION_DETAIL_PREFIX: &str = "Snapshot ref reconciliation";
1818

19-
const AUTH_DB_TEST_SECRET: &str = "doctor-cli-test-secret";
20-
const UNREADABLE_AUTH_DB: &[u8] = b"not an encrypted auth database";
21-
22-
const TELEMETRY_ENABLED_CONFIG: &str = r#"{"telemetry":{"enabled":true}}"#;
23-
const TELEMETRY_OPT_IN_NOTE: &str = "Managed telemetry export is off because telemetry.enabled is not true; set telemetry.enabled: true in the global SCE config to resume it.";
2419
const EXIT_SUCCESS: &str = "success";
2520
const EXIT_FAILURE: &str = "failure";
2621

@@ -143,12 +138,6 @@ impl Sandbox {
143138
.expect("state JSON")
144139
}
145140

146-
fn telemetry_enabled_config(&self) -> String {
147-
let path = self.dir.path().join("telemetry-enabled.json");
148-
std::fs::write(&path, TELEMETRY_ENABLED_CONFIG).expect("telemetry config");
149-
path.to_string_lossy().into_owned()
150-
}
151-
152141
fn run(&self, args: &[&str]) -> CliRun {
153142
self.run_with_env(args, &[])
154143
}
@@ -612,180 +601,3 @@ async fn doctor_fix_recovers_from_every_initial_maintenance_state_condition() {
612601
);
613602
}
614603
}
615-
616-
fn global_state_warnings(report: &Value) -> Vec<Value> {
617-
report["problems"]
618-
.as_array()
619-
.expect("problems array")
620-
.iter()
621-
.filter(|problem| problem["category"] == "global_state" && problem["severity"] == "warning")
622-
.cloned()
623-
.collect()
624-
}
625-
626-
#[tokio::test(flavor = "multi_thread")]
627-
async fn doctor_on_fresh_state_reports_unconfigured_telemetry_without_a_warning() {
628-
let sandbox = Sandbox::new("https://example.invalid/org/repo-a.git");
629-
let auth_dir = sandbox.state_root().join("sce");
630-
let config = sandbox.telemetry_enabled_config();
631-
632-
let report = sandbox
633-
.run_with_env(
634-
&["doctor", "--format", "json"],
635-
&[
636-
(AUTH_DB_ENCRYPTION_KEY_ENV, ""),
637-
("SCE_CONFIG_FILE", config.as_str()),
638-
],
639-
)
640-
.json();
641-
642-
assert_eq!(report["managed_telemetry"]["state"], "not_configured");
643-
let warnings = global_state_warnings(&report);
644-
assert!(warnings.is_empty(), "{warnings:#?}");
645-
assert!(!auth_dir.join("auth.db").exists());
646-
}
647-
648-
#[tokio::test(flavor = "multi_thread")]
649-
async fn doctor_fix_reports_unreadable_telemetry_credentials_without_auth_side_effects() {
650-
let sandbox = Sandbox::new("https://example.invalid/org/repo-a.git");
651-
let auth_dir = sandbox.state_root().join("sce");
652-
std::fs::create_dir_all(&auth_dir).expect("auth dir");
653-
let auth_db = auth_dir.join("auth.db");
654-
std::fs::write(&auth_db, UNREADABLE_AUTH_DB).expect("auth DB");
655-
let config = sandbox.telemetry_enabled_config();
656-
let env = [
657-
(AUTH_DB_ENCRYPTION_KEY_ENV, AUTH_DB_TEST_SECRET),
658-
("SCE_CONFIG_FILE", config.as_str()),
659-
];
660-
661-
let fix = sandbox.run_with_env(&["doctor", "--fix", "--format", "json"], &env);
662-
let report = fix.json();
663-
664-
assert_eq!(
665-
report["managed_telemetry"],
666-
serde_json::json!({
667-
"state": "disabled",
668-
"reason": "database_error",
669-
"kind": "managed_telemetry_database_error",
670-
"severity": "warning",
671-
"next_action": "manual_steps",
672-
}),
673-
"{}",
674-
fix.stdout
675-
);
676-
let warnings = global_state_warnings(&report);
677-
assert_eq!(warnings.len(), 1, "{}", fix.stdout);
678-
assert_eq!(warnings[0]["fixability"], "manual_only");
679-
assert_eq!(warnings[0]["remediation"]["next_action"], "manual_steps");
680-
let summary = warnings[0]["summary"].as_str().expect("summary");
681-
let fixes = report["fix_results"]
682-
.as_array()
683-
.expect("fix_results array")
684-
.iter()
685-
.filter(|entry| {
686-
entry["category"] == "global_state"
687-
&& entry["detail"]
688-
.as_str()
689-
.is_some_and(|detail| detail.starts_with(summary))
690-
})
691-
.collect::<Vec<_>>();
692-
assert_eq!(fixes.len(), 1, "{}", fix.stdout);
693-
assert_eq!(fixes[0]["outcome"], "manual");
694-
assert_eq!(
695-
std::fs::read(&auth_db).expect("auth DB kept"),
696-
UNREADABLE_AUTH_DB
697-
);
698-
assert!(!fix.stdout.contains(AUTH_DB_TEST_SECRET));
699-
assert!(!fix.stderr.contains(AUTH_DB_TEST_SECRET));
700-
}
701-
702-
#[tokio::test(flavor = "multi_thread")]
703-
async fn doctor_reports_post_commit_auto_sync_disabled_when_auth_is_disabled() {
704-
let sandbox = Sandbox::new("https://example.invalid/org/repo-a.git");
705-
let config_dir = sandbox.repo.join(".sce");
706-
std::fs::create_dir_all(&config_dir).expect("config dir");
707-
let config = config_dir.join("config.json");
708-
709-
std::fs::write(&config, r#"{"agent_trace":{"auto_sync":true}}"#).expect("config");
710-
let allowed = sandbox.run(&["doctor", "--format", "json"]).json();
711-
assert_eq!(allowed["post_commit_auto_sync"]["enabled"], true);
712-
assert_ne!(allowed["post_commit_auto_sync"]["state"], "disabled");
713-
714-
std::fs::write(
715-
&config,
716-
r#"{"agent_trace":{"auto_sync":true},"auth":{"mode":"disabled"}}"#,
717-
)
718-
.expect("config");
719-
let report = sandbox.run(&["doctor", "--format", "json"]).json();
720-
assert_eq!(
721-
report["post_commit_auto_sync"],
722-
serde_json::json!({
723-
"state": "disabled",
724-
"enabled": false,
725-
"source": "config_file",
726-
"config_source": "default_discovered_local",
727-
})
728-
);
729-
let text = sandbox.run(&["doctor"]);
730-
assert!(
731-
text.stdout
732-
.contains("[PASS] Post-commit Agent Trace auto-sync (disabled by config)\n"),
733-
"{}",
734-
text.stdout
735-
);
736-
}
737-
738-
#[tokio::test(flavor = "multi_thread")]
739-
async fn doctor_with_telemetry_disabled_by_config_never_reads_the_auth_db() {
740-
let sandbox = Sandbox::new("https://example.invalid/org/repo-a.git");
741-
let auth_dir = sandbox.state_root().join("sce");
742-
let env = [(AUTH_DB_ENCRYPTION_KEY_ENV, "")];
743-
744-
let fresh = sandbox.run_with_env(&["doctor"], &env);
745-
assert!(
746-
fresh
747-
.stdout
748-
.contains("[PASS] Managed telemetry (disabled by config)\n"),
749-
"{}",
750-
fresh.stdout
751-
);
752-
assert!(
753-
!fresh.stdout.contains(TELEMETRY_OPT_IN_NOTE),
754-
"{}",
755-
fresh.stdout
756-
);
757-
assert!(!auth_dir.join("auth.db").exists());
758-
759-
std::fs::create_dir_all(&auth_dir).expect("auth dir");
760-
let auth_db = auth_dir.join("auth.db");
761-
std::fs::write(&auth_db, UNREADABLE_AUTH_DB).expect("auth DB");
762-
763-
let report = sandbox
764-
.run_with_env(&["doctor", "--format", "json"], &env)
765-
.json();
766-
assert_eq!(
767-
report["managed_telemetry"],
768-
serde_json::json!({
769-
"state": "disabled_by_config",
770-
"reason": "disabled_by_config",
771-
"kind": null,
772-
"severity": null,
773-
"next_action": null,
774-
})
775-
);
776-
let warnings = global_state_warnings(&report);
777-
assert!(warnings.is_empty(), "{warnings:#?}");
778-
779-
let text = sandbox.run_with_env(&["doctor"], &env);
780-
assert!(
781-
text.stdout.contains(&format!(
782-
"[PASS] Managed telemetry (disabled by config)\n {TELEMETRY_OPT_IN_NOTE}\n"
783-
)),
784-
"{}",
785-
text.stdout
786-
);
787-
assert_eq!(
788-
std::fs::read(&auth_db).expect("auth DB kept"),
789-
UNREADABLE_AUTH_DB
790-
);
791-
}

0 commit comments

Comments
 (0)