123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- from __future__ import print_function
- import pexpect
- import unittest
- import shutil
- import sys
- import os
- class Ferrum(unittest.TestCase):
- def clean_files(self):
-
-
-
-
-
-
-
-
- if os.path.exists('test-chg_passwd.log'):
- os.remove('test-chg_passwd.log')
-
- db = os.path.join(os.path.dirname(__file__), 'foo.baz.db')
- if os.path.exists(db):
- os.remove(db)
- @unittest.skip("obsolete")
- def test_b_run_convert(self):
- "invoke pwman with -k option to convert the old data"
- lfile = 'convert-test.log'
- logfile = open(lfile, 'wb')
- cmd = (os.path.join(os.path.dirname(__file__), '../scripts/pwman3'
- ) + ' -k -e Blowfish -d ')
- child = pexpect.spawn(cmd, logfile=logfile)
- child.expect('[\s|\S]+Please enter your password:', timeout=10)
- self.assertEqual(6, child.sendline('12345'))
- rv = child.expect('pwman successfully converted the old database')
- self.assertEqual(0, rv)
-
-
- def test_c_change_pass(self):
- lfile = 'test-chg_passwd.log'
- logfile = open(lfile, 'wb')
- cmd = shutil.which('pwman3')
- db = 'sqlite://' + os.path.join(os.path.dirname(__file__), 'foo.baz.db')
- child = pexpect.spawn(cmd + ' -d ' + db, logfile=logfile)
- if sys.version_info[0] > 2:
- child.expect('[\s|\S]+(password:)$', timeout=10)
- child.sendline('foobar')
- child.sendline('foobar')
- self.clean_files()
- def suite():
- loader = unittest.TestLoader()
- suite = unittest.TestSuite()
- suite.addTest(loader.loadTestsFromTestCase(Ferrum))
- return suite
- if __name__ == '__main__':
- unittest.TextTestRunner(verbosity=2).run(suite())
|