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
|
mod common;
use common::Environment;
#[test]
fn export() -> anyhow::Result<()> {
let e = Environment::new()?;
let (alice, _alice_pgp) = e.gen("alice", None, None);
let (bob, _bob_pgp) = e.gen("bob", None, None);
// Add alice.
e.sq_git(&[
"policy",
"authorize",
"alice", &alice.fingerprint().to_string(),
"--project-maintainer"
])?;
e.git(&["add", "openpgp-policy.toml"])?;
e.git(&[
"commit",
"-m", "Initial commit.",
&format!("-S{}", alice.fingerprint()),
])?;
let root = e.git_current_commit()?;
e.sq_git(&["log", "--trust-root", &root])?;
e.check_export("alice", None, &[ &alice ]);
e.check_export(None, None, &[ &alice ]);
e.check_export("bob", None, &[ ]);
// Add alice.
e.sq_git(&[
"policy",
"authorize",
"bob", &bob.fingerprint().to_string(),
"--project-maintainer"
])?;
e.git(&["add", "openpgp-policy.toml"])?;
e.git(&[
"commit",
"-m", "Add Bob as co-maintainer.",
&format!("-S{}", alice.fingerprint()),
])?;
let _c2 = e.git_current_commit()?;
e.sq_git(&["log", "--trust-root", &root])?;
e.check_export("alice", None, &[ &alice ]);
e.check_export(None, None, &[ &alice, &bob ]);
e.check_export("bob", None, &[ &bob ]);
// Make sure using a commit works.
e.check_export("alice", &root[..], &[ &alice ]);
e.check_export(None, &root[..], &[ &alice ]);
e.check_export("bob", &root[..], &[ ]);
Ok(())
}
|