Skip to content
Open
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
32 changes: 32 additions & 0 deletions crates/google-workspace-cli/src/auth_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}
}
Expand Down Expand Up @@ -2236,6 +2238,36 @@ mod tests {
));
}

#[test]
fn scope_matches_admin_directory_service() {
let services: HashSet<String> = ["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<String> = ["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]
Expand Down
10 changes: 10 additions & 0 deletions crates/google-workspace/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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]
Expand Down
Loading