def test_authenticate(self): if not test.env.auth: raise SkipTest('Authentication is not enabled on server') # self.db is logged in as root. yield from self.db.add_user("jesse", "password") db = AsyncIOMotorClient(host, port, io_loop=self.loop).motor_test try: # Authenticate many times at once to test concurrency. yield from asyncio.wait( [db.authenticate("jesse", "password") for _ in range(10)], loop=self.loop) # Just make sure there are no exceptions here. yield from db.remove_user("jesse") yield from db.logout() if (yield from at_least(self.cx, (2, 5, 4))): info = yield from self.db.command("usersInfo", "jesse") users = info.get('users', []) else: users = yield from self.db.system.users.find().to_list(10) self.assertFalse("jesse" in [u['user'] for u in users]) finally: yield from remove_all_users(self.db) test.env.sync_cx.disconnect()
def test_authenticate(self): if not test.env.auth: raise SkipTest('Authentication is not enabled on server') # self.db is logged in as root. test.env.create_user(self.db.name, "jesse", "password", roles=['userAdmin', 'readWrite']) db = AsyncIOMotorClient(env.host, env.port, **self.get_client_kwargs()).motor_test try: # Authenticate many times at once to test concurrency. yield from asyncio.wait( [db.authenticate("jesse", "password") for _ in range(10)], loop=self.loop) # Just make sure there are no exceptions here. test.env.drop_user(db.name, 'jesse') yield from db.logout() info = yield from self.db.command("usersInfo", "jesse") users = info.get('users', []) self.assertFalse("jesse" in [u['user'] for u in users]) finally: yield from remove_all_users(self.db) test.env.sync_cx.close()
def test_authenticate(self): if not test.env.auth: raise SkipTest('Authentication is not enabled on server') # self.db is logged in as root. yield from self.db.add_user("jesse", "password") db = AsyncIOMotorClient(host, port, io_loop=self.loop).motor_test try: # Authenticate many times at once to test concurrency. yield from asyncio.wait( [db.authenticate("jesse", "password") for _ in range(10)], loop=self.loop) # Just make sure there are no exceptions here. yield from db.remove_user("jesse") yield from db.logout() if (yield from at_least(self.cx, (2, 5, 4))): info = yield from self.db.command("usersInfo", "jesse") users = info.get('users', []) else: users = yield from self.db.system.users.find().to_list(10) self.assertFalse("jesse" in [u['user'] for u in users]) finally: yield from remove_all_users(self.db) test.env.sync_cx.disconnect()
def test_authenticate(self): if not test.env.auth: raise SkipTest('Authentication is not enabled on server') # self.db is logged in as root. yield from self.db.add_user("jesse", "password") db = AsyncIOMotorClient(env.host, env.port, **self.get_client_kwargs()).motor_test try: # Authenticate many times at once to test concurrency. yield from asyncio.wait( [db.authenticate("jesse", "password") for _ in range(10)], loop=self.loop) # Just make sure there are no exceptions here. yield from db.remove_user("jesse") yield from db.logout() info = yield from self.db.command("usersInfo", "jesse") users = info.get('users', []) self.assertFalse("jesse" in [u['user'] for u in users]) finally: yield from remove_all_users(self.db) test.env.sync_cx.close()