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

test: Use stratis key set --keyfile-path #19549

Merged
merged 1 commit into from
Nov 1, 2023
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
13 changes: 9 additions & 4 deletions test/verify/check-storage-stratis
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def get_stratis_stop_type_opt(execute):
return ""


def create_pool_key(machine, keyname, passphrase):
# this is a bit complicated, see https://bugzilla.redhat.com/show_bug.cgi?id=2246923
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't actually think it's that complicated, and there is no bug worth fixing here. (Well, maybe the docs.) So I think this comment is misleading. It was a mistake to not use --keyfile-path from the start in our tests, since --capture-key is the mode for interactive use.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, if --capture-key is for interactive use, it is highly misleading. "Interactive" means "human on a tty" for me, and that is more robust than stdin. Piping in a password is usually "noninteractive"/automated in my book. But yes, we can discuss that in the bugzilla.

machine.execute(f"echo -n '{passphrase}' | stratis key set --keyfile-path /dev/stdin {keyname}")


@testlib.skipImage("No Stratis", "debian-*", "ubuntu-*")
@testlib.nondestructive
class TestStorageStratis(storagelib.StorageCase):
Expand Down Expand Up @@ -434,7 +439,7 @@ class TestStorageStratisReboot(storagelib.StorageCase):
# it. Cockpit will chose a key description for the pool and
# we occupy its first choice in order to force Cockpit to use
# something else.
m.execute("echo not-the-passphrase | stratis key set --capture-key pool0")
create_pool_key(m, "pool0", "not-the-passphrase")
self.dialog_open_with_retry(trigger=lambda: self.devices_dropdown("Create Stratis pool"),
expect=lambda: (self.dialog_is_present('disks', dev_1) and
self.dialog_check({"name": "pool0"})))
Expand Down Expand Up @@ -484,7 +489,7 @@ class TestStorageStratisReboot(storagelib.StorageCase):
'new_passphrase': "boodeefoodeebar",
'new_passphrase2': "boodeefoodeebar"})
# do it again, with the old passphrase in the keyring
m.execute("echo boodeefoodeebar | stratis key set pool0 --capture-key")
create_pool_key(m, "pool0", "boodeefoodeebar")
b.click('#detail-header .pf-v5-c-description-list__group:contains(Passphrase) button:contains(Change)')
self.dialog({'new_passphrase': passphrase,
'new_passphrase2': passphrase})
Expand Down Expand Up @@ -944,7 +949,7 @@ class TestStorageStratisNBDE(packagelib.PackageCase, storagelib.StorageCase):
b.click('#detail-header .pf-v5-c-description-list__group:contains(Keyserver) button:contains(Remove)')
self.confirm()

m.execute("echo foobar | stratis key set pool0 --capture-key")
create_pool_key(m, "pool0", "foobar")
b.click('#detail-header button:contains(Add keyserver)')
self.dialog_wait_open()
self.dialog_set_val("tang_url", "10.111.112.5")
Expand All @@ -955,7 +960,7 @@ class TestStorageStratisNBDE(packagelib.PackageCase, storagelib.StorageCase):
with b.wait_timeout(60):
b.wait_in_text('#dialog', "Command failed")
m.execute("stratis key unset pool0")
m.execute("echo foodeeboodeebar | stratis key set pool0 --capture-key")
create_pool_key(m, "pool0", "foodeeboodeebar")
self.dialog_apply()
with b.wait_timeout(60):
self.dialog_wait_close()
Expand Down