def test_list_users_diff_mpwd(self): with sphinx.connect() as s: self.assertIsInstance(sphinx.create(s, pwd, user, host, char_classes, size), str) with sphinx.connect() as s: self.assertIsInstance(sphinx.create(s, 'zxcv', user2, host, char_classes, size), str) with sphinx.connect() as s: users = sphinx.users(s, host) self.assertIsInstance(users, str) self.assertEqual(users, '\n'.join((user,user2)))
def test_commit_undo_inv_mpwd(self): # create with sphinx.connect() as s: pwd0 = sphinx.create(s, pwd, user, host, char_classes, size) self.assertIsInstance(pwd0, str) # change invalid mpwd with sphinx.connect() as s: self.assertRaises(ValueError, sphinx.change,s, 'zxcv', user, host) # change correct mpwd with sphinx.connect() as s: pwd2 = sphinx.change(s, pwd, user, host) self.assertIsInstance(pwd2, str) self.assertNotEqual(pwd0, pwd2) # commit invalid mpwd with sphinx.connect() as s: self.assertRaises(ValueError, sphinx.commit,s, 'zxcv', user, host) # commit correct mpwd with sphinx.connect() as s: pwd4 = sphinx.commit(s, pwd, user, host, ) self.assertIsInstance(pwd4, str) self.assertEqual(pwd2, pwd4) # undo invalid mpwd with sphinx.connect() as s: self.assertRaises(ValueError, sphinx.undo,s, 'zxcv', user, host) # undo correct mpwd with sphinx.connect() as s: pwd5 = sphinx.undo(s, pwd, user, host, ) self.assertIsInstance(pwd5, str) self.assertEqual(pwd0, pwd5)
def test_commit_undo(self): # create with sphinx.connect() as s: pwd0 = sphinx.create(s, pwd, user, host, char_classes, size) self.assertIsInstance(pwd0, str) # get with sphinx.connect() as s: pwd1 = sphinx.get(s, pwd, user, host) self.assertIsInstance(pwd1, str) # change with sphinx.connect() as s: pwd2 = sphinx.change(s, pwd, user, host) self.assertIsInstance(pwd2, str) self.assertNotEqual(pwd1, pwd2) # get with sphinx.connect() as s: pwd3 = sphinx.get(s, pwd, user, host) self.assertIsInstance(pwd3, str) self.assertEqual(pwd1, pwd3) # commit with sphinx.connect() as s: pwd4 = sphinx.commit(s, pwd, user, host, ) self.assertIsInstance(pwd4, str) self.assertEqual(pwd2, pwd4) # undo with sphinx.connect() as s: pwd5 = sphinx.undo(s, pwd, user, host, ) self.assertIsInstance(pwd5, str) self.assertEqual(pwd1, pwd5)
def test_get_inv_mpwd(self): with sphinx.connect() as s: rwd0 = sphinx.create(s, pwd, user, host, char_classes, size) self.assertIsInstance(rwd0, str) with sphinx.connect() as s: rwd = sphinx.get(s, 'zxcv', user, host) self.assertNotEqual(rwd0,rwd)
def test_change(self): with sphinx.connect() as s: self.assertIsInstance(sphinx.create(s, pwd, user, host, char_classes, size), str) with sphinx.connect() as s: pwd0 = sphinx.get(s, pwd, user, host) self.assertIsInstance(pwd0, str) with sphinx.connect() as s: pwd1 = sphinx.change(s, pwd, user, host) self.assertIsInstance(pwd1, str) self.assertNotEqual(pwd0, pwd1)
def test_double_commit(self): # create with sphinx.connect() as s: pwd0 = sphinx.create(s, pwd, user, host, char_classes, size) self.assertIsInstance(pwd0, str) # change with sphinx.connect() as s: pwd2 = sphinx.change(s, pwd, user, host) self.assertIsInstance(pwd2, str) self.assertNotEqual(pwd0, pwd2) # commit with sphinx.connect() as s: pwd4 = sphinx.commit(s, pwd, user, host, ) self.assertIsInstance(pwd4, str) self.assertEqual(pwd2, pwd4) # commit with sphinx.connect() as s: self.assertRaises(ValueError, sphinx.commit,s, pwd, user, host)
def test_delete_inv_mpwd(self): with sphinx.connect() as s: self.assertIsInstance(sphinx.create(s, pwd, user, host, char_classes, size), str) with sphinx.connect() as s: self.assertIsNone(sphinx.delete(s, 'zxcv', user, host))
def test_delete(self): with sphinx.connect() as s: self.assertIsInstance(sphinx.create(s, pwd, user, host, char_classes, size), str) with sphinx.connect() as s: self.assertTrue(sphinx.delete(s, pwd, user, host))
def test_recreate_user(self): with sphinx.connect() as s: self.assertIsInstance(sphinx.create(s, pwd, user, host, char_classes, size), str) with sphinx.connect() as s: self.assertRaises(ValueError, sphinx.create,s, pwd, user, host, char_classes, size)