[team] Team vaults: rustfmt on the files this change touches

This commit is contained in:
2026-11-17 12:15:18 +01:00
parent e3ede760bd
commit 3bb05bf6f1
8 changed files with 138 additions and 45 deletions
+24 -6
View File
@@ -74,7 +74,9 @@ fn every_size_environment_author_and_approver_under_the_default_policy() {
let r = roster(n);
for env in ["preview", "staging", "production", "qa"] {
// The author by handle (any case), by member id, someone outside the team, or nobody named.
for (author, is_member) in [("mnovak", true), ("MNOVAK", true), (id(0).as_str(), true), ("stranger", false), ("", false)] {
for (author, is_member) in
[("mnovak", true), ("MNOVAK", true), (id(0).as_str(), true), ("stranger", false), ("", false)]
{
for (what, set) in approver_sets(n) {
let got = evaluate(&policy, &r, env, author, &set);
let want = expected(n, env, is_member, &set);
@@ -119,9 +121,15 @@ fn several_approvals_others_and_approver_lists() {
let three = roster(3);
assert_eq!(evaluate(&p, &three, "production", "mnovak", &[id(1)]).verdict, Verdict::Need(1));
assert_eq!(evaluate(&p, &three, "production", "mnovak", &[id(0), id(1)]).verdict, Verdict::Need(1));
assert_eq!(evaluate(&p, &three, "production", "mnovak", &[id(1), id(2)]).verdict, Verdict::Allowed(KeyRole::Release));
assert_eq!(
evaluate(&p, &three, "production", "mnovak", &[id(1), id(2)]).verdict,
Verdict::Allowed(KeyRole::Release)
);
// Someone not named as the author (a release by a non-member): every member counts.
assert_eq!(evaluate(&p, &three, "production", "stranger", &[id(0), id(1)]).verdict, Verdict::Allowed(KeyRole::Release));
assert_eq!(
evaluate(&p, &three, "production", "stranger", &[id(0), id(1)]).verdict,
Verdict::Allowed(KeyRole::Release)
);
// Only member 1 may approve staging.
p.set_rule(EnvRule { env: "staging".into(), approvals: 1, others: false, approvers: vec![id(1)] }).unwrap();
@@ -138,7 +146,10 @@ fn several_approvals_others_and_approver_lists() {
q.set_rule(EnvRule { env: "staging".into(), approvals: 1, others: true, approvers: vec![id(0)] }).unwrap();
q
};
assert_eq!(evaluate(&solo_policy, &roster(1), "staging", "mnovak", &[id(0)]).verdict, Verdict::Allowed(KeyRole::Release));
assert_eq!(
evaluate(&solo_policy, &roster(1), "staging", "mnovak", &[id(0)]).verdict,
Verdict::Allowed(KeyRole::Release)
);
// A preview made strict.
p.set_rule(EnvRule { env: "preview".into(), approvals: 1, others: false, approvers: vec![] }).unwrap();
assert_eq!(evaluate(&p, &four, "preview", "mnovak", &[]).verdict, Verdict::Need(1));
@@ -163,7 +174,10 @@ fn the_policy_text_is_canonical_and_its_rules_are_checked() {
text.replace("\"approvers\":[]}]", "\"approvers\":[\"nope\"]}]"),
text.replace("{\"v\":1,", "{\"v\":2,"),
text.clone() + "\n",
text.replace("\"others\":false,\"approvers\":[]},{\"env\":\"staging\"", "\"others\":false,\"approvers\":[],\"x\":1},{\"env\":\"staging\""),
text.replace(
"\"others\":false,\"approvers\":[]},{\"env\":\"staging\"",
"\"others\":false,\"approvers\":[],\"x\":1},{\"env\":\"staging\"",
),
] {
assert!(Policy::parse(&bad).is_err(), "{bad}");
}
@@ -178,7 +192,11 @@ fn the_identity_signs_the_policy_and_nothing_else_passes_for_it() {
let text = Policy::default_for(TEAM).canonical();
let sig = identity.sign_policy(&text);
assert!(custos_team::member::verify_policy_sig(&identity.public(), &text, &sig));
assert!(!custos_team::member::verify_policy_sig(&identity.public(), &text.replace("\"approvals\":1,\"others\":true", "\"approvals\":0,\"others\":true"), &sig));
assert!(!custos_team::member::verify_policy_sig(
&identity.public(),
&text.replace("\"approvals\":1,\"others\":true", "\"approvals\":0,\"others\":true"),
&sig
));
// A proof signature is not a policy signature.
let proof_sig = identity.sign_proof(&text);
assert!(!custos_team::member::verify_policy_sig(&identity.public(), &text, &proof_sig));