def test_wrongHost(self): conn = RestAuthConnection('http://[:2]:8003', 'wrong', 'credentials', timeout=1.0) try: RestAuthUser.get(conn, 'foobar') self.fail() except HttpException as e: e.get_cause()
def test_removeUser(self): user = RestAuthUser.create(self.conn, username, password) user.remove() self.assertEqual([], RestAuthUser.get_all(self.conn)) try: RestAuthUser.get(self.conn, username) self.fail() except error.ResourceNotFound as e: self.assertEqual("user", e.get_type())
def test_createUserWithNoPassword(self): user1 = RestAuthUser.create(self.conn, username) self.assertEqual([user1], RestAuthUser.get_all(self.conn)) self.assertEqual(user1, RestAuthUser.get(self.conn, username)) # check that no password verifies as correct self.assertFalse(user1.verify_password("")) self.assertFalse(user1.verify_password(password)) # use empty string instead: user2 = RestAuthUser.create(self.conn, username + "1", "") self.assertCountEqual([user1, user2], RestAuthUser.get_all(self.conn)) self.assertEqual(user2, RestAuthUser.get(self.conn, username + "1")) # check that no password verifies as correct self.assertFalse(user2.verify_password("")) self.assertFalse(user2.verify_password(password))
def test_createUserUnicode(self): user = RestAuthUser.create(self.conn, username, "password") self.assertEqual([user], RestAuthUser.get_all(self.conn)) self.assertEqual(user, RestAuthUser.get(self.conn, username))
def test_createUserWithSpace(self): user = RestAuthUser.create(self.conn, "mati space", "password") self.assertEqual([user], RestAuthUser.get_all(self.conn)) self.assertEqual(user, RestAuthUser.get(self.conn, "mati space"))
def test_getInvalidUser(self): try: RestAuthUser.get(self.conn, "invalid") self.fail() except error.ResourceNotFound as e: self.assertEqual("user", e.get_type())