summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-12-02 21:48:59 +0100
committerNora Widdecke <nora@sequoia-pgp.org>2022-02-25 12:51:57 +0100
commit0fb0297f0297cf6c048216a357d65a3689a0bdb5 (patch)
tree222dae252baae42cc425cddb8f1732d6b6f7d4a0
parent2c5c40988d692fc8eb6421e8ed33dec471c73235 (diff)
sq: Use only assert_cmd.
- assert_cli has been deprecated for a long time, assert_cmd is the successor. - a4cfd15805a543a327d2242f9c0f2b653a11ee55 introduced assert_cmd to sq, in addition to assert_cli. It does not make sense to use two different crates for cli testing. - Closes #640.
-rw-r--r--Cargo.lock91
-rw-r--r--sq/Cargo.toml4
-rw-r--r--sq/tests/sq-certify.rs127
-rw-r--r--sq/tests/sq-key-adopt.rs208
-rw-r--r--sq/tests/sq-sign.rs557
5 files changed, 463 insertions, 524 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4a1e49e2..6572ef9e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -100,20 +100,6 @@ dependencies = [
]
[[package]]
-name = "assert_cli"
-version = "0.6.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a29ab7c0ed62970beb0534d637a8688842506d0ff9157de83286dacd065c8149"
-dependencies = [
- "colored",
- "difference",
- "environment",
- "failure",
- "failure_derive",
- "serde_json",
-]
-
-[[package]]
name = "assert_cmd"
version = "2.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -504,17 +490,6 @@ dependencies = [
]
[[package]]
-name = "colored"
-version = "1.9.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f4ffc801dacf156c5854b9df4f425a626539c3a6ef7893cc0c5084a23f0b6c59"
-dependencies = [
- "atty",
- "lazy_static",
- "winapi",
-]
-
-[[package]]
name = "const-oid"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -758,12 +733,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499"
[[package]]
-name = "difference"
-version = "2.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
-
-[[package]]
name = "difflib"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -926,34 +895,6 @@ dependencies = [
]
[[package]]
-name = "environment"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1f4b14e20978669064c33b4c1e0fb4083412e40fe56cbea2eae80fd7591503ee"
-
-[[package]]
-name = "failure"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86"
-dependencies = [
- "backtrace",
- "failure_derive",
-]
-
-[[package]]
-name = "failure_derive"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn",
- "synstructure",
-]
-
-[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1027,6 +968,15 @@ dependencies = [
]
[[package]]
+name = "float-cmp"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1797,6 +1747,12 @@ dependencies = [
]
[[package]]
+name = "normalize-line-endings"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
+
+[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2221,21 +2177,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5aab5be6e4732b473071984b3164dbbfb7a3674d30ea5ff44410b6bcd960c3c"
dependencies = [
"difflib",
+ "float-cmp",
"itertools 0.10.1",
+ "normalize-line-endings",
"predicates-core",
+ "regex",
]
[[package]]
name = "predicates-core"
-version = "1.0.3"
+version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "da1c2388b1513e1b605fcec39a95e0a9e8ef088f71443ef37099fa9ae6673fcb"
+checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451"
[[package]]
name = "predicates-tree"
-version = "1.0.5"
+version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4d86de6de25020a36c6d3643a86d9a6a9f552107c0559c60ea03551b5e16c032"
+checksum = "338c7be2905b732ae3984a2f40032b5e94fd8f52505b186c7d4d68d193445df7"
dependencies = [
"predicates-core",
"termtree",
@@ -2785,13 +2744,13 @@ name = "sequoia-sq"
version = "0.25.0"
dependencies = [
"anyhow",
- "assert_cli",
"assert_cmd",
"buffered-reader",
"chrono",
"clap",
"fehler",
"itertools 0.9.0",
+ "predicates",
"rpassword",
"sequoia-autocrypt",
"sequoia-net",
@@ -3254,9 +3213,9 @@ dependencies = [
[[package]]
name = "termtree"
-version = "0.2.4"
+version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b"
+checksum = "13a4ec180a2de59b57434704ccfad967f789b12737738798fa08798cd5824c16"
[[package]]
name = "textwrap"
diff --git a/sq/Cargo.toml b/sq/Cargo.toml
index 2d9a29b5..297f9412 100644
--- a/sq/Cargo.toml
+++ b/sq/Cargo.toml
@@ -45,10 +45,10 @@ sequoia-openpgp = { path = "../openpgp", version = "1.0.0", default-features = f
subplot-build = "0.1.0"
[dev-dependencies]
-assert_cli = "0.6"
-assert_cmd = "2.0.4"
subplotlib = "0.1.0"
fehler = "1.0.0"
+assert_cmd = "2.0.4"
+predicates = "2"
[[bin]]
name = "sq"
diff --git a/sq/tests/sq-certify.rs b/sq/tests/sq-certify.rs
index b6a670d8..4cbd0a9c 100644
--- a/sq/tests/sq-certify.rs
+++ b/sq/tests/sq-certify.rs
@@ -2,9 +2,9 @@ use std::fs::File;
use std::time;
use std::time::Duration;
-use assert_cli::Assert;
-use assert_cmd::Command;
use tempfile::TempDir;
+use assert_cmd::Command;
+use predicates::prelude::*;
use sequoia_openpgp as openpgp;
use openpgp::Result;
@@ -38,14 +38,15 @@ fn sq_certify() -> Result<()> {
// A simple certification.
- Assert::cargo_binary("sq")
- .with_args(
- &["certify",
- alice_pgp.to_str().unwrap(),
- bob_pgp.to_str().unwrap(),
- "bob@example.org",
- ])
- .stdout().satisfies(|output| {
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("certify")
+ .arg(alice_pgp.to_str().unwrap())
+ .arg(bob_pgp.to_str().unwrap())
+ .arg("bob@example.org")
+ .assert()
+ .success()
+ .stdout(predicate::function(|output: &[u8]| -> bool {
let cert = Cert::from_bytes(output).unwrap();
let vc = cert.with_policy(P, None).unwrap();
@@ -66,22 +67,21 @@ fn sq_certify() -> Result<()> {
return true;
}
}
-
false
},
- "Bad certification")
- .unwrap();
+ ));
// No expiry.
- Assert::cargo_binary("sq")
- .with_args(
- &["certify",
- alice_pgp.to_str().unwrap(),
- bob_pgp.to_str().unwrap(),
- "bob@example.org",
- "--expires", "never"
- ])
- .stdout().satisfies(|output| {
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("certify")
+ .arg(alice_pgp.to_str().unwrap())
+ .arg(bob_pgp.to_str().unwrap())
+ .arg("bob@example.org")
+ .args(["--expires", "never"])
+ .assert()
+ .success()
+ .stdout(predicate::function(|output: &[u8]| -> bool {
let cert = Cert::from_bytes(output).unwrap();
let vc = cert.with_policy(P, None).unwrap();
@@ -103,26 +103,25 @@ fn sq_certify() -> Result<()> {
}
false
- },
- "Bad certification")
- .unwrap();
+ }));
// Have alice certify bob@example.org for 0xB0B.
- Assert::cargo_binary("sq")
- .with_args(
- &["certify",
- alice_pgp.to_str().unwrap(),
- bob_pgp.to_str().unwrap(),
- "bob@example.org",
- "--depth", "10",
- "--amount", "5",
- "--regex", "a",
- "--regex", "b",
- "--local",
- "--non-revocable",
- "--expires-in", "1d",
- ])
- .stdout().satisfies(|output| {
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("certify")
+ .arg(alice_pgp.to_str().unwrap())
+ .arg(bob_pgp.to_str().unwrap())
+ .arg("bob@example.org")
+ .args(["--depth", "10"])
+ .args(["--amount", "5"])
+ .args(["--regex", "a"])
+ .args(["--regex", "b"])
+ .arg("--local")
+ .arg("--non-revocable")
+ .args(["--expires-in", "1d"])
+ .assert()
+ .success()
+ .stdout(predicate::function(|output: &[u8]| -> bool {
let cert = Cert::from_bytes(output).unwrap();
let vc = cert.with_policy(P, None).unwrap();
@@ -146,33 +145,31 @@ fn sq_certify() -> Result<()> {
}
false
- },
- "Bad certification")
- .unwrap();
+ }));
// It should fail if the User ID doesn't exist.
- Assert::cargo_binary("sq")
- .with_args(
- &["certify",
- alice_pgp.to_str().unwrap(),
- bob_pgp.to_str().unwrap(),
- "bob",
- ])
- .fails()
- .unwrap();
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("certify")
+ .arg(alice_pgp.to_str().unwrap())
+ .arg(bob_pgp.to_str().unwrap())
+ .arg("bob")
+ .assert()
+ .failure();
// With a notation.
- Assert::cargo_binary("sq")
- .with_args(
- &["certify",
- "--notation", "foo", "bar",
- "--notation", "!foo", "xyzzy",
- "--notation", "hello@example.org", "1234567890",
- alice_pgp.to_str().unwrap(),
- bob_pgp.to_str().unwrap(),
- "bob@example.org",
- ])
- .stdout().satisfies(|output| {
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("certify")
+ .args(["--notation", "foo", "bar"])
+ .args(["--notation", "!foo", "xyzzy"])
+ .args(["--notation", "hello@example.org", "1234567890"])
+ .arg(alice_pgp.to_str().unwrap())
+ .arg(bob_pgp.to_str().unwrap())
+ .arg("bob@example.org")
+ .assert()
+ .success()
+ .stdout(predicate::function(|output: &[u8]| -> bool {
let cert = Cert::from_bytes(output).unwrap();
// The standard policy will reject the
@@ -239,9 +236,7 @@ fn sq_certify() -> Result<()> {
}
false
- },
- "Bad certification")
- .unwrap();
+ }));
Ok(())
}
diff --git a/sq/tests/sq-key-adopt.rs b/sq/tests/sq-key-adopt.rs
index 5bb40f32..b3097f14 100644
--- a/sq/tests/sq-key-adopt.rs
+++ b/sq/tests/sq-key-adopt.rs
@@ -2,7 +2,8 @@
mod integration {
use std::path;
- use assert_cli::Assert;
+ use assert_cmd::Command;
+ use predicates::prelude::*;
use sequoia_openpgp as openpgp;
@@ -140,15 +141,15 @@ mod integration {
#[test]
fn adopt_encryption() -> Result<()> {
// Adopt an encryption subkey.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_encryption().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 2, (bob_primary(), &[alice_encryption()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_encryption().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 2, (bob_primary(), &[alice_encryption()])).is_ok()
+ }));
Ok(())
}
@@ -156,15 +157,15 @@ mod integration {
#[test]
fn adopt_signing() -> Result<()> {
// Adopt a signing subkey (subkey has secret key material).
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_signing().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 2, (bob_primary(), &[alice_signing()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_signing().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 2, (bob_primary(), &[alice_signing()])).is_ok()
+ }));
Ok(())
}
@@ -172,15 +173,15 @@ mod integration {
#[test]
fn adopt_certification() -> Result<()> {
// Adopt a certification subkey (subkey has secret key material).
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- carol().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_primary().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 4, (carol_primary(), &[alice_primary()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(carol())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_primary().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 4, (carol_primary(), &[alice_primary()])).is_ok()
+ }));
Ok(())
}
@@ -188,18 +189,19 @@ mod integration {
#[test]
fn adopt_encryption_and_signing() -> Result<()> {
// Adopt an encryption subkey and a signing subkey.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_signing().0.to_hex(),
- "--key", &alice_encryption().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 3,
- (bob_primary(),
- &[alice_signing(), alice_encryption()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_signing().0.to_hex())
+ .arg("--key").arg(alice_encryption().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 3,
+ (bob_primary(),
+ &[alice_signing(), alice_encryption()]))
+ .is_ok()
+ }));
Ok(())
}
@@ -207,16 +209,16 @@ mod integration {
#[test]
fn adopt_twice() -> Result<()> {
// Adopt the same an encryption subkey twice.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_encryption().0.to_hex(),
- "--key", &alice_encryption().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 2, (bob_primary(), &[alice_encryption()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_encryption().0.to_hex())
+ .arg("--key").arg(alice_encryption().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 2, (bob_primary(), &[alice_encryption()])).is_ok()
+ }));
Ok(())
}
@@ -224,16 +226,16 @@ mod integration {
#[test]
fn adopt_key_appears_twice() -> Result<()> {
// Adopt the an encryption subkey that appears twice.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_encryption().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 2, (bob_primary(), &[alice_encryption()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(alice())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_encryption().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 2, (bob_primary(), &[alice_encryption()])).is_ok()
+ }));
Ok(())
}
@@ -241,16 +243,15 @@ mod integration {
#[test]
fn adopt_own_encryption() -> Result<()> {
// Adopt its own encryption subkey. This should be a noop.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- alice().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_encryption().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 3, (alice_primary(),
- &[alice_encryption()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(alice())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_encryption().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 3, (alice_primary(), &[alice_encryption()])).is_ok()
+ }));
Ok(())
}
@@ -258,15 +259,15 @@ mod integration {
#[test]
fn adopt_own_primary() -> Result<()> {
// Adopt own primary key.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", bob().to_str().unwrap(),
- "--key", &bob_primary().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 2, (bob_primary(), &[bob_primary()]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(bob())
+ .arg("--key").arg(bob_primary().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 2, (bob_primary(), &[bob_primary()])).is_ok()
+ }));
Ok(())
}
@@ -274,12 +275,12 @@ mod integration {
#[test]
fn adopt_missing() -> Result<()> {
// Adopt a key that is not present.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", bob().to_str().unwrap(),
- "--key", "1234 5678 90AB CDEF 1234 5678 90AB CDEF"
- ]).fails().unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(bob())
+ .arg("--key").arg("1234 5678 90AB CDEF 1234 5678 90AB CDEF")
+ .assert()
+ .code(1);
Ok(())
}
@@ -287,24 +288,25 @@ mod integration {
#[test]
fn adopt_from_multiple() -> Result<()> {
// Adopt from multiple certificates simultaneously.
- Assert::cargo_binary("sq").with_args(&[
- "key", "adopt",
- bob().to_str().unwrap(),
- "--keyring", alice().to_str().unwrap(),
- "--key", &alice_signing().0.to_hex(),
- "--key", &alice_encryption().0.to_hex(),
- "--keyring", carol().to_str().unwrap(),
- "--key", &carol_signing().0.to_hex(),
- "--key", &carol_encryption().0.to_hex(),
- ]).stdout().satisfies(|output| {
- check(output.as_bytes(), 5,
- (bob_primary(),
- &[
- alice_signing(), alice_encryption(),
- carol_signing(), carol_encryption()
- ]))
- .is_ok()
- }, "check failed").unwrap();
+ Command::cargo_bin("sq").unwrap().arg("key").arg("adopt")
+ .arg(bob())
+ .arg("--keyring").arg(alice())
+ .arg("--key").arg(alice_signing().0.to_hex())
+ .arg("--key").arg(alice_encryption().0.to_hex())
+ .arg("--keyring").arg(carol())
+ .arg("--key").arg(carol_signing().0.to_hex())
+ .arg("--key").arg(carol_encryption().0.to_hex())
+ .assert()
+ .code(0)
+ .stdout(predicate::function(|output: &[u8]| -> bool {
+ check(output, 5,
+ (bob_primary(),
+ &[
+ alice_signing(), alice_encryption(),
+ carol_signing(), carol_encryption()
+ ]))
+ .is_ok()
+ }));
Ok(())
}
diff --git a/sq/tests/sq-sign.rs b/sq/tests/sq-sign.rs
index 97d0a40b..b9208c8a 100644
--- a/sq/tests/sq-sign.rs
+++ b/sq/tests/sq-sign.rs
@@ -1,9 +1,8 @@
use std::fs::{self, File};
use std::io;
-use assert_cmd::Command;
-use assert_cli::Assert;
use tempfile::TempDir;
+use assert_cmd::Command;
use sequoia_openpgp as openpgp;
use openpgp::Fingerprint;
@@ -33,15 +32,14 @@ fn sq_sign() {
let sig = tmp_dir.path().join("sig0");
// Sign message.
- Assert::cargo_binary("sq")
- .with_args(
- &["sign",
- "--signer-key",
- &artifact("keys/dennis-simon-anton-private.pgp"),
- "--output",
- &sig.to_string_lossy(),
- &artifact("messages/a-cypherpunks-manifesto.txt")])
- .unwrap();
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("sign")
+ .args(["--signer-key", &artifact("keys/dennis-simon-anton-private.pgp")])
+ .args(["--output", &sig.to_string_lossy()])
+ .arg(&artifact("messages/a-cypherpunks-manifesto.txt"))
+ .assert()
+ .success();
// Check that the content is sane.
let packets: Vec<Packet> =
@@ -68,13 +66,13 @@ fn sq_sign() {
assert!(&content[..].starts_with(b"-----BEGIN PGP MESSAGE-----\n\n"));
// Verify signed message.
- Assert::cargo_binary("sq")
- .with_args(
- &["verify",
- "--signer-cert",
- &artifact("keys/dennis-simon-anton.pgp"),
- &sig.to_string_lossy()])
- .unwrap();
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("verify")
+ .args(["--signer-cert", &artifact("keys/dennis-simon-anton.pgp")])
+ .arg(&*sig.to_string_lossy())
+ .assert()
+ .success();
}
#[test]
@@ -83,18 +81,17 @@ fn sq_sign_with_notations() {
let sig = tmp_dir.path().join("sig0");
// Sign message.
- Assert::cargo_binary("sq")
- .with_args(
- &["sign",
- "--signer-key",
- &artifact("keys/dennis-simon-anton-private.pgp"),
- "--output",
- &sig.to_string_lossy(),
- "--notation", "foo", "bar",
- "--notation", "!foo", "xyzzy",
- "--notation", "hello@example.org", "1234567890",
- &artifact("messages/a-cypherpunks-manifesto.txt")])
- .unwrap();
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("sign")
+ .args(["--signer-key", &artifact("keys/dennis-simon-anton-private.pgp")])
+ .args(["--output", &sig.to_string_lossy()])
+ .args(["--notation", "foo", "bar"])
+ .args(["--notation", "!foo", "xyzzy"])
+ .args(["--notation", "hello@example.org", "1234567890"])
+ .arg(&artifact("messages/a-cypherpunks-manifesto.txt"))
+ .assert()
+ .success();
// Check that the content is sane.
let packets: Vec<Packet> =
@@ -146,14 +143,14 @@ fn sq_sign_with_notations() {
assert!(&content[..].starts_with(b"-----BEGIN PGP MESSAGE-----\n\n"));
// Verify signed message.
- Assert::cargo_binary("sq")
- .with_args(
- &["--known-notation", "foo",
- "verify",
- "--signer-cert",
- &artifact("keys/dennis-simon-anton.pgp"),
- &sig.to_string_lossy()])
- .unwrap();
+ Command::cargo_bin("sq")
+ .unwrap()
+ .args(["--known-notation", "foo"])
+ .arg("verify")
+ .args(["--signer-cert", &artifact("keys/dennis-simon-anton.pgp")])
+ .arg(&*sig.to_string_lossy())
+ .assert()
+ .success();
}
#[test]
@@ -162,15 +159,14 @@ fn sq_sign_append() {
let sig0 = tmp_dir.path().join("sig0");
// Sign message.
- Assert::cargo_binary("sq")
- .with_args(
- &["sign",
- "--signer-key",
- &artifact("keys/dennis-simon-anton-private.pgp"),
- "--output",
- &sig0.to_string_lossy(),
- &artifact("messages/a-cypherpunks-manifesto.txt")])
- .unwrap();
+ Command::cargo_bin("sq")
+ .unwrap()
+ .arg("sign")
+ .args(["--signer-key", &artifact("keys/dennis-simon-anton-private.pgp")])
+ .args(["--output", &sig0.to_string_lossy()])
+ .arg(&artifact("messages/a-cypherpunks-manifesto.txt"))
<