Update tomber in extras for v2.2+

This commit is contained in:
Federico Reiven 2017-01-10 12:11:32 -03:00
parent 42ae73d727
commit a808d4aef8
2 changed files with 20 additions and 19 deletions

View File

@ -15,12 +15,13 @@ class tomberTester(unittest.TestCase):
self.keyfile2 = '.'.join([self.pid, '2ndkey'])
self.exhumedkey = '.'.join([self.pid, 'exhumed'])
self.mountpath = './tmptomb'
os.mkdir(self.mountpath)
# generate a passphrase with spaces
self.passphrase = str(randrange(2 ** 64)).replace("", " ")[1:-1]
self.passphrase2 = str(randrange(2 ** 64))
self.imagefile = '.'.join([self.pid, 'jpg'])
copyfile(
'/'.join([os.path.dirname(__file__), 'test.jpg']),
'/'.join([os.path.dirname(os.path.abspath(__file__)), 'test.jpg']),
self.imagefile)
@classmethod
@ -30,7 +31,7 @@ class tomberTester(unittest.TestCase):
os.unlink(self.keyfile2)
os.unlink(self.imagefile)
os.unlink(self.exhumedkey)
rmtree(self.mountpath)
rmtree(self.mountpath, ignore_errors=True)
def test_01_dig(self):
""" Dig a tomb of 10mb"""
@ -90,15 +91,15 @@ class tomberTester(unittest.TestCase):
self.keyfile,
self.tombfile,
self.keyfile2,
self.passphrase,
self.passphrase2
self.passphrase2,
self.passphrase
)[0]
)
def test_11_slam(self):
""" Slam open tombs """
topen(self.tombfile, self.keyfile, self.passphrase2, self.mountpath)
topen(self.tombfile, self.keyfile2, self.passphrase, self.mountpath)
self.assertTrue(tslam()[0])
if __name__ == '__main__':
unittest.main()
unittest.main()

View File

@ -32,7 +32,7 @@ def execute(cmd):
"""
Execute given cmd. return boolean based on exit status and error string
"""
p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
p = Popen(cmd.split(), stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
p_status = p.wait()
if p_status == 0:
@ -65,7 +65,7 @@ def tforge(keyfile, passphrase, force=False):
cmd = ' '.join(['tomb',
'forge',
keyfile,
'--unsecure-dev-mode',
'--unsafe',
'--tomb-pwd',
sanitize_passphrase(passphrase),
'--no-color'])
@ -83,7 +83,7 @@ def tlock(tombfile, keyfile, passphrase):
tombfile,
'-k',
keyfile,
'--unsecure-dev-mode',
'--unsafe',
'--tomb-pwd',
sanitize_passphrase(passphrase),
'--no-color'])
@ -102,7 +102,7 @@ def topen(tombfile, keyfile, passphrase, mountpath=False):
tombfile,
'-k',
keyfile,
'--unsecure-dev-mode',
'--unsafe',
'--tomb-pwd',
sanitize_passphrase(passphrase),
'--no-color',
@ -128,7 +128,7 @@ def tresize(tombfile, keyfile, passphrase, newsize):
tombfile,
'-k',
keyfile,
'--unsecure-dev-mode',
'--unsafe',
'--tomb-pwd',
sanitize_passphrase(passphrase),
'-s',
@ -145,7 +145,7 @@ def tbury(keyfile, passphrase, imagefile):
'bury',
'-k',
keyfile,
'--unsecure-dev-mode',
'--unsafe',
'--tomb-pwd',
sanitize_passphrase(passphrase),
imagefile,
@ -161,7 +161,7 @@ def texhume(keyfile, passphrase, imagefile):
'exhume',
'-k',
keyfile,
'--unsecure-dev-mode',
'--unsafe',
'--tomb-pwd',
sanitize_passphrase(passphrase),
imagefile,
@ -177,7 +177,7 @@ def tpasswd(keyfile, newpassphrase, oldpassphrase):
'passwd',
'-k',
keyfile,
'--unsecure-dev-mode',
'--unsafe',
'--tomb-pwd',
sanitize_passphrase(newpassphrase),
'--tomb-old-pwd',
@ -193,14 +193,14 @@ def tsetkey(oldkeyfile, tombfile, newkeyfile, newpassphrase, oldpassphrase):
"""
cmd = ' '.join(['tomb',
'setkey',
oldkeyfile,
tombfile,
'-k',
newkeyfile,
'--unsecure-dev-mode',
'--tomb-pwd',
sanitize_passphrase(newpassphrase),
oldkeyfile,
tombfile,
'--unsafe',
'--tomb-old-pwd',
sanitize_passphrase(newpassphrase),
'--tomb-pwd',
sanitize_passphrase(oldpassphrase),
'--no-color'])
return execute(cmd)