Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests to cover all unformatted UUID commands #3610

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 134 additions & 3 deletions tests/stratis_min.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ fn test_stratis_min_create_no_blockdevs() {
}

#[test]
// Test stopping a pool using an invalid name, that will fail with a
// "Uuid error".
fn test_stratis_min_pool_stop_invalid_name() {
// Test stopping a pool using an invalid UUID; unless name is specified the
// id value is interpreted as a UUID.
fn test_stratis_min_pool_stop_invalid_uuid() {
let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("stop").arg("pn");
cmd.assert()
Expand All @@ -175,6 +175,137 @@ fn test_stratis_min_pool_stop_invalid_name() {
.stderr(predicate::str::contains("Uuid error"));
}

#[test]
// Test starting a pool using an invalid UUID; unless name is specified the
// id value is interpreted as a UUID.
fn test_stratis_min_pool_start_invalid_uuid() {
let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("start").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));
}

#[test]
// Test binding a pool using an invalid UUID; unless name is specified the
// id value is interpreted as a UUID.
fn test_stratis_min_pool_bind_invalid_uuid() {
let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool")
.arg("bind")
.arg("keyring")
.arg("pn")
.arg("--key-desc")
.arg("desc");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool")
.arg("bind")
.arg("tang")
.arg("pn")
.arg("http://abc")
.arg("--trust-url");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("bind").arg("tpm2").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));
}

#[test]
// Test unbinding a pool using an invalid UUID; unless name is specified the
// id value is interpreted as a UUID.
fn test_stratis_min_pool_unbind_invalid_uuid() {
let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("unbind").arg("keyring").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("unbind").arg("clevis").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));
}

#[test]
// Test rebinding a pool using an invalid UUID; unless name is specified the
// id value is interpreted as a UUID.
fn test_stratis_min_pool_rebind_invalid_uuid() {
let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool")
.arg("rebind")
.arg("keyring")
.arg("--key-desc")
.arg("desc")
.arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("rebind").arg("clevis").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));
}

#[test]
// Test checking a pool property using an invalid UUID; unless name is
// specified the id value is interpreted as a UUID.
fn test_stratis_min_pool_properties_invalid_uuid() {
let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("is-encrypted").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("is-stopped").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("is-bound").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("has-passphrase").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));

let mut cmd = Command::cargo_bin("stratis-min").unwrap();
cmd.arg("pool").arg("clevis-pin").arg("pn");
cmd.assert()
.failure()
.code(1)
.stderr(predicate::str::contains("Uuid error"));
}

#[test]
// Test running "stratis pool bind" with missing subcommand.
fn test_stratis_min_pool_bind_missing_subcommand() {
Expand Down
Loading