Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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 @@ -164,6 +170,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())
);
Comment on lines +173 to +176
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To prevent future bugs from duplicate service aliases, it's important to ensure all aliases are unique. The current implementation of resolve_service will silently use the first match it finds, which can lead to subtle bugs if an alias is accidentally duplicated. Please add a new test to verify the uniqueness of all aliases across the SERVICES list. This will improve the long-term maintainability and correctness of service resolution.

Here is a suggested implementation for the test:

#[test]
fn test_all_aliases_are_unique() {
    let mut all_aliases = std::collections::HashSet::new();
    for service in SERVICES {
        for &alias in service.aliases {
            assert!(all_aliases.insert(alias), "Duplicate alias found: {}", alias);
        }
    }
}

}

#[test]
Expand Down
Loading