]> git.proxmox.com Git - proxmox-backup.git/commitdiff
fix api2::types::ACL_ROLE_SCHEMA
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Apr 2020 11:25:02 +0000 (13:25 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 28 Apr 2020 11:25:02 +0000 (13:25 +0200)
make sure we list all roles ...

src/api2/types.rs
tests/verify-api.rs

index 90207861d8111ca4305de1fbbb6979d11c66cbb7..5b852a880ff9450fcf93ebf8e68c1a4a7771f19a 100644 (file)
@@ -257,8 +257,10 @@ pub const ACL_ROLE_SCHEMA: Schema = StringSchema::new(
         "Admin",
         "Audit",
         "Datastore.Admin",
+        "Datastore.Reader",
         "Datastore.Audit",
-        "Datastore.User",
+        "Datastore.Backup",
+        "Datastore.PowerUser",
         "NoAccess",
     ]))
     .schema();
index d919f1547dd0a342c33297463ad6fa5ad10f3ac0..a5887758ecaa82edde800fa0103056892ab5715b 100644 (file)
@@ -142,3 +142,27 @@ fn verify_root_api() -> Result<(), Error> {
 
     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(())
+}