*test.py restored
This commit is contained in:
parent
dba8ca79fd
commit
2b4180a83b
2 changed files with 117 additions and 0 deletions
|
@ -9,5 +9,6 @@ server.logFile = "cryptoboxwebserver.log"
|
||||||
|
|
||||||
[/favicon.ico]
|
[/favicon.ico]
|
||||||
static_filter.on = True
|
static_filter.on = True
|
||||||
|
# RFC why the cherry and not the ant?
|
||||||
static_filter.file = "/usr/share/doc/python-cherrypy/cherrypy/favicon.ico"
|
static_filter.file = "/usr/share/doc/python-cherrypy/cherrypy/favicon.ico"
|
||||||
|
|
||||||
|
|
116
pythonrewrite/bin2/test.complete.CryptoBox.py
Executable file
116
pythonrewrite/bin2/test.complete.CryptoBox.py
Executable file
|
@ -0,0 +1,116 @@
|
||||||
|
#!/usr/bin/env python2.4
|
||||||
|
|
||||||
|
"""
|
||||||
|
BEWARE: this script may overwrite the data of one of your loop devices. You
|
||||||
|
should restrict the AllowedDevices directive in cryptobox.conf to exclude
|
||||||
|
your precious black devices from being used by this script.
|
||||||
|
|
||||||
|
the following script runs a number of tests for different parts
|
||||||
|
"""
|
||||||
|
|
||||||
|
from CryptoBox import CryptoBoxProps
|
||||||
|
from CryptoBoxContainer import CryptoBoxContainer
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
cb = CryptoBoxProps()
|
||||||
|
|
||||||
|
print "Confguration:"
|
||||||
|
print "\tConfig file:\t\t%s" % (cb.cbxPrefs.filename, )
|
||||||
|
print "\tAllowed devices:\t%s" % (cb.cbxPrefs["Main"]["AllowedDevices"], )
|
||||||
|
|
||||||
|
"""for e in cb.getContainerList(filterType=CryptoBoxContainer.Types["luks"]):"""
|
||||||
|
for e in cb.getContainerList():
|
||||||
|
print "\t\t%d\t\t%s - %s - %d" % (cb.getContainerList().index(e), e.getDevice(), e.getName(), e.getType())
|
||||||
|
|
||||||
|
if not cb.getContainerList():
|
||||||
|
print "no loop devices found for testing"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if len(cb.getContainerList()) > 1:
|
||||||
|
print "I found more than one available loop device - I will stop now to avoid risking data loss."
|
||||||
|
print "Please change the 'AllowedDevices' setting in 'cryptobox.conf' to reduce the number of allowed devices to only one."
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
testElement = cb.getContainerList()[0]
|
||||||
|
print "\nRunning some tests now ..."
|
||||||
|
if not plain_tests(testElement):
|
||||||
|
print "some previous tests failed - we should stop now"
|
||||||
|
sys.exit(1)
|
||||||
|
luks_tests(testElement)
|
||||||
|
|
||||||
|
|
||||||
|
" ***************** some functions ******************** "
|
||||||
|
|
||||||
|
def luks_tests(e):
|
||||||
|
# umount if necessary
|
||||||
|
try:
|
||||||
|
e.umount()
|
||||||
|
except "MountError":
|
||||||
|
pass
|
||||||
|
|
||||||
|
e.create(e.Types["luks"], "alt")
|
||||||
|
print "\tluks create:\tok"
|
||||||
|
|
||||||
|
e.changePassword("alt","neu")
|
||||||
|
print "\tluks changepw:\tok"
|
||||||
|
|
||||||
|
e.setName("lalla")
|
||||||
|
print "\tluks setName:\tok"
|
||||||
|
|
||||||
|
try:
|
||||||
|
e.mount("neu")
|
||||||
|
except "MountError":
|
||||||
|
pass
|
||||||
|
if e.isMounted(): print "\tluks mount:\tok"
|
||||||
|
else: print "\tluks mount:\tfailed"
|
||||||
|
|
||||||
|
print "\tCapacity (size, free, used) [MB]:\t%s" % (e.getCapacity(), )
|
||||||
|
|
||||||
|
try:
|
||||||
|
e.umount()
|
||||||
|
except "MountError":
|
||||||
|
pass
|
||||||
|
if e.isMounted(): print "\tluks umount:\tfailed"
|
||||||
|
else: print "\tluks umount:\tok"
|
||||||
|
|
||||||
|
if e.isMounted(): return False
|
||||||
|
else: return True
|
||||||
|
|
||||||
|
|
||||||
|
def plain_tests(e):
|
||||||
|
# umount if necessary
|
||||||
|
try:
|
||||||
|
e.umount()
|
||||||
|
except "MountError":
|
||||||
|
pass
|
||||||
|
|
||||||
|
e.create(e.Types["plain"])
|
||||||
|
print "\tplain create:\tok"
|
||||||
|
|
||||||
|
e.setName("plain-lili")
|
||||||
|
print "\tplain setName:\tok"
|
||||||
|
|
||||||
|
try:
|
||||||
|
e.mount()
|
||||||
|
except "MountError":
|
||||||
|
pass
|
||||||
|
if e.isMounted(): print "\tplain mount:\tok"
|
||||||
|
else: print "\tplain mount:\tfailed"
|
||||||
|
|
||||||
|
print "\tCapacity (size, free, used) [MB]:\t%s" % (e.getCapacity(), )
|
||||||
|
|
||||||
|
try:
|
||||||
|
e.umount()
|
||||||
|
except "MountError":
|
||||||
|
pass
|
||||||
|
if e.isMounted(): print "\tplain umount:\tfailed"
|
||||||
|
else: print "\tplain umount:\tok"
|
||||||
|
|
||||||
|
if e.isMounted(): return False
|
||||||
|
else: return True
|
||||||
|
|
||||||
|
# ************ main ****************
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in a new issue