1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import pexpect
- import unittest
- import os
- OLD_DB_PATH = os.path.join(os.path.dirname(__file__), 'pwman.v0.0.8.db')
- NEW_DB_PATH = os.path.join(os.path.dirname(__file__), 'pwman.v0.0.8-newdb.db')
- _db_warn = ("\n*** WARNNING: You are using the old database format"
- " which is insecure."
- " Please upgrade to the new database "
- " format. Do note: support for this DB format will be dropped in"
- " v0.5. This database format is on hold. No bugs are fixead"
- " Check the help (pwman3 -h) or look at the manpage which"
- " explains how to proceed. ***")
- class Ferrum(unittest.TestCase):
- def test_db_warning(self):
- "when trying to run with old db, we should see warning"
- child = pexpect.spawn(os.path.join(os.path.dirname(__file__),
- '../../scripts/pwman3')+' -t -d '+OLD_DB_PATH)
- self.assertEqual(0, child.expect_exact(_db_warn, timeout=0.5))
- def test_run_convert(self):
- "invoke pwman with -k option to convert the old data"
- child = pexpect.spawn(os.path.join(os.path.dirname(__file__),
- '../../scripts/pwman3')+' -t -k -d '+OLD_DB_PATH)
-
- child.expect('[\s|\S]+Please enter your password:', timeout=5)
- self.assertEqual(6, child.sendline('12345'))
- print child.readlines()
-
-
-
-
-
-
-
-
-
- def suite():
- loader = unittest.TestLoader()
- suite = unittest.TestSuite()
- suite.addTest(loader.loadTestsFromTestCase(Ferrum))
- return suite
- if __name__ == '__main__':
- unittest.TextTestRunner(verbosity=2).run(suite())
- os.remove(NEW_DB_PATH)
|