Cole-Greer commented on code in PR #3384:
URL: https://github.com/apache/tinkerpop/pull/3384#discussion_r3140708086


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java:
##########
@@ -193,6 +216,11 @@ public Object get(final String key) {
     @Override
     public GremlinScriptEngine getEngineByName(final String shortName) {
         if (null == shortName) throw new NullPointerException();
+
+        if (allowedEngines != null && !allowedEngines.contains(shortName)) {

Review Comment:
   This allowlist means that unless the server config yaml explicitly 
configures the groovy script engine, any request which explicitly sets 
`"language": "gremlin-groovy"` will fail, even if the groovy script engine is 
available on the classpath. This enables the last few cases which I added to 
your groovy tests:
   
   ```
               // explicit gremlin-groovy should fail when engine is not 
configured
               try {
                   client.submit("2+2", groovyRequestOptions).all().get();
                   fail("Should have failed for unavailable gremlin-groovy 
engine");
               } catch (Exception ex) {
                   final ResponseException re = (ResponseException) 
ex.getCause();
                   assertEquals(HttpResponseStatus.BAD_REQUEST, 
re.getResponseStatusCode());
                   assertEquals("InvalidRequestException", 
re.getRemoteException());
                   assertEquals("Script engine [gremlin-groovy] is not 
available.", re.getMessage());
               }
   
               // completely unknown engine should also fail
               try {
                   final RequestOptions unknownEngine = 
RequestOptions.build().language("gremlin-foo").create();
                   client.submit("g.V()", unknownEngine).all().get();
                   fail("Should have failed for unknown script engine");
               } catch (Exception ex) {
                   final ResponseException re = (ResponseException) 
ex.getCause();
                   assertEquals(HttpResponseStatus.BAD_REQUEST, 
re.getResponseStatusCode());
                   assertEquals("InvalidRequestException", 
re.getRemoteException());
                   assertEquals("Script engine [gremlin-foo] is not 
available.", re.getMessage());
               }
   ```



-- 
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]

Reply via email to