Add tests for former python API.

git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@673 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
Milan Broz
2011-11-06 22:44:37 +00:00
parent 251c7f434f
commit 4f2d4f98e3

View File

@@ -8,6 +8,7 @@ import pycryptsetup
IMG = "test.img"
PASSWORD = "password"
PASSWORD2 = "password2"
DEVICE = "pycryptsetup_test_dev"
def log(pri, txt):
@@ -17,7 +18,7 @@ def log(pri, txt):
return
def askyes(txt):
print "Asking about:", txt, "\n"
print "Question:", txt
return 1
def askpassword(txt):
@@ -34,15 +35,34 @@ c = pycryptsetup.CryptSetup(
r = c.isLuks()
print "isLuks :", r
c.luksFormat()
c.askyes(message = "Is there anybody out there?")
c.log(priority = 1, message = "Nobody there...\n")
c.luksFormat(cipher = "aes", cipherMode= "xts-plain64", keysize = 512)
print "isLuks :", c.isLuks()
print "luksUUID:", c.luksUUID()
print "addKey :", c.addKeyByVolumeKey(PASSWORD)
print "addKeyVK:", c.addKeyByVolumeKey(newPassphrase = PASSWORD, slot = 2)
print "addKeyP :", c.addKeyByPassphrase(passphrase = PASSWORD,
newPassphrase = PASSWORD2, slot = 3)
print "removeP :", c.removePassphrase(passphrase = PASSWORD2)
print "addKeyP :", c.addKeyByPassphrase(PASSWORD, PASSWORD2)
# original api required wrong passphrase paramater here
# print "killSlot:", c.killSlot(passphrase = "xxx", slot = 0)
print "killSlot:", c.killSlot(slot = 0)
print "activate:", c.activate(name = DEVICE, passphrase = PASSWORD)
print "suspend :", c.suspend()
# os.system("dmsetup info -c " + DEVICE)
print "resume :", c.resume(passphrase = PASSWORD)
print "status :", c.status()
info = c.info()
print "cipher :", info["cipher"]
print "cmode :", info["cipher_mode"]
print "keysize :", info["keysize"]
print "dir :", info["dir"]
print "device :", info["device"]
print "offset :", info["offset"]
print "name :", info["name"]
print "uuid :", info["uuid"]
# os.system("cryptsetup luksDump " + info["device"])
print "deact. :", c.deactivate()
del c