diff --git a/crates/google-workspace-cli/src/auth_commands.rs b/crates/google-workspace-cli/src/auth_commands.rs index d7571e74..0eaeb5cd 100644 --- a/crates/google-workspace-cli/src/auth_commands.rs +++ b/crates/google-workspace-cli/src/auth_commands.rs @@ -841,6 +841,8 @@ fn map_service_to_scope_prefixes(service: &str) -> Vec<&str> { "slides" => vec!["presentations"], "docs" => vec!["documents"], "people" => vec!["contacts", "directory"], + "admin-directory" => vec!["admin.directory"], + "admin-reports" | "reports" => vec!["admin.reports"], s => vec![s], } } @@ -2236,6 +2238,36 @@ mod tests { )); } + #[test] + fn scope_matches_admin_directory_service() { + let services: HashSet = ["admin-directory"].iter().map(|s| s.to_string()).collect(); + assert!(scope_matches_service( + "https://www.googleapis.com/auth/admin.directory.user.readonly", + &services + )); + assert!(scope_matches_service( + "https://www.googleapis.com/auth/admin.directory.group", + &services + )); + assert!(!scope_matches_service( + "https://www.googleapis.com/auth/admin.reports.audit.readonly", + &services + )); + } + + #[test] + fn scope_matches_admin_reports_service() { + let services: HashSet = ["admin-reports"].iter().map(|s| s.to_string()).collect(); + assert!(scope_matches_service( + "https://www.googleapis.com/auth/admin.reports.audit.readonly", + &services + )); + assert!(!scope_matches_service( + "https://www.googleapis.com/auth/admin.directory.user.readonly", + &services + )); + } + // ── services filter integration tests ──────────────────────────────── #[test] diff --git a/crates/google-workspace/src/services.rs b/crates/google-workspace/src/services.rs index 72c96329..faa97d87 100644 --- a/crates/google-workspace/src/services.rs +++ b/crates/google-workspace/src/services.rs @@ -58,6 +58,12 @@ pub const SERVICES: &[ServiceEntry] = &[ version: "reports_v1", description: "Audit logs and usage reports", }, + ServiceEntry { + aliases: &["admin-directory"], + api_name: "admin", + version: "directory_v1", + description: "Manage users, groups, and organizational units", + }, ServiceEntry { aliases: &["docs"], api_name: "docs", @@ -174,6 +180,10 @@ mod tests { resolve_service("reports").unwrap(), ("admin".to_string(), "reports_v1".to_string()) ); + assert_eq!( + resolve_service("admin-directory").unwrap(), + ("admin".to_string(), "directory_v1".to_string()) + ); } #[test]