fix api2::types::ACL_ROLE_SCHEMA
make sure we list all roles ...
This commit is contained in:
parent
dd335b77f5
commit
409f44247b
@ -257,8 +257,10 @@ pub const ACL_ROLE_SCHEMA: Schema = StringSchema::new(
|
|||||||
"Admin",
|
"Admin",
|
||||||
"Audit",
|
"Audit",
|
||||||
"Datastore.Admin",
|
"Datastore.Admin",
|
||||||
|
"Datastore.Reader",
|
||||||
"Datastore.Audit",
|
"Datastore.Audit",
|
||||||
"Datastore.User",
|
"Datastore.Backup",
|
||||||
|
"Datastore.PowerUser",
|
||||||
"NoAccess",
|
"NoAccess",
|
||||||
]))
|
]))
|
||||||
.schema();
|
.schema();
|
||||||
|
@ -142,3 +142,27 @@ fn verify_root_api() -> Result<(), Error> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn verify_acl_role_schema() -> Result<(), Error> {
|
||||||
|
|
||||||
|
let list = match api2::types::ACL_ROLE_SCHEMA {
|
||||||
|
Schema::String(StringSchema { format: Some(ApiStringFormat::Enum(list)), .. }) => list,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let map = &proxmox_backup::config::acl::ROLE_NAMES;
|
||||||
|
for item in *list {
|
||||||
|
if !map.contains_key(item) {
|
||||||
|
bail!("found role '{}' without description/mapping", item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for role in map.keys() {
|
||||||
|
if !list.contains(role) {
|
||||||
|
bail!("role '{}' missing in ACL_ROLE_SCHEMA enum", role);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user