unittests for CryptoBoxTools
mount/umount moved to separate volume plugins volume name change moved to 'volume_props' plugin webinterface for password change (luks) added attribute "pluginCapabilities" added to plugins attribute "requestAuth" added to plugins http authentication implemented (for now: static user database)
This commit is contained in:
parent
ca13aebdc8
commit
9321677078
9 changed files with 226 additions and 216 deletions
48
pythonrewrite/bin/unittests.CryptoBoxTools.py
Executable file
48
pythonrewrite/bin/unittests.CryptoBoxTools.py
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import unittest
|
||||
import CryptoBoxTools
|
||||
import os
|
||||
|
||||
|
||||
class CryptoBoxToolsTests(unittest.TestCase):
|
||||
|
||||
def testGetAbsoluteDeviceName(self):
|
||||
func = CryptoBoxTools.getAbsoluteDeviceName
|
||||
self.assertTrue(func("hda") == "/dev/hda")
|
||||
self.assertTrue(func("loop0") == "/dev/loop0")
|
||||
self.assertTrue(func(os.path.devnull) == os.path.devnull)
|
||||
|
||||
|
||||
def testFindMajorMinorOfDevice(self):
|
||||
func = CryptoBoxTools.findMajorMinorOfDevice
|
||||
self.assertTrue(func("/dev/hda") == (3,0))
|
||||
self.assertTrue(func("/dev/hda1") == (3,1))
|
||||
self.assertTrue(func(os.path.devnull) == (1,3))
|
||||
self.assertTrue(func("/dev/nothere") is None)
|
||||
|
||||
|
||||
def testFindMajorMinorDeviceName(self):
|
||||
func = CryptoBoxTools.findMajorMinorDeviceName
|
||||
dir = os.path.join(os.path.sep, "dev")
|
||||
self.assertTrue(os.path.join(dir,"hda") in func(dir,3,0))
|
||||
self.assertTrue(os.path.devnull in func(dir,1,3))
|
||||
self.assertFalse(os.path.devnull in func(dir,2,3))
|
||||
|
||||
|
||||
def testIsPartOfBlockDevice(self):
|
||||
func = CryptoBoxTools.isPartOfBlockDevice
|
||||
self.assertTrue(func("/dev/hda", "/dev/hda1"))
|
||||
self.assertFalse(func("/dev/hda", "/dev/hda"))
|
||||
self.assertFalse(func("/dev/hda1", "/dev/hda"))
|
||||
self.assertFalse(func("/dev/hda1", "/dev/hda1"))
|
||||
self.assertFalse(func("/dev/hda", "/dev/hdb1"))
|
||||
self.assertFalse(func(None, "/dev/hdb1"))
|
||||
self.assertFalse(func("/dev/hda", None))
|
||||
self.assertFalse(func(None, ""))
|
||||
self.assertFalse(func("loop0", "loop1"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue