tests: Add more tests for sq encrypt.

This commit is contained in:
Neal H. Walfield 2024-11-22 21:39:05 +01:00
parent 258394678f
commit c51e657fcc
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3

View File

@ -1,6 +1,7 @@
use std::collections::HashSet;
use sequoia_openpgp as openpgp;
use openpgp::Cert;
use openpgp::KeyHandle;
use openpgp::KeyID;
use openpgp::Fingerprint;
@ -788,3 +789,26 @@ fn sq_encrypt_revoked() -> Result<()>
Ok(())
}
// Try encrypting to a certificate with a weakly bound key. Make sure
// it fails.
#[test]
fn sq_encrypt_weak() -> Result<()>
{
let mut sq = Sq::new();
let cert_path = sq.test_data()
.join("keys")
.join("sha1-subkey-priv.pgp");
sq.key_import(&cert_path);
let cert = Cert::from_file(&cert_path).expect("can read");
sq.tick(1);
// Two days pass...
sq.tick(2 * 24 * 60 * 60);
try_encrypt(&sq, &[], &[], &[ &cert.fingerprint() ], &[], &[]);
Ok(())
}