Pre-generate more keys for use in integration tests

This commit is contained in:
Floris Bruynooghe
2020-02-07 00:24:41 +01:00
committed by Alexander Krotov
parent 515c753d11
commit 1144a536a5
11 changed files with 32 additions and 6 deletions

View File

@@ -595,4 +595,25 @@ i8pcjGO+IZffvyZJVRWfVooBJmWWbPB1pueo3tx8w3+fcuzpxz+RLFKaPyqXO+dD
store_self_keypair(&t.ctx, &KEYPAIR, KeyPairUse::Default).unwrap();
assert_eq!(nrows(), 1);
}
// Convenient way to create a new key if you need one, run with
// `cargo test key::tests::gen_key`.
// #[test]
// fn gen_key() {
// let name = "fiona";
// let keypair = crate::pgp::create_keypair(
// EmailAddress::new(&format!("{}@example.net", name)).unwrap(),
// )
// .unwrap();
// std::fs::write(
// format!("test-data/key/{}-public.asc", name),
// keypair.public.to_base64(),
// )
// .unwrap();
// std::fs::write(
// format!("test-data/key/{}-secret.asc", name),
// keypair.secret.to_base64(),
// )
// .unwrap();
// }
}

View File

@@ -58,11 +58,7 @@ pub(crate) fn logging_cb(_ctx: &Context, evt: Event) {
///
/// This saves CPU cycles by avoiding having to generate a key.
///
/// The keypair was created using (this is purposefully not a doctest, it would be slow):
/// let keypair = crate::pgp::create_keypair(EmailAddress::new("alice@example.com"))
/// .unwrap();
/// println!("{}", keypair.public.to_base64(64));
/// println!("{}", keypair.secret.to_base64(64));
/// The keypair was created using the crate::key::tests::gen_key test.
pub(crate) fn alice_keypair() -> key::KeyPair {
let addr = EmailAddress::new("alice@example.com").unwrap();
let public =