kirill-stepanishin commented on code in PR #3231:
URL: https://github.com/apache/tinkerpop/pull/3231#discussion_r2403422528
##########
gremlin-python/src/main/python/examples/connections.py:
##########
@@ -57,32 +61,57 @@ def with_remote():
# connecting with plain text authentication
def with_auth():
- rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g',
username='stephen', password='password')
+ server_url = os.getenv('GREMLIN_SERVER_BASIC_AUTH_URL',
'ws://localhost:8182/gremlin').format(45941)
+ # turn off certificate verification for testing purposes only
+ ssl_opts = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
+ ssl_opts.check_hostname = False
+ ssl_opts.verify_mode = ssl.CERT_NONE
+ rc = DriverRemoteConnection(server_url, 'g', username='stephen',
password='password',
+ transport_factory=lambda:
AiohttpTransport(ssl_options=ssl_opts))
g = traversal().with_remote(rc)
+ # drop existing vertices
+ g.V().drop().iterate()
+
v = g.add_v().iterate()
count = g.V().count().next()
print("Vertex count: " + str(count))
+ # clean added data
+ g.V().drop().iterate()
rc.close()
# connecting with Kerberos SASL authentication
def with_kerberos():
- rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g',
kerberized_service='[email protected]')
- g = traversal().with_remote(rc)
+ server_url = os.getenv('GREMLIN_SERVER_URL',
'ws://localhost:8182/gremlin').format(45942)
+ kerberos_hostname = os.getenv('KRB_HOSTNAME', 'gremlin-server-test')
+ kerberized_service = f'test-service@{kerberos_hostname}'
+
+ try:
+ rc = DriverRemoteConnection(server_url, 'g',
kerberized_service=kerberized_service)
+ g = traversal().with_remote(rc)
- v = g.add_v().iterate()
- count = g.V().count().next()
- print("Vertex count: " + str(count))
+ # drop existing vertices
+ g.V().drop().iterate()
- rc.close()
+ v = g.add_v().iterate()
+ count = g.V().count().next()
+ print("Vertex count: " + str(count))
+
+ # clean added data
+ g.V().drop().iterate()
+ rc.close()
+ except Exception as e:
+ print(f"Kerberos authentication failed (expected in test environment):
{e}")
Review Comment:
Works if using `socket.gethostname()` instead of `gremlin-server-test` as in
`conftest.py`. Applied in 6729d40b1b21b54e078b50637de55293aebc3455
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]