| 1 |
use anyhow::Result; |
| 2 |
|
| 3 |
use sequoia_openpgp as openpgp; |
| 4 |
use openpgp::{ |
| 5 |
cert::prelude::*, |
| 6 |
parse::Parse, |
| 7 |
serialize::{ |
| 8 |
Serialize, |
| 9 |
SerializeInto, |
| 10 |
}, |
| 11 |
}; |
| 12 |
|
| 13 |
use super::super::*; |
| 14 |
|
| 15 |
const PLAINTEXT: &[u8] = b"plaintext"; |
| 16 |
|
| 17 |
// We import a certificate, which is not ultimately trusted, and use |
| 18 |
// --command-fd and --status-fd. When gpg is run, it should prompt |
| 19 |
// for confirmation via status-fd using a machine readable (rather |
| 20 |
// than human readable) prompt. |
| 21 |
#[test] |
| 22 |
#[ntest::timeout(600000)] |
| 23 |
fn untrusted_certificate_prompt() -> Result<()> { |
| 24 |
let cs = CipherSuite::Cv25519; |
| 25 |
|
| 26 |
let mut experiment = make_experiment!(format!("{:?}", cs))?; |
| 27 |
let cert = experiment.artifact( |
| 28 |
"cert", |
| 29 |
|| CertBuilder::general_purpose( |
| 30 |
Some("Alice Lovelace <[email protected]>")) |
| 31 |
.set_cipher_suite(cs) |
| 32 |
.set_creation_time(Experiment::now()) |
| 33 |
.generate() |
| 34 |
.map(|(cert, _rev)| cert), |
| 35 |
|a, f| a.serialize(f), |
| 36 |
|b| Cert::from_bytes(&b))?; |
| 37 |
|
| 38 |
experiment.section("Importing cert..."); |
| 39 |
let diff = experiment.invoke(&[ |
| 40 |
"--import", |
| 41 |
&experiment.store("cert", &cert.to_vec()?)?, |
| 42 |
])?; |
| 43 |
diff.assert_success(); |
| 44 |
diff.assert_equal_up_to(0, 0); |
| 45 |
|
| 46 |
let diff = experiment.invoke(&[ |
| 47 |
"--command-fd=0", |
| 48 |
"--encrypt", |
| 49 |
"--recipient", "<[email protected]>", |
| 50 |
"--output", "ciphertext", |
| 51 |
&experiment.store("plaintext", PLAINTEXT)?, |
| 52 |
])?; |
| 53 |
|
| 54 |
diff.assert_failure(); |
| 55 |
diff.assert_limits(0, 0, 201); |
| 56 |
|
| 57 |
Ok(()) |
| 58 |
} |