You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/11/28 00:26:56 UTC
incubator-tinkerpop git commit: Deprecate credentialsDbLocation
setting for gremlin server simple auth.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/TINKERPOP3-981 [created] 0f4ad252c
Deprecate credentialsDbLocation setting for gremlin server simple auth.
Fixed up docs and altered packaged config files. This is a non-breaking change as the setting is still supported. It offers a warning when it is used. Kept tests in place and added new ones to test both features.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/0f4ad252
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/0f4ad252
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/0f4ad252
Branch: refs/heads/TINKERPOP3-981
Commit: 0f4ad252c4097b888ba0df33333d11c512d3af32
Parents: df887ac
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Nov 27 18:25:13 2015 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Nov 27 18:25:13 2015 -0500
----------------------------------------------------------------------
.../src/reference/gremlin-applications.asciidoc | 19 +-
.../conf/gremlin-server-rest-secure.yaml | 3 +-
gremlin-server/conf/gremlin-server-secure.yaml | 3 +-
.../conf/tinkergraph-credentials.properties | 20 ++
.../server/auth/SimpleAuthenticator.java | 30 ++-
.../GremlinServerAuthIntegrateOldTest.java | 235 +++++++++++++++++++
.../server/GremlinServerAuthIntegrateTest.java | 4 +-
.../server/GremlinServerHttpIntegrateTest.java | 49 ++++
8 files changed, 329 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index 7ef7a71..a217847 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -759,28 +759,13 @@ graph database, which must be provided to it as part of the configuration.
authentication: {
className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,
config: {
- credentialsDb: conf/credential-graph.properties}}
+ credentialsDb: conf/tinkergraph-credentials.properties}}
Quick Start
+++++++++++
A quick way to get started with the `SimpleAuthenticator` is to use TinkerGraph for the "credentials graph" and the
-"sample" credential graph that is packaged with the server. Recall that TinkerGraph is an in-memory graph and
-therefore always starts as "empty" when opened by `GraphFactory`. To allow TinkerGraph to be used in this "getting
-started" capacity, Gremlin Server allows for a TinkerGraph-only configuration option called `credentialsDbLocation`.
-The following snippet comes from the `conf/gremlin-server-secure.yaml` file packaged with the server:
-
-[source,yaml]
-authentication: {
- className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,
- config: {
- credentialsDb: conf/tinkergraph-empty.properties,
- credentialsDbLocation: data/credentials.kryo}}
-
-This added configuration tells Gremlin Server to look for a gryo file at that location containing the data for the
-graph which it loads via standard `io` methods. The limitation is that this read is only performed at the
-initialization of the server so therefore credentials remain static for the life of the server. In this case,
-`data/credentials.kryo` contains a single user named "stephen" with the imaginative password of "password".
+"sample" credential graph that is packaged with the server.
[source,text]
----
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/gremlin-server/conf/gremlin-server-rest-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-rest-secure.yaml b/gremlin-server/conf/gremlin-server-rest-secure.yaml
index de1e674..5a1001d 100644
--- a/gremlin-server/conf/gremlin-server-rest-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-rest-secure.yaml
@@ -70,7 +70,6 @@ writeBufferHighWaterMark: 65536
authentication: {
className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,
config: {
- credentialsDb: conf/tinkergraph-empty.properties,
- credentialsDbLocation: data/credentials.kryo}}
+ credentialsDb: conf/tinkergraph-credentials.properties}}
ssl: {
enabled: true}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/gremlin-server/conf/gremlin-server-secure.yaml
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/gremlin-server-secure.yaml b/gremlin-server/conf/gremlin-server-secure.yaml
index 20ae461..caf9726 100644
--- a/gremlin-server/conf/gremlin-server-secure.yaml
+++ b/gremlin-server/conf/gremlin-server-secure.yaml
@@ -70,7 +70,6 @@ writeBufferHighWaterMark: 65536
authentication: {
className: org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator,
config: {
- credentialsDb: conf/tinkergraph-empty.properties,
- credentialsDbLocation: data/credentials.kryo}}
+ credentialsDb: conf/tinkergraph-credentials.properties}}
ssl: {
enabled: true}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/gremlin-server/conf/tinkergraph-credentials.properties
----------------------------------------------------------------------
diff --git a/gremlin-server/conf/tinkergraph-credentials.properties b/gremlin-server/conf/tinkergraph-credentials.properties
new file mode 100644
index 0000000..b5d5a27
--- /dev/null
+++ b/gremlin-server/conf/tinkergraph-credentials.properties
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+gremlin.graph=org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
+gremlin.tinkergraph.vertexIdManager=LONG
+gremlin.tinkergraph.graphLocation=data/credentials.kryo
+gremlin.tinkergraph.graphFormat=gryo
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java
index 76dc618..7692343 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/SimpleAuthenticator.java
@@ -48,7 +48,16 @@ public class SimpleAuthenticator implements Authenticator {
private static final byte NUL = 0;
private CredentialGraph credentialStore;
+ /**
+ * @deprecated As of release 3.1.1-incubating, if using TinkerGraph, simply rely on it's "persistence" features.
+ * @see <a href="https://issues.apache.org/jira/browse/TINKERPOP3-981">TINKERPOP3-981</a>
+ */
+ @Deprecated
public static final String CONFIG_CREDENTIALS_LOCATION = "credentialsDbLocation";
+
+ /**
+ * The location of the configuration file that contains the credentials database.
+ */
public static final String CONFIG_CREDENTIALS_DB = "credentialsDb";
@Override
@@ -74,19 +83,20 @@ public class SimpleAuthenticator implements Authenticator {
final Graph graph = GraphFactory.open((String) config.get(CONFIG_CREDENTIALS_DB));
if (graph instanceof TinkerGraph) {
- if (!config.containsKey(CONFIG_CREDENTIALS_LOCATION)) {
- throw new IllegalStateException(String.format(
- "Credentials configuration for TinkerGraph missing the %s key that points to a gryo file containing credentials data", CONFIG_CREDENTIALS_LOCATION));
- }
-
+ // have to create the indices because they are not stored in gryo
final TinkerGraph tinkerGraph = (TinkerGraph) graph;
tinkerGraph.createIndex(PROPERTY_USERNAME, Vertex.class);
- final String location = (String) config.get(CONFIG_CREDENTIALS_LOCATION);
- try {
- tinkerGraph.io(IoCore.gryo()).readGraph(location);
- } catch (IOException e) {
- logger.warn("Could not read credentials graph from {} - authentication is enabled, but with an empty user database", location);
+ // we deprecated credentialsLocation, but we still need to support it. if it is present as a key, we can
+ // load the data as we always did.
+ if (config.containsKey(CONFIG_CREDENTIALS_LOCATION)) {
+ logger.warn("Using {} configuration option which is deprecated - prefer including the location of the credentials graph data in the TinkerGraph config file.");
+ final String location = (String) config.get(CONFIG_CREDENTIALS_LOCATION);
+ try {
+ tinkerGraph.io(IoCore.gryo()).readGraph(location);
+ } catch (IOException e) {
+ logger.warn("Could not read credentials graph from {} - authentication is enabled, but with an empty user database", location);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateOldTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateOldTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateOldTest.java
new file mode 100644
index 0000000..5b09425
--- /dev/null
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateOldTest.java
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.server;
+
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.tinkerpop.gremlin.driver.Client;
+import org.apache.tinkerpop.gremlin.driver.Cluster;
+import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
+import org.apache.tinkerpop.gremlin.driver.ser.Serializers;
+import org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator;
+import org.ietf.jgss.GSSException;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeoutException;
+
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ * @deprecated As of release 3.1.1-incubating, replaced by {@link GremlinServerAuthIntegrateTest}
+ * @see <a href="https://issues.apache.org/jira/browse/TINKERPOP3-981">TINKERPOP3-981</a>
+ */
+@Deprecated
+public class GremlinServerAuthIntegrateOldTest extends AbstractGremlinServerIntegrationTest {
+
+ /**
+ * Configure specific Gremlin Server settings for specific tests.
+ */
+ @Override
+ public Settings overrideSettings(final Settings settings) {
+ final Settings.AuthenticationSettings authSettings = new Settings.AuthenticationSettings();
+ authSettings.className = SimpleAuthenticator.class.getName();
+
+ // use a credentials graph with one user in it: stephen/password
+ final Map<String,Object> authConfig = new HashMap<>();
+ authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_DB, "conf/tinkergraph-empty.properties");
+ authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_LOCATION, "data/credentials.kryo");
+
+ authSettings.config = authConfig;
+ settings.authentication = authSettings;
+
+ final String nameOfTest = name.getMethodName();
+ switch (nameOfTest) {
+ case "shouldAuthenticateOverSslWithPlainText":
+ case "shouldFailIfSslEnabledOnServerButNotClient":
+ final Settings.SslSettings sslConfig = new Settings.SslSettings();
+ sslConfig.enabled = true;
+ settings.ssl = sslConfig;
+ break;
+ }
+
+ return settings;
+ }
+
+ @Test
+ public void shouldFailIfSslEnabledOnServerButNotClient() throws Exception {
+ final Cluster cluster = Cluster.build().create();
+ final Client client = cluster.connect();
+
+ try {
+ client.submit("1+1").all().get();
+ fail("This should not succeed as the client did not enable SSL");
+ } catch(Exception ex) {
+ final Throwable root = ExceptionUtils.getRootCause(ex);
+ assertEquals(TimeoutException.class, root.getClass());
+ assertEquals("Timed out waiting for an available host.", root.getMessage());
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldAuthenticateWithPlainText() throws Exception {
+ final Cluster cluster = Cluster.build().credentials("stephen", "password").create();
+ final Client client = cluster.connect();
+
+ try {
+ assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+ assertEquals(3, client.submit("1+2").all().get().get(0).getInt());
+ assertEquals(4, client.submit("1+3").all().get().get(0).getInt());
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldAuthenticateOverSslWithPlainText() throws Exception {
+ final Cluster cluster = Cluster.build()
+ .enableSsl(true)
+ .credentials("stephen", "password").create();
+ final Client client = cluster.connect();
+
+ try {
+ assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+ assertEquals(3, client.submit("1+2").all().get().get(0).getInt());
+ assertEquals(4, client.submit("1+3").all().get().get(0).getInt());
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldFailAuthenticateWithPlainTextNoCredentials() throws Exception {
+ final Cluster cluster = Cluster.build().create();
+ final Client client = cluster.connect();
+
+ try {
+ client.submit("1+1").all().get();
+ fail("This should not succeed as the client did not provide credentials");
+ } catch(Exception ex) {
+ final Throwable root = ExceptionUtils.getRootCause(ex);
+ assertEquals(GSSException.class, root.getClass());
+ assertThat(root.getMessage(), startsWith("Invalid name provided"));
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldFailAuthenticateWithPlainTextBadPassword() throws Exception {
+ final Cluster cluster = Cluster.build().credentials("stephen", "bad").create();
+ final Client client = cluster.connect();
+
+ try {
+ client.submit("1+1").all().get();
+ fail("This should not succeed as the client did not provide valid credentials");
+ } catch(Exception ex) {
+ final Throwable root = ExceptionUtils.getRootCause(ex);
+ assertEquals(ResponseException.class, root.getClass());
+ assertEquals("Username and/or password are incorrect", root.getMessage());
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldFailAuthenticateWithPlainTextBadUsername() throws Exception {
+ final Cluster cluster = Cluster.build().credentials("marko", "password").create();
+ final Client client = cluster.connect();
+
+ try {
+ client.submit("1+1").all();
+ } catch(Exception ex) {
+ final Throwable root = ExceptionUtils.getRootCause(ex);
+ assertEquals(ResponseException.class, root.getClass());
+ assertEquals("Username and/or password are incorrect", root.getMessage());
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldAuthenticateWithPlainTextOverJSONSerialization() throws Exception {
+ final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON).credentials("stephen", "password").create();
+ final Client client = cluster.connect();
+
+ try {
+ assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+ assertEquals(3, client.submit("1+2").all().get().get(0).getInt());
+ assertEquals(4, client.submit("1+3").all().get().get(0).getInt());
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldAuthenticateWithPlainTextOverGraphSONSerialization() throws Exception {
+ final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON_V1D0).credentials("stephen", "password").create();
+ final Client client = cluster.connect();
+
+ try {
+ assertEquals(2, client.submit("1+1").all().get().get(0).getInt());
+ assertEquals(3, client.submit("1+2").all().get().get(0).getInt());
+ assertEquals(4, client.submit("1+3").all().get().get(0).getInt());
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldAuthenticateAndWorkWithVariablesOverJsonSerialization() throws Exception {
+ final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON).credentials("stephen", "password").create();
+ final Client client = cluster.connect(name.getMethodName());
+
+ try {
+ Map vertex = (Map) client.submit("v=graph.addVertex(\"name\", \"stephen\")").all().get().get(0).getObject();
+ Map<String, List<Map>> properties = (Map) vertex.get("properties");
+ assertEquals("stephen", properties.get("name").get(0).get("value"));
+
+ final Map vpName = (Map)client.submit("v.property('name')").all().get().get(0).getObject();
+ assertEquals("stephen", vpName.get("value"));
+ } finally {
+ cluster.close();
+ }
+ }
+
+ @Test
+ public void shouldAuthenticateAndWorkWithVariablesOverGraphSONSerialization() throws Exception {
+ final Cluster cluster = Cluster.build().serializer(Serializers.GRAPHSON_V1D0).credentials("stephen", "password").create();
+ final Client client = cluster.connect(name.getMethodName());
+
+ try {
+ Map vertex = (Map) client.submit("v=graph.addVertex('name', 'stephen')").all().get().get(0).getObject();
+ Map<String, List<Map>> properties = (Map) vertex.get("properties");
+ assertEquals("stephen", properties.get("name").get(0).get("value"));
+
+ final Map vpName = (Map)client.submit("v.property('name')").all().get().get(0).getObject();
+ assertEquals("stephen", vpName.get("value"));
+ } finally {
+ cluster.close();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
index c4743dd..0530548 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerAuthIntegrateTest.java
@@ -23,7 +23,6 @@ import org.apache.tinkerpop.gremlin.driver.Client;
import org.apache.tinkerpop.gremlin.driver.Cluster;
import org.apache.tinkerpop.gremlin.driver.exception.ResponseException;
import org.apache.tinkerpop.gremlin.server.auth.SimpleAuthenticator;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import org.ietf.jgss.GSSException;
import org.junit.Test;
@@ -54,8 +53,7 @@ public class GremlinServerAuthIntegrateTest extends AbstractGremlinServerIntegra
// use a credentials graph with one user in it: stephen/password
final Map<String,Object> authConfig = new HashMap<>();
- authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_DB, "conf/tinkergraph-empty.properties");
- authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_LOCATION, "data/credentials.kryo");
+ authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_DB, "conf/tinkergraph-credentials.properties");
authSettings.config = authConfig;
settings.authentication = authSettings;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0f4ad252/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
index f46f022..e377851 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpIntegrateTest.java
@@ -81,6 +81,10 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
case "should200OnPOSTWithAuthorizationHeader":
configureForAuthentication(settings);
break;
+ case "should401OnPOSTWithInvalidPasswordAuthorizationHeaderOld":
+ case "should200OnPOSTWithAuthorizationHeaderOld":
+ configureForAuthenticationOld(settings);
+ break;
}
return settings;
}
@@ -91,6 +95,19 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
// use a credentials graph with one user in it: stephen/password
final Map<String,Object> authConfig = new HashMap<>();
+ authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_DB, "conf/tinkergraph-credentials.properties");
+
+ authSettings.config = authConfig;
+ settings.authentication = authSettings;
+ }
+
+ @Deprecated
+ private void configureForAuthenticationOld(final Settings settings) {
+ final Settings.AuthenticationSettings authSettings = new Settings.AuthenticationSettings();
+ authSettings.className = SimpleAuthenticator.class.getName();
+
+ // use a credentials graph with one user in it: stephen/password
+ final Map<String,Object> authConfig = new HashMap<>();
authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_DB, "conf/tinkergraph-empty.properties");
authConfig.put(SimpleAuthenticator.CONFIG_CREDENTIALS_LOCATION, "data/credentials.kryo");
@@ -193,6 +210,20 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
}
@Test
+ @Deprecated
+ public void should401OnPOSTWithInvalidPasswordAuthorizationHeaderOld() throws Exception {
+ final CloseableHttpClient httpclient = HttpClients.createDefault();
+ final HttpPost httppost = new HttpPost("http://localhost:8182");
+ httppost.addHeader("Content-Type", "application/json");
+ httppost.addHeader("Authorization", "Basic " + encoder.encodeToString("stephen:not-my-password".getBytes()));
+ httppost.setEntity(new StringEntity("{\"gremlin\":\"1-1\"}", Consts.UTF_8));
+
+ try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
+ assertEquals(401, response.getStatusLine().getStatusCode());
+ }
+ }
+
+ @Test
public void should200OnGETWithAuthorizationHeader() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpGet httpget = new HttpGet("http://localhost:8182?gremlin=1-1");
@@ -225,6 +256,24 @@ public class GremlinServerHttpIntegrateTest extends AbstractGremlinServerIntegra
}
@Test
+ @Deprecated
+ public void should200OnPOSTWithAuthorizationHeaderOld() throws Exception {
+ final CloseableHttpClient httpclient = HttpClients.createDefault();
+ final HttpPost httppost = new HttpPost("http://localhost:8182");
+ httppost.addHeader("Content-Type", "application/json");
+ httppost.addHeader("Authorization", "Basic " + encoder.encodeToString("stephen:password".getBytes()));
+ httppost.setEntity(new StringEntity("{\"gremlin\":\"1-1\"}", Consts.UTF_8));
+
+ try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals("application/json", response.getEntity().getContentType().getValue());
+ final String json = EntityUtils.toString(response.getEntity());
+ final JsonNode node = mapper.readTree(json);
+ assertEquals(0, node.get("result").get("data").get(0).intValue());
+ }
+ }
+
+ @Test
public void should200OnGETWithGremlinQueryStringArgumentWithBindingsAndFunction() throws Exception {
final CloseableHttpClient httpclient = HttpClients.createDefault();
final HttpGet httpget = new HttpGet("http://localhost:8182?gremlin=addItUp(Integer.parseInt(x),Integer.parseInt(y))&bindings.x=10&bindings.y=10");