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

View File

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