Skip to content

Commit

Permalink
Cover encrypted case better
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed May 3, 2022
1 parent 604407b commit 99a425b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/stratis_cli/_actions/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,12 @@ def maybe_inconsistent(value):
:rtype: str
"""
(real, value) = value
return str(value) if real else "inconsistent" # pragma: no cover
return str(value) if real else "inconsistent"

def interp_clevis(value):
""" """
(real, value) = value
return "present" if real else "inconsistent" # pragma: no cover
return "present" if real else "inconsistent"

def na_string(value, interp_option):
"""
Expand Down
46 changes: 46 additions & 0 deletions tests/whitebox/integration/pool/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from stratis_cli import StratisCliErrorCodes
from stratis_cli._errors import StratisCliResourceNotFoundError

from .._keyutils import RandomKeyTmpFile
from .._misc import RUNNER, TEST_RUNNER, SimTestCase, device_name_list, stop_pool

_DEVICE_STRATEGY = device_name_list(1)
Expand Down Expand Up @@ -147,3 +148,48 @@ def test_list_bogus(self):
"""
command_line = self._MENU + ["--uuid=%s" % uuid4()]
self.check_error(StratisCliResourceNotFoundError, command_line, _ERROR)


class List4TestCase(SimTestCase):
"""
Test listing stopped pools that have been encrypted.
"""

_MENU = ["--propagate", "pool", "list-stopped"]
_POOLNAME = "deadpool"
_KEY_DESC = "keydesc"

def setUp(self):
"""
Start the stratisd daemon with the simulator. Create a pool.
"""
super().setUp()

with RandomKeyTmpFile() as fname:
command_line = [
"--propagate",
"key",
"set",
"--keyfile-path",
fname,
self._KEY_DESC,
]
RUNNER(command_line)

command_line = [
"--propagate",
"pool",
"create",
"--key-desc",
self._KEY_DESC,
self._POOLNAME,
] + _DEVICE_STRATEGY()
RUNNER(command_line)

def test_list(self):
"""
Test listing all with a stopped pool.
"""
command_line = ["pool", "stop", self._POOLNAME]
RUNNER(command_line)
TEST_RUNNER(self._MENU)

0 comments on commit 99a425b

Please sign in to comment.