mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 08:20:07 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user