aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/access.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/api/access.rs b/src/api/access.rs
index 6977a0a..ddcaad0 100644
--- a/src/api/access.rs
+++ b/src/api/access.rs
@@ -419,10 +419,22 @@ mod tests {
by: String::new(),
since: 0,
}];
- let handed = Access::Caps(operator.clone().within(members));
+ let handed = Access::Caps(operator.clone().within(members.clone()));
let need = |method: &Method, at: &str| needed(method, at, "n1");
assert!(allowed(need(&Method::GET, "/admin/stats"), &handed));
assert!(allowed(need(&Method::GET, "/peers"), &handed));
+ // A limit where the user has nothing: nothing to look with.
+ let elsewhere = Caps::new(vec![Capability {
+ path: path("data/eu"),
+ rights: ["read".to_owned()].into(),
+ by: String::new(),
+ since: 0,
+ }])
+ .within(members.clone());
+ assert!(!allowed(
+ need(&Method::GET, "/admin/stats"),
+ &Access::Caps(elsewhere)
+ ));
for (method, at) in [
(Method::POST, "/auth/refresh"),
(Method::DELETE, "/auth/session"),