1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use super::*;
#[test]
fn default_is_off() {
// Guard against a stray env var leaking into the test process.
if std::env::var("LEAN_CTX_PERMISSION_INHERITANCE").is_ok() {
return;
}
let cfg = Config::default();
assert_eq!(
cfg.permission_inheritance_effective(),
PermissionInheritance::Off
);
}
#[test]
fn config_on() {
if std::env::var("LEAN_CTX_PERMISSION_INHERITANCE").is_ok() {
return;
}
let cfg = Config {
permission_inheritance: Some("on".to_string()),
..Default::default()
};
assert_eq!(
cfg.permission_inheritance_effective(),
PermissionInheritance::On
);
}
#[test]
fn unknown_value_falls_back_to_off() {
if std::env::var("LEAN_CTX_PERMISSION_INHERITANCE").is_ok() {
return;
}
let cfg = Config {
permission_inheritance: Some("nonsense".to_string()),
..Default::default()
};
assert_eq!(
cfg.permission_inheritance_effective(),
PermissionInheritance::Off
);
}
#[test]
fn deserialization_from_toml() {
let cfg: Config = toml::from_str(r#"permission_inheritance = "on""#).unwrap();
assert_eq!(cfg.permission_inheritance.as_deref(), Some("on"));
}
#[test]
fn local_override_merges() {
if std::env::var("LEAN_CTX_PERMISSION_INHERITANCE").is_ok() {
return;
}
let mut base = Config::default();
base.merge_local(r#"permission_inheritance = "on""#, true);
assert_eq!(
base.permission_inheritance_effective(),
PermissionInheritance::On
);
}