You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by jo...@apache.org on 2018/08/23 08:16:49 UTC

[02/14] tinkerpop git commit: Unsaved changes uploaded

Unsaved changes uploaded


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c8ae3c8c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c8ae3c8c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c8ae3c8c

Branch: refs/heads/TINKERPOP-1977
Commit: c8ae3c8cae9cbe7963fa4aea55ba4409cb73fd86
Parents: 2a8b4b4
Author: Matthew Allen <ma...@runbox.com>
Authored: Fri Jul 6 21:12:16 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:36:52 2018 +0100

----------------------------------------------------------------------
 .../lib/driver/driver-remote-connection.js      | 10 ++--
 .../integration/sasl-authentication-tests.js    | 59 ++++++++++++++++++++
 2 files changed, 63 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c8ae3c8c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 153c278..0f46745 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -33,7 +33,7 @@ const responseStatusCode = {
   partialContent: 206,
   authenticationChallenge:  407,
 };
-const defaultMimeType = 'application/vnd.gremlin-v2.0+json';
+const defaultMimeType = 'application/vnd.gremlin-v3.0+json';
 
 class DriverRemoteConnection extends RemoteConnection {
   /**
@@ -77,8 +77,6 @@ class DriverRemoteConnection extends RemoteConnection {
     const mimeType = options.mimeType || defaultMimeType;
     this._header = String.fromCharCode(mimeType.length) + mimeType;
     this.isOpen = false;
-    this.connectionError = false;
-    this.connectionErrorMessage = '';
     this.traversalSource = options.traversalSource || 'g';
 
     if (options.authenticator) {
@@ -119,12 +117,12 @@ class DriverRemoteConnection extends RemoteConnection {
     }));
   }
 
-  _getRequest(id, bytecode, op, args) {
+  _getRequest(id, bytecode) {
     return ({
       'requestId': { '@type': 'g:UUID', '@value': id },
-      'op': op || 'bytecode',
+      'op': 'bytecode',
       'processor': 'traversal',
-      'args': args || {
+      'args': {
         'gremlin': this._writer.adaptObject(bytecode),
         'aliases': { 'g': this.traversalSource }
       }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c8ae3c8c/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/sasl-authentication-tests.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/sasl-authentication-tests.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/sasl-authentication-tests.js
new file mode 100644
index 0000000..c5dc48f
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/sasl-authentication-tests.js
@@ -0,0 +1,59 @@
+/*
+ *  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.
+ */
+
+/**
+ * @author Jorge Bay Gondra
+ */
+'use strict';
+
+const assert = require('assert');
+const Bytecode = require('../../lib/process/bytecode');
+const graphModule = require('../../lib/structure/graph');
+const helper = require('../helper');
+
+let connection;
+
+describe('DriverRemoteConnectionWithSaslAuthenticator', function () {
+  before(function () {
+    connection = helper.getSecureConnectionWithAuthenticator('gmodern');
+    return connection.open();
+  });
+  after(function () {
+    return connection.close();
+  });
+  describe('#submit()', function () {
+    it('should send the request with valid credentials and parse the response', function () {
+      return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
+        .then(function (response) {
+          assert.ok(response);
+          assert.ok(response.traversers);
+          assert.strictEqual(response.traversers.length, 1);
+          assert.ok(response.traversers[0].object instanceof graphModule.Vertex);
+        });
+    });
+    it('should send the request with invaid credentials and parse the response error', function () {
+      connection._authenticator.username = 'Bob';
+      return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
+        .catch(function (err) {
+          assert.ok(err);
+          assert.ok(err.message.indexOf('401') > 0);
+        });
+    });
+  });
+});
\ No newline at end of file