def authenticated_client(request): try: if request.param == 'basic': # turn off certificate verification for testing purposes only ssl_opts = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) ssl_opts.verify_mode = ssl.CERT_NONE client = Client(basic_url, 'gmodern', username='******', password='******', transport_factory=lambda: AiohttpTransport( ssl_options=ssl_opts)) elif request.param == 'kerberos': client = Client(kerberos_url, 'gmodern', kerberized_service=kerberized_service) else: raise ValueError("Invalid authentication option - " + request.param) except OSError: pytest.skip('Gremlin Server is not running') else: def fin(): client.close() request.addfinalizer(fin) return client
def remote_connection_authenticated(request): try: if request.param == 'basic': # turn off certificate verification for testing purposes only ssl_opts = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) ssl_opts.verify_mode = ssl.CERT_NONE remote_conn = DriverRemoteConnection( basic_url, 'gmodern', username='******', password='******', message_serializer=serializer.GraphSONSerializersV2d0(), transport_factory=lambda: AiohttpTransport(ssl_options=ssl_opts )) elif request.param == 'kerberos': remote_conn = DriverRemoteConnection( kerberos_url, 'gmodern', kerberized_service=kerberized_service, message_serializer=serializer.GraphSONSerializersV2d0()) else: raise ValueError("Invalid authentication option - " + request.param) except OSError: pytest.skip('Gremlin Server is not running') else: def fin(): remote_conn.close() request.addfinalizer(fin) return remote_conn
def test_client_side_timeout_set_for_aiohttp(client): client = Client('ws://localhost:45940/gremlin', 'gmodern', transport_factory=lambda: AiohttpTransport( read_timeout=1, write_timeout=1)) try: # should fire an exception client.submit('Thread.sleep(2000);1').all().result() assert False except TimeoutError as err: # asyncio TimeoutError has no message. assert str(err) == ""
async def async_connect(enable): try: transport = AiohttpTransport(call_from_event_loop=enable) transport.connect('ws://localhost:45940/gremlin') transport.close() return True except RuntimeError: return False
def connection(request): protocol = GremlinServerWSProtocol(GraphSONMessageSerializer(), username='******', password='******') executor = concurrent.futures.ThreadPoolExecutor(5) pool = queue.Queue() try: conn = Connection(anonymous_url, 'gmodern', protocol, lambda: AiohttpTransport(), executor, pool) except OSError: executor.shutdown() pytest.skip('Gremlin Server is not running') else: def fin(): executor.shutdown() conn.close() request.addfinalizer(fin) return conn
def transport_factory(): return AiohttpTransport(**transport_kwargs)