diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2018-11-26 17:24:47 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2018-11-26 19:50:41 +0100 |
commit | 02e61f0758e93b44a054a01b4137ea25ff7dd5ec (patch) | |
tree | b1ef6b097e5fc93faf20433219565bbabfa04fb5 /sqv/tests | |
parent | 557aca35bad457622642308c1d780757b174bf50 (diff) |
sqv: Move sqv into a new crate.
- This allows us to use sequoia-openpgp without compression support
reducing binary size and trusted computing base.
Diffstat (limited to 'sqv/tests')
-rw-r--r-- | sqv/tests/bad-subkey.rs | 18 | ||||
-rw-r--r-- | sqv/tests/data/bad-subkey-keyring.pgp | bin | 0 -> 18064 bytes | |||
-rw-r--r-- | sqv/tests/data/bad-subkey-keyring.txt | 12 | ||||
-rw-r--r-- | sqv/tests/data/bad-subkey.txt | 1 | ||||
-rw-r--r-- | sqv/tests/data/bad-subkey.txt.sig | bin | 0 -> 310 bytes | |||
-rw-r--r-- | sqv/tests/duplicate-signatures.rs | 31 | ||||
-rw-r--r-- | sqv/tests/multiple-signatures.rs | 24 | ||||
-rw-r--r-- | sqv/tests/not-before-after.rs | 62 |
8 files changed, 148 insertions, 0 deletions
diff --git a/sqv/tests/bad-subkey.rs b/sqv/tests/bad-subkey.rs new file mode 100644 index 00000000..6a6b7fc7 --- /dev/null +++ b/sqv/tests/bad-subkey.rs @@ -0,0 +1,18 @@ +extern crate assert_cli; + +#[cfg(test)] +mod integration { + use std::path; + + use assert_cli::Assert; + + #[test] + fn bad_subkey() { + Assert::cargo_binary("sqv") + .current_dir(path::Path::new("tests").join("data")) + .with_args(&["-r", "bad-subkey-keyring.pgp", + "bad-subkey.txt.sig", "bad-subkey.txt"]) + .stdout().is("8F17 7771 18A3 3DDA 9BA4 8E62 AACB 3243 6300 52D9") + .unwrap(); + } +} diff --git a/sqv/tests/data/bad-subkey-keyring.pgp b/sqv/tests/data/bad-subkey-keyring.pgp Binary files differnew file mode 100644 index 00000000..72acf4de --- /dev/null +++ b/sqv/tests/data/bad-subkey-keyring.pgp diff --git a/sqv/tests/data/bad-subkey-keyring.txt b/sqv/tests/data/bad-subkey-keyring.txt new file mode 100644 index 00000000..d98d157b --- /dev/null +++ b/sqv/tests/data/bad-subkey-keyring.txt @@ -0,0 +1,12 @@ +This key keyring contains two keys in the following order: "Justus", +"Neal". + +Justus's key includes all of Neal's subkeys. When Justus's key is +canonicalized, Neal's subkeys should be dropped. + +If an application looks for Neal's signing subkey and either doesn't +validate the keys or only filters on the unvalidated keys, then it +will not find the right key. + +This was fixed in sqv in commit +1d63e71a839bf68f50cb7f4c1942f0d0b1eccfca. diff --git a/sqv/tests/data/bad-subkey.txt b/sqv/tests/data/bad-subkey.txt new file mode 100644 index 00000000..257cc564 --- /dev/null +++ b/sqv/tests/data/bad-subkey.txt @@ -0,0 +1 @@ +foo diff --git a/sqv/tests/data/bad-subkey.txt.sig b/sqv/tests/data/bad-subkey.txt.sig Binary files differnew file mode 100644 index 00000000..65fc578c --- /dev/null +++ b/sqv/tests/data/bad-subkey.txt.sig diff --git a/sqv/tests/duplicate-signatures.rs b/sqv/tests/duplicate-signatures.rs new file mode 100644 index 00000000..691afb50 --- /dev/null +++ b/sqv/tests/duplicate-signatures.rs @@ -0,0 +1,31 @@ +extern crate assert_cli; + +use assert_cli::Assert; + +fn p(filename: &str) -> String { + format!("../openpgp/tests/data/{}", filename) +} + +/// Asserts that duplicate signatures are properly ignored. +#[test] +fn ignore_duplicates() { + // Duplicate is ignored, but remaining one is ok. + Assert::cargo_binary("sqv") + .with_args( + &["-r", + &p("keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"), + &p("messages/a-cypherpunks-manifesto.txt.ed25519.sig.duplicated"), + &p("messages/a-cypherpunks-manifesto.txt")]) + .unwrap(); + + // Duplicate is ignored, and fails to meet the threshold. + Assert::cargo_binary("sqv") + .with_args( + &["-r", + &p("keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"), + "--signatures=2", + &p("messages/a-cypherpunks-manifesto.txt.ed25519.sig.duplicated"), + &p("messages/a-cypherpunks-manifesto.txt")]) + .fails() + .unwrap(); +} diff --git a/sqv/tests/multiple-signatures.rs b/sqv/tests/multiple-signatures.rs new file mode 100644 index 00000000..a2bff844 --- /dev/null +++ b/sqv/tests/multiple-signatures.rs @@ -0,0 +1,24 @@ +extern crate assert_cli; + +use assert_cli::Assert; + +fn p(filename: &str) -> String { + format!("../openpgp/tests/data/{}", filename) +} + +/// Asserts that multiple signatures from the same TPK are properly +/// ignored. +#[test] +fn ignore_multiple_signatures() { + // Multiple signatures from the same TPK are ignored, and fails to + // meet the threshold. + Assert::cargo_binary("sqv") + .with_args( + &["-r", + &p("keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"), + "--signatures=2", + &p("messages/a-cypherpunks-manifesto.txt.ed25519.sig.duplicated"), + &p("messages/a-cypherpunks-manifesto.txt")]) + .fails() + .unwrap(); +} diff --git a/sqv/tests/not-before-after.rs b/sqv/tests/not-before-after.rs new file mode 100644 index 00000000..5be41bf0 --- /dev/null +++ b/sqv/tests/not-before-after.rs @@ -0,0 +1,62 @@ +extern crate assert_cli; + +#[cfg(test)] +mod integration { + use assert_cli::Assert; + + fn p(filename: &str) -> String { + format!("../openpgp/tests/data/{}", filename) + } + + #[test] + fn unconstrained() { + Assert::cargo_binary("sqv") + .with_args( + &["-r", + &p("keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"), + &p("messages/a-cypherpunks-manifesto.txt.ed25519.sig"), + &p("messages/a-cypherpunks-manifesto.txt")]) + .stdout().is("8E8C 33FA 4626 3379 76D9 7978 069C 0C34 8DD8 2C19") + .unwrap(); + } + + #[test] + fn in_interval() { + Assert::cargo_binary("sqv") + .with_args( + &["-r", + &p("keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"), + "--not-before", "2018-08-14", + "--not-after", "2018-08-15", + &p("messages/a-cypherpunks-manifesto.txt.ed25519.sig"), + &p("messages/a-cypherpunks-manifesto.txt")]) + .stdout().is("8E8C 33FA 4626 3379 76D9 7978 069C 0C34 8DD8 2C19") + .unwrap(); + } + + #[test] + fn before() { + Assert::cargo_binary("sqv") + .with_args( + &["-r", + &p("keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"), + "--not-before", "2018-08-15", + &p("messages/a-cypherpunks-manifesto.txt.ed25519.sig"), + &p("messages/a-cypherpunks-manifesto.txt")]) + .fails() + .unwrap(); + } + + #[test] + fn after() { + Assert::cargo_binary("sqv") + .with_args( + &["-r", + &p("keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp"), + "--not-after", "2018-08-14", + &p("messages/a-cypherpunks-manifesto.txt.ed25519.sig"), + &p("messages/a-cypherpunks-manifesto.txt")]) + .fails() + .unwrap(); + } +} |