]>
git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/tests/util/test_encryption.py
8cca42689b41ec0652a5b818661c5b2b01ca6371
1 from ceph_volume
.util
import encryption
4 class TestStatus(object):
6 def test_skips_unuseful_lines(self
, stub_call
):
7 out
= ['some line here', ' device: /dev/sdc1']
8 stub_call((out
, '', 0))
9 assert encryption
.status('/dev/sdc1') == {'device': '/dev/sdc1'}
11 def test_removes_extra_quotes(self
, stub_call
):
12 out
= ['some line here', ' device: "/dev/sdc1"']
13 stub_call((out
, '', 0))
14 assert encryption
.status('/dev/sdc1') == {'device': '/dev/sdc1'}
16 def test_ignores_bogus_lines(self
, stub_call
):
17 out
= ['some line here', ' ']
18 stub_call((out
, '', 0))
19 assert encryption
.status('/dev/sdc1') == {}
22 class TestDmcryptClose(object):
24 def test_mapper_exists(self
, fake_run
, tmpfile
):
25 file_name
= tmpfile(name
='mapper-device')
26 encryption
.dmcrypt_close(file_name
)
27 arguments
= fake_run
.calls
[0]['args'][0]
28 assert arguments
[0] == 'cryptsetup'
29 assert arguments
[1] == 'remove'
30 assert arguments
[2].startswith('/')
32 def test_mapper_does_not_exist(self
, fake_run
):
33 file_name
= '/path/does/not/exist'
34 encryption
.dmcrypt_close(file_name
)
35 assert fake_run
.calls
== []