1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- from __future__ import print_function
- import pexpect
- import unittest
- import os
- import shutil
- class Ferrum(unittest.TestCase):
- def clean_files(self):
- lfile = 'convert-test.log'
- with open(lfile) as l:
- lines = l.readlines()
- orig = lines[0].split(':')[-1].strip()
- backup = lines[1].split()[-1].strip()
- shutil.copy(backup, orig)
-
- os.remove(lfile)
- os.remove('test-chg_passwd.log')
- os.remove(backup)
- @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')
- child = pexpect.spawn(os.path.join(os.path.dirname(__file__),
- '../scripts/pwman3') +
- ' -d ', logfile=logfile)
- child.sendline('passwd')
- child.expect("Please enter your current password:")
- child.sendline('12345')
- 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())
|