Skip to content

Commit 2bcd7b5

Browse files
authored
Merge pull request #993 from mulkieran/version-3.5.2
Version 3.5.3
2 parents dde80a3 + 1d77a0e commit 2bcd7b5

11 files changed

Lines changed: 99 additions & 130 deletions

File tree

CHANGES.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1+
stratis-cli 3.5.3
2+
=================
3+
Required stratisd version: 3.5.0
4+
5+
Recommended development environment: Fedora 38
6+
Lowest supported Python interpreter: 3.9.16
7+
8+
- Cherry-picked commits:
9+
* Allow for error string if encryption info inconsistent
10+
* Mock getpass for better coverage
11+
* Use unittest.mock for monkey patching tests
12+
13+
- Tidies and Maintenance:
14+
* Add list of cherry-picked commits to changelog for version 3.5.2
15+
16+
117
stratis-cli 3.5.2
218
=================
319
Required stratisd version: 3.5.0
420

521
Recommended development environment: Fedora 38
622
Lowest supported Python interpreter: 3.9.16
723

24+
- Cherry-picked commits:
25+
* Add man page field for blockdev UUID
26+
* Advance current development environment to Fedora 38
27+
* Use SPDX license format
28+
* Add legacy package testing
29+
* Use setup configuration file
30+
831
- Set up patch branch:
932
https://github.com/stratis-storage/stratis-cli/pull/985
1033

Makefile

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,14 @@ coverage-no-html:
6161
python3 -m coverage --version
6262
python3 -m coverage run --timid --branch -m unittest discover --quiet --top-level-directory ./tests/whitebox --start-directory ./tests/whitebox/integration >& /dev/null
6363
python3 -m coverage run --timid --branch -a -m unittest discover --quiet --start-directory ./tests/whitebox/unittest
64-
python3 -m coverage run --timid --branch -a -m unittest --quiet tests.whitebox.monkey_patching.test_keyboard_interrupt.KeyboardInterruptTestCase
65-
python3 -m coverage run --timid --branch -a -m unittest --quiet tests.whitebox.monkey_patching.test_stratisd_version.StratisdVersionTestCase
6664
python3 -m coverage report -m --fail-under=100 --show-missing --include="./src/*"
6765

6866
.PHONY: coverage
6967
coverage: coverage-no-html
7068
python3 -m coverage html --include="./src/*"
7169

72-
keyboard-interrupt-test:
73-
python3 -m unittest ${UNITTEST_OPTS} tests.whitebox.monkey_patching.test_keyboard_interrupt.KeyboardInterruptTestCase
74-
75-
stratisd-version-test:
76-
python3 -m unittest ${UNITTEST_OPTS} tests.whitebox.monkey_patching.test_stratisd_version.StratisdVersionTestCase
77-
78-
.PHONY: sim-tests
79-
sim-tests: dbus-tests keyboard-interrupt-test stratisd-version-test
80-
8170
.PHONY: all-tests
82-
all-tests: unittest-tests sim-tests
71+
all-tests: unittest-tests dbus-tests
8372

8473
.PHONY: yamllint
8574
yamllint:

src/stratis_cli/_actions/_list_pool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ def _non_existent_or_inconsistent_to_str(
6767
:returns: a string to print
6868
:rtype: str
6969
"""
70-
(consistent, (exists, value)) = value
70+
(consistent, tuple_or_err_str) = value
7171

7272
if not consistent: # pragma: no cover
7373
return inconsistent_str
7474

75+
(exists, value) = tuple_or_err_str
76+
7577
if not exists:
7678
return non_existent_str
7779

src/stratis_cli/_actions/_top.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _add_update_key(proxy, key_desc, capture_key, *, keyfile_path):
7070
# pylint: disable=import-outside-toplevel
7171
from ._data import Manager
7272

73-
if capture_key: # pragma: no cover
73+
if capture_key:
7474
password = getpass(prompt="Enter key data followed by the return key: ")
7575

7676
(read, write) = os.pipe()
@@ -91,7 +91,7 @@ def _add_update_key(proxy, key_desc, capture_key, *, keyfile_path):
9191
{"key_desc": key_desc, "key_fd": file_desc},
9292
)
9393

94-
if fd_is_pipe: # pragma: no cover
94+
if fd_is_pipe:
9595
os.close(write)
9696
else:
9797
os.close(file_desc)

src/stratis_cli/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
.. moduleauthor:: mulhern <amulhern@redhat.com>
1818
"""
1919

20-
__version_info__ = (3, 5, 2)
20+
__version_info__ = (3, 5, 3)
2121
__version__ = ".".join(str(x) for x in __version_info__)

tests/whitebox/integration/key/test_set.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@
1515
Test 'set'.
1616
"""
1717

18+
# isort: STDLIB
19+
from unittest.mock import patch
20+
1821
# isort: LOCAL
1922
from stratis_cli import StratisCliErrorCodes
23+
from stratis_cli._actions import _top
2024
from stratis_cli._errors import (
2125
StratisCliEngineError,
2226
StratisCliKeyfileNotFoundError,
@@ -69,3 +73,11 @@ def test_set_key_filename_missing(self):
6973
"""
7074
command_line = self._MENU + [self._KEYNAME, "--keyfile-path", "/bogus"]
7175
self.check_error(StratisCliKeyfileNotFoundError, command_line, _ERROR)
76+
77+
def test_set_key_capture_key(self):
78+
"""
79+
Test specifying a key via the --capture-key option.
80+
"""
81+
command_line = self._MENU + [self._KEYNAME, "--capture-key"]
82+
with patch.object(_top, "getpass", return_value="totally_secret"):
83+
TEST_RUNNER(command_line)

tests/whitebox/integration/test_stratis.py

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
Test 'stratisd'.
1616
"""
1717

18+
# isort: STDLIB
19+
from unittest.mock import patch
20+
1821
# isort: THIRDPARTY
1922
import dbus
2023

2124
# isort: LOCAL
22-
from stratis_cli import StratisCliErrorCodes
25+
from stratis_cli import StratisCliErrorCodes, run
26+
from stratis_cli._errors import StratisCliStratisdVersionError
2327

2428
from ._misc import RUNNER, TEST_RUNNER, RunTestCase, SimTestCase
2529

@@ -60,3 +64,55 @@ def test_not_propagate(self):
6064
command_line = ["daemon", "version"]
6165
with self.assertRaises(SystemExit):
6266
RUNNER(command_line)
67+
68+
69+
class StratisdVersionTestCase(SimTestCase):
70+
"""
71+
Test behavior of stratis on incompatible versions of stratisd.
72+
"""
73+
74+
def test_outdated_stratisd_version(self):
75+
"""
76+
Verify that an outdated version of stratisd will produce a
77+
StratisCliStratisdVersionError.
78+
"""
79+
# pylint: disable=import-outside-toplevel
80+
# isort: LOCAL
81+
from stratis_cli._actions import _data
82+
83+
command_line = ["--propagate", "daemon", "version"]
84+
85+
# pylint: disable=protected-access
86+
with patch.object(
87+
_data.Manager0.Properties.Version,
88+
"Get",
89+
return_value="1.0.0",
90+
):
91+
self.check_error(StratisCliStratisdVersionError, command_line, _ERROR)
92+
93+
94+
class KeyboardInterruptTestCase(SimTestCase):
95+
"""
96+
Test behavior of stratis on KeyboardInterrupt.
97+
"""
98+
99+
def test_catch_keyboard_exception(self):
100+
"""
101+
Verify that the KeyboardInterrupt is propagated by the run() method.
102+
./bin/stratis contains a try block at the outermost level which
103+
then catches the KeyboardInterrupt and exits with an error message.
104+
The KeyboardInterrupt is most likely raised in the dbus-python
105+
method which is actually communicating on the D-Bus, but it is
106+
fairly difficult to get at that method. Instead settle for getting
107+
at the calling method generated by dbus-python-client-gen.
108+
"""
109+
110+
# pylint: disable=import-outside-toplevel
111+
# isort: LOCAL
112+
from stratis_cli._actions import _data
113+
114+
with patch.object(
115+
_data.Manager0.Properties.Version, "Get", side_effect=KeyboardInterrupt()
116+
):
117+
with self.assertRaises(KeyboardInterrupt):
118+
run()(["daemon", "version"])

tests/whitebox/monkey_patching/README.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/whitebox/monkey_patching/__init__.py

Whitespace-only changes.

tests/whitebox/monkey_patching/test_keyboard_interrupt.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)