Skip to content

Commit a1534b1

Browse files
Merge pull request #1077 from vojtechtrefny/master_seems-encrypted-test
tests: Add a simple test case for bd_crypto_device_seems_encrypted
2 parents 4d746d2 + 6bac76c commit a1534b1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/crypto_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,24 @@ def test_veracrypt_open_close(self):
14441444
self.assertTrue(succ)
14451445
self.assertFalse(os.path.exists("/dev/mapper/libblockdevTestTC"))
14461446

1447+
@tag_test(TestTags.NOSTORAGE)
1448+
def test_seems_encrypted(self):
1449+
"""Verify that BlockDev.crypto_device_seems_encrypted works"""
1450+
1451+
# truecrypt device without header
1452+
enc = BlockDev.crypto_device_seems_encrypted(self.tc_dev)
1453+
self.assertTrue(enc)
1454+
1455+
ctx = BlockDev.CryptoKeyslotContext(passphrase=self.passphrase)
1456+
succ = BlockDev.crypto_tc_open(self.tc_dev, "libblockdevTestTC", ctx)
1457+
self.assertTrue(succ)
1458+
1459+
# the cleartext device is not encrypted
1460+
enc = BlockDev.crypto_device_seems_encrypted("/dev/mapper/libblockdevTestTC")
1461+
self.assertFalse(enc)
1462+
1463+
succ = BlockDev.crypto_tc_close("libblockdevTestTC")
1464+
14471465

14481466
class CryptoTestBitlk(CryptoTestCase):
14491467

0 commit comments

Comments
 (0)