api/permissions: support test-harness

(Api-macro tests want to use `==` to compare generated
schemas against hardcoded schemas.)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-04-14 11:25:18 +02:00
parent 5aeebdab44
commit b67e2f7214
2 changed files with 3 additions and 0 deletions

View File

@ -6,6 +6,7 @@ use std::fmt;
use serde_json::Value;
/// Access permission
#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub enum Permission {
/// Allow Superuser
Superuser,
@ -70,6 +71,7 @@ impl fmt::Debug for Permission {
}
}
}
/// Trait to query user information (used by check_api_permission)
pub trait UserInformation {
fn is_superuser(&self, userid: &str) -> bool;

View File

@ -386,6 +386,7 @@ fn dummy_handler_fn(
const DUMMY_HANDLER: ApiHandler = ApiHandler::Sync(&dummy_handler_fn);
/// Access permission with description
#[cfg_attr(feature = "test-harness", derive(Eq, PartialEq))]
pub struct ApiAccessPermissions {
pub description: &'static str,
pub permission: &'static Permission,