]> git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/tests/util/test_encryption.py
8cca42689b41ec0652a5b818661c5b2b01ca6371
[ceph.git] / ceph / src / ceph-volume / ceph_volume / tests / util / test_encryption.py
1 from ceph_volume.util import encryption
2
3
4 class TestStatus(object):
5
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'}
10
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'}
15
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') == {}
20
21
22 class TestDmcryptClose(object):
23
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('/')
31
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 == []