[team] Team vaults: rustfmt on the files this change touches
This commit is contained in:
@@ -43,7 +43,11 @@ fn request(vault: &Vault, env: &str, author: &str, format: Format, fabrica: &cus
|
||||
env: env.into(),
|
||||
author: author.into(),
|
||||
format,
|
||||
artifact: Artifact { name: "Arca_0.7.0_x64-setup.exe".into(), size: 13, sha256: custos_sign::sha256_hex(b"the installer") },
|
||||
artifact: Artifact {
|
||||
name: "Arca_0.7.0_x64-setup.exe".into(),
|
||||
size: 13,
|
||||
sha256: custos_sign::sha256_hex(b"the installer"),
|
||||
},
|
||||
artifact_digest: digest.to_vec(),
|
||||
image: image.into(),
|
||||
public: fabrica.public(),
|
||||
@@ -67,7 +71,9 @@ fn members_open_the_team_vault_and_outsiders_do_not() {
|
||||
assert!(matches!(Vault::open_team(&bytes, &MemberKey::generate()), Err(Error::NotAMember)));
|
||||
// A team vault is not a two-factor vault, and a personal vault is not a team vault.
|
||||
assert!(Vault::factor_kinds(&bytes).unwrap().is_empty());
|
||||
let mut personal = Vault::create(&SecretString::from("pw"), custos_vault::KdfParams { m_cost_kib: 8, t_cost: 1, p_cost: 1 }).unwrap();
|
||||
let mut personal =
|
||||
Vault::create(&SecretString::from("pw"), custos_vault::KdfParams { m_cost_kib: 8, t_cost: 1, p_cost: 1 })
|
||||
.unwrap();
|
||||
assert!(matches!(Vault::open_team(&personal.to_bytes().unwrap(), &t.a), Err(Error::NotATeam)));
|
||||
// A changed header byte (a member slot moved to another epoch) does not open.
|
||||
let mut moved = bytes.clone();
|
||||
@@ -171,7 +177,9 @@ fn contains(hay: &[u8], needle: &[u8]) -> bool {
|
||||
#[test]
|
||||
fn a_member_refuses_an_older_copy_or_another_identity() {
|
||||
let mut t = team();
|
||||
let mut own = Vault::create(&SecretString::from("pw"), custos_vault::KdfParams { m_cost_kib: 8, t_cost: 1, p_cost: 1 }).unwrap();
|
||||
let mut own =
|
||||
Vault::create(&SecretString::from("pw"), custos_vault::KdfParams { m_cost_kib: 8, t_cost: 1, p_cost: 1 })
|
||||
.unwrap();
|
||||
// Mark's own vault holds his member key; the team was made with the same key.
|
||||
let c = MemberKey::generate();
|
||||
let code = c.public().join_code();
|
||||
@@ -192,15 +200,29 @@ fn the_policy_is_set_per_environment_signed_and_kept() {
|
||||
let mut t = team();
|
||||
let p = t
|
||||
.vault
|
||||
.team_set_rule(EnvRule { env: "staging".into(), approvals: 1, others: true, approvers: vec![t.b.id()] }, &t.a.id(), NOW)
|
||||
.team_set_rule(
|
||||
EnvRule { env: "staging".into(), approvals: 1, others: true, approvers: vec![t.b.id()] },
|
||||
&t.a.id(),
|
||||
NOW,
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(p.rev, 2);
|
||||
assert!(t.vault.team_set_rule(EnvRule { env: "staging".into(), approvals: 1, others: true, approvers: vec!["ab".repeat(16)] }, &t.a.id(), NOW).is_err());
|
||||
assert!(
|
||||
t.vault
|
||||
.team_set_rule(
|
||||
EnvRule { env: "staging".into(), approvals: 1, others: true, approvers: vec!["ab".repeat(16)] },
|
||||
&t.a.id(),
|
||||
NOW
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
let v = Vault::open_team(&t.vault.to_bytes().unwrap(), &t.b).unwrap();
|
||||
let (text, sig) = v.team_policy_signed().unwrap();
|
||||
assert!(custos_team::member::verify_policy_sig(&v.team_identity().unwrap(), &text, &sig));
|
||||
assert_eq!(v.team_policy().unwrap().rule("staging").unwrap().approvers, vec![t.b.id()]);
|
||||
assert!(v.team_audit().unwrap().iter().any(|e| e.detail.as_deref() == Some("staging: 1 approval(s), not the author")));
|
||||
assert!(
|
||||
v.team_audit().unwrap().iter().any(|e| e.detail.as_deref() == Some("staging: 1 approval(s), not the author"))
|
||||
);
|
||||
}
|
||||
|
||||
/// Mandatory: a signing request with a wrong or replayed match code is refused.
|
||||
@@ -232,7 +254,10 @@ fn wrong_and_replayed_match_codes_are_refused() {
|
||||
assert!(eval.counted.is_empty());
|
||||
// An expired request.
|
||||
let late = request(&t.vault, "staging", "mnovak", Format::Minisign, &fabrica);
|
||||
assert_eq!(t.vault.team_sign(&late, &[], &t.a, Some(&code), None, NOW + 3_601_000).unwrap_err(), TeamError::Expired);
|
||||
assert_eq!(
|
||||
t.vault.team_sign(&late, &[], &t.a, Some(&code), None, NOW + 3_601_000).unwrap_err(),
|
||||
TeamError::Expired
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -241,7 +266,13 @@ fn two_approvals_collect_statements_and_the_last_approver_signs() {
|
||||
let c = MemberKey::generate();
|
||||
let code = c.public().join_code();
|
||||
t.vault.team_add_member(&c.public(), "Jan", &[], &t.a.id(), &code, NOW).unwrap();
|
||||
t.vault.team_set_rule(EnvRule { env: "production".into(), approvals: 2, others: true, approvers: vec![] }, &t.a.id(), NOW).unwrap();
|
||||
t.vault
|
||||
.team_set_rule(
|
||||
EnvRule { env: "production".into(), approvals: 2, others: true, approvers: vec![] },
|
||||
&t.a.id(),
|
||||
NOW,
|
||||
)
|
||||
.unwrap();
|
||||
let fabrica = custos_seal::Recipient::generate();
|
||||
let text = request(&t.vault, "production", "mnovak", Format::Minisign, &fabrica);
|
||||
let code = fabrica.match_code();
|
||||
@@ -382,15 +413,17 @@ fn a_target_credential_is_released_once_for_a_signed_deployment_of_its_project_a
|
||||
assert!(!format!("{:?}", t.vault.team_targets().unwrap()).contains("apiVersion"));
|
||||
let team_id = t.vault.team_view().unwrap().id;
|
||||
let fabrica = custos_seal::Recipient::generate();
|
||||
let ask = |deployment: &str| TargetRequest {
|
||||
team: team_id.clone(),
|
||||
id: custos_team::new_id(),
|
||||
target: target.clone(),
|
||||
deployment: deployment.into(),
|
||||
public: fabrica.public(),
|
||||
expires: NOW_S + 600,
|
||||
}
|
||||
.canonical();
|
||||
let ask = |deployment: &str| {
|
||||
TargetRequest {
|
||||
team: team_id.clone(),
|
||||
id: custos_team::new_id(),
|
||||
target: target.clone(),
|
||||
deployment: deployment.into(),
|
||||
public: fabrica.public(),
|
||||
expires: NOW_S + 600,
|
||||
}
|
||||
.canonical()
|
||||
};
|
||||
// No signed deployment yet.
|
||||
let unsigned = "ab".repeat(32);
|
||||
assert!(t.vault.team_target_release(&ask(&unsigned), &t.b.id(), NOW).is_err());
|
||||
|
||||
Reference in New Issue
Block a user