|
1 | 1 | from ceph_volume.util import encryption |
2 | | -from mock.mock import patch |
| 2 | +from mock.mock import patch, Mock |
3 | 3 | import base64 |
| 4 | +import pytest |
| 5 | + |
| 6 | + |
| 7 | +class TestNoWorkqueue: |
| 8 | + def setup_method(self): |
| 9 | + encryption.conf.dmcrypt_no_workqueue = None |
| 10 | + |
| 11 | + @patch('ceph_volume.util.encryption.process.call', |
| 12 | + Mock(return_value=(['cryptsetup 2.7.2 flags: UDEV BLKID KEYRING' \ |
| 13 | + 'FIPS KERNEL_CAPI PWQUALITY '], [''], 0))) |
| 14 | + def test_set_dmcrypt_no_workqueue_true(self): |
| 15 | + encryption.set_dmcrypt_no_workqueue() |
| 16 | + assert encryption.conf.dmcrypt_no_workqueue |
| 17 | + |
| 18 | + @patch('ceph_volume.util.encryption.process.call', |
| 19 | + Mock(return_value=(['cryptsetup 2.0.0'], [''], 0))) |
| 20 | + def test_set_dmcrypt_no_workqueue_false(self): |
| 21 | + encryption.set_dmcrypt_no_workqueue() |
| 22 | + assert encryption.conf.dmcrypt_no_workqueue is None |
| 23 | + |
| 24 | + @patch('ceph_volume.util.encryption.process.call', |
| 25 | + Mock(return_value=([''], ['fake error'], 1))) |
| 26 | + def test_set_dmcrypt_no_workqueue_cryptsetup_version_fails(self): |
| 27 | + with pytest.raises(RuntimeError): |
| 28 | + encryption.set_dmcrypt_no_workqueue() |
| 29 | + |
| 30 | + @patch('ceph_volume.util.encryption.process.call', |
| 31 | + Mock(return_value=(['unexpected output'], [''], 0))) |
| 32 | + def test_set_dmcrypt_no_workqueue_pattern_not_found(self): |
| 33 | + with pytest.raises(RuntimeError): |
| 34 | + encryption.set_dmcrypt_no_workqueue() |
| 35 | + |
| 36 | + @patch('ceph_volume.util.encryption.process.call', |
| 37 | + Mock(return_value=([], [''], 0))) |
| 38 | + def test_set_dmcrypt_no_workqueue_index_error(self): |
| 39 | + with pytest.raises(RuntimeError): |
| 40 | + encryption.set_dmcrypt_no_workqueue() |
| 41 | + |
4 | 42 |
|
5 | 43 | class TestGetKeySize(object): |
6 | 44 | def test_get_size_from_conf_default(self, conf_ceph_stub): |
|
0 commit comments