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 12:51:02 UTC

[01/15] tinkerpop git commit: Implementation of Sasl authentication.

Repository: tinkerpop
Updated Branches:
  refs/heads/tp32 675c07717 -> b08d0d856


Implementation of Sasl authentication.


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

Branch: refs/heads/tp32
Commit: 2a8b4b4ff5cf55b82fe2af8f8390724c6688467f
Parents: 675c077
Author: Matthew Allen <ma...@runbox.com>
Authored: Fri Jul 6 20:49:54 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:33:51 2018 +0100

----------------------------------------------------------------------
 .../lib/driver/authenticator.js                 | 14 ++++++
 .../lib/driver/driver-remote-connection.js      | 44 ++++++++-----------
 .../lib/driver/sasl-authenticator.js            | 45 ++++++++++++++++++++
 .../javascript/gremlin-javascript/lib/utils.js  | 23 +++++++++-
 4 files changed, 99 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a8b4b4f/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
new file mode 100644
index 0000000..053aecd
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
@@ -0,0 +1,14 @@
+'use strict';
+
+/** @abstract */
+class Authenticator {
+  constructor(credentials) {
+    this._credentials = credentials;
+  }
+  
+  evaluateChallenge(ws, header) {
+    throw new Error("evaluateChallenge should be implemented");
+  }
+}
+
+module.exports = Authenticator;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a8b4b4f/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 0f7cedb..153c278 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
@@ -22,7 +22,6 @@
  */
 'use strict';
 
-const crypto = require('crypto');
 const WebSocket = require('ws');
 const util = require('util');
 const RemoteConnection = require('./remote-connection').RemoteConnection;
@@ -31,7 +30,8 @@ const serializer = require('../structure/io/graph-serializer');
 const responseStatusCode = {
   success: 200,
   noContent: 204,
-  partialContent: 206
+  partialContent: 206,
+  authenticationChallenge:  407,
 };
 const defaultMimeType = 'application/vnd.gremlin-v2.0+json';
 
@@ -48,6 +48,7 @@ class DriverRemoteConnection extends RemoteConnection {
    * @param {Boolean} [options.rejectUnauthorized] Determines whether to verify or not the server certificate.
    * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
    * @param {GraphSONWriter} [options.writer] The writer to use.
+   * @param {Authenticator} [options.authenticator] The authentication handler to use.
    * @constructor
    */
   constructor(url, options) {
@@ -76,7 +77,13 @@ 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) {
+      this._authenticator = options.authenticator;
+    }
   }
 
   /**
@@ -102,7 +109,7 @@ class DriverRemoteConnection extends RemoteConnection {
   /** @override */
   submit(bytecode) {
     return this.open().then(() => new Promise((resolve, reject) => {
-      const requestId = getUuid();
+      const requestId = utils.getUuid();
       this._responseHandlers[requestId] = {
         callback: (err, result) => err ? reject(err) : resolve(result),
         result: null
@@ -112,12 +119,12 @@ class DriverRemoteConnection extends RemoteConnection {
     }));
   }
 
-  _getRequest(id, bytecode) {
+  _getRequest(id, bytecode, op, args) {
     return ({
       'requestId': { '@type': 'g:UUID', '@value': id },
-      'op': 'bytecode',
+      'op': op || 'bytecode',
       'processor': 'traversal',
-      'args': {
+      'args': args || {
         'gremlin': this._writer.adaptObject(bytecode),
         'aliases': { 'g': this.traversalSource }
       }
@@ -151,7 +158,11 @@ class DriverRemoteConnection extends RemoteConnection {
       return;
     }
 
-    if (response.status.code >= 400) {
+    if (response.status.code === responseStatusCode.authenticationChallenge && this._authenticator) {
+       this._authenticator.evaluateChallenge(this._ws, this._header);
+       return;
+    }
+    else if (response.status.code >= 400) {
       // callback in error
       return handler.callback(
         new Error(util.format('Server error: %s (%d)', response.status.message, response.status.code)));
@@ -203,25 +214,6 @@ class DriverRemoteConnection extends RemoteConnection {
   }
 }
 
-function getUuid() {
-  const buffer = crypto.randomBytes(16);
-  //clear the version
-  buffer[6] &= 0x0f;
-  //set the version 4
-  buffer[6] |= 0x40;
-  //clear the variant
-  buffer[8] &= 0x3f;
-  //set the IETF variant
-  buffer[8] |= 0x80;
-  const hex = buffer.toString('hex');
-  return (
-    hex.substr(0, 8) + '-' +
-    hex.substr(8, 4) + '-' +
-    hex.substr(12, 4) + '-' +
-    hex.substr(16, 4) + '-' +
-    hex.substr(20, 12));
-}
-
 const bufferFromString = (Int8Array.from !== Buffer.from && Buffer.from) || function newBuffer(text) {
   return new Buffer(text, 'utf8');
 };

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a8b4b4f/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
new file mode 100644
index 0000000..1f08b7d
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
@@ -0,0 +1,45 @@
+'use strict';
+
+const Authenticator = require('./authenticator');
+const utils = require('../utils');
+
+class SaslAuthenticator extends Authenticator {
+  /**
+   * Creates a new instance of SaslAuthenticator.
+   * @param {Object} [credentials] The authentication credential options.
+   * @param {String} [credentials.username] The user for the authentication response.
+   * @param {String} [credentials.password] The plaintext password for authentication response.
+   * @constructor
+   */
+  constructor(credentials) {
+    super(credentials);
+  }
+  
+  evaluateChallenge(ws, header) {
+    const message = bufferFromString(header + JSON.stringify({
+      'requestId': { '@type': 'g:UUID', '@value': utils.getUuid() },
+      'op': 'authentication',
+      'processor': 'traversal',
+      'args': {
+        'sasl': this.saslArgument()
+      }
+    }));
+    
+    return ws.send(message);
+  }
+
+  saslArgument() {
+    if (this._credentials.username === null || this._credentials.username.length === 0 
+      || this._credentials.password === null || this._credentials.password.length === 0 ) {
+      return '';
+    }
+    return new Buffer(`\0${this._credentials.username}\0${this._credentials.password}`).toString('base64');
+  }
+}
+
+
+const bufferFromString = (Int8Array.from !== Buffer.from && Buffer.from) || function newBuffer(text) {
+  return new Buffer(text, 'utf8');
+};
+
+module.exports = SaslAuthenticator;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2a8b4b4f/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
index e3a001c..7abc5fe 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/utils.js
@@ -23,6 +23,8 @@
  */
 'use strict';
 
+const crypto = require('crypto');
+
 exports.toLong = function toLong(value) {
   return new Long(value);
 };
@@ -32,4 +34,23 @@ const Long = exports.Long = function Long(value) {
     throw new TypeError('Ty')
   }
   this.value = value.toString();
-};
\ No newline at end of file
+};
+
+exports.getUuid = function getUuid() {
+  const buffer = crypto.randomBytes(16);
+  //clear the version
+  buffer[6] &= 0x0f;
+  //set the version 4
+  buffer[6] |= 0x40;
+  //clear the variant
+  buffer[8] &= 0x3f;
+  //set the IETF variant
+  buffer[8] |= 0x80;
+  const hex = buffer.toString('hex');
+  return (
+    hex.substr(0, 8) + '-' +
+    hex.substr(8, 4) + '-' +
+    hex.substr(12, 4) + '-' +
+    hex.substr(16, 4) + '-' +
+    hex.substr(20, 12));
+}
\ No newline at end of file


[08/15] tinkerpop git commit: Switched from TLS sockets to normal socket on connection to gremlin secure server.

Posted by jo...@apache.org.
Switched from TLS sockets to normal socket on connection to gremlin secure server.


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

Branch: refs/heads/tp32
Commit: bdecf85fb5a0df9d11bffc948bd213921125e0de
Parents: 5e5a09b
Author: Matthew Allen <ma...@runbox.com>
Authored: Wed Jul 18 23:35:12 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:38:58 2018 +0100

----------------------------------------------------------------------
 .../src/main/javascript/gremlin-javascript/test/helper.js       | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bdecf85f/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
index 99fea7f..5a90296 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -26,12 +26,9 @@ const DriverRemoteConnection = require('../lib/driver/driver-remote-connection')
 
 exports.getConnection = function getConnection(traversalSource) {
   return new DriverRemoteConnection('ws://localhost:45940/gremlin', { traversalSource: traversalSource });
-<<<<<<< HEAD
-=======
 };
 
 exports.getSecureConnectionWithAuthenticator = function getConnection(traversalSource) {
   const authenticator = new SaslAuthenticator({ username: 'stephen', password: 'password' });
-  return new DriverRemoteConnection('wss://localhost:45941/gremlin', { traversalSource: traversalSource, authenticator: authenticator, rejectUnauthorized: false });
->>>>>>> 65de11c3c8... Submit can accept an existing requestId.
+  return new DriverRemoteConnection('ws://localhost:45941/gremlin', { traversalSource: traversalSource, authenticator: authenticator, rejectUnauthorized: false });
 };
\ No newline at end of file


[04/15] tinkerpop git commit: Removed async keyword from Authenticator class for JS compatability.

Posted by jo...@apache.org.
Removed async keyword from Authenticator class for JS compatability.


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

Branch: refs/heads/tp32
Commit: 0e05499d1e131c318cc7bb8e486792ba38773dd5
Parents: 6f65b92
Author: Matthew Allen <ma...@runbox.com>
Authored: Tue Jul 10 10:47:14 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:36:59 2018 +0100

----------------------------------------------------------------------
 .../main/javascript/gremlin-javascript/lib/driver/authenticator.js | 2 +-
 .../javascript/gremlin-javascript/lib/driver/sasl-authenticator.js | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e05499d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
index fe83077..c57cec5 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
@@ -6,7 +6,7 @@ class Authenticator {
     this._credentials = credentials;
   }
   
-  async evaluateChallenge(challenge) {
+  evaluateChallenge(challenge) {
     throw new Error("evaluateChallenge should be implemented");
   }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0e05499d/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
index d7db3de..fb4c5af 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
@@ -14,7 +14,7 @@ class SaslAuthenticator extends Authenticator {
     super(credentials);
   }
   
-  async evaluateChallenge(challenge) {
+  evaluateChallenge(challenge) {
     return Promise.resolve({ 'sasl': this.saslArgument() });
   }
 


[15/15] tinkerpop git commit: Merge branch 'TINKERPOP-1977' into tp32

Posted by jo...@apache.org.
Merge branch 'TINKERPOP-1977' into tp32


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

Branch: refs/heads/tp32
Commit: b08d0d8569a1a6fb13f3c015df3e69604df7b1e7
Parents: 675c077 e61fcf1
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Aug 23 14:50:14 2018 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Thu Aug 23 14:50:14 2018 +0200

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 docs/src/reference/gremlin-variants.asciidoc    |  8 ++
 .../upgrade/release-3.2.x-incubating.asciidoc   |  2 +
 .../main/javascript/gremlin-javascript/index.js |  8 +-
 .../lib/driver/auth/authenticator.js            | 38 ++++++++
 .../auth/mechanisms/sasl-mechanism-base.js      | 52 +++++++++++
 .../auth/mechanisms/sasl-mechanism-plain.js     | 96 ++++++++++++++++++++
 .../auth/plain-text-sasl-authenticator.js       | 55 +++++++++++
 .../lib/driver/auth/sasl-authenticator.js       | 49 ++++++++++
 .../lib/driver/driver-remote-connection.js      | 85 ++++++++++-------
 .../lib/driver/remote-connection.js             |  5 +-
 .../javascript/gremlin-javascript/lib/utils.js  | 23 ++++-
 .../gremlin-javascript/test/helper.js           | 11 +++
 .../integration/sasl-authentication-tests.js    | 63 +++++++++++++
 14 files changed, 461 insertions(+), 35 deletions(-)
----------------------------------------------------------------------



[09/15] tinkerpop git commit: Added support for mechanism plugins for Sasl handler

Posted by jo...@apache.org.
Added support for mechanism plugins for Sasl handler


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

Branch: refs/heads/tp32
Commit: 7a5cb9c8053dbd303f70f5bbca95dcde528cf886
Parents: bdecf85
Author: Matthew Allen <ma...@runbox.com>
Authored: Sun Jul 29 15:59:08 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:39:26 2018 +0100

----------------------------------------------------------------------
 .../auth/mechanisms/sasl-mechanism-base.js      | 36 +++++++++++++++++++
 .../auth/mechanisms/sasl-mechanism-plain.js     | 37 ++++++++++++++++++++
 .../lib/driver/driver-remote-connection.js      |  2 +-
 .../lib/driver/sasl-authenticator.js            | 28 +++++++--------
 .../gremlin-javascript/test/helper.js           | 11 ++++--
 5 files changed, 97 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7a5cb9c8/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js
new file mode 100644
index 0000000..4b75778
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js
@@ -0,0 +1,36 @@
+/*
+ *  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.
+ */
+'use strict';
+
+/** @abstract */
+class SaslMechanismBase {
+  get name() {
+    return null;
+  }
+
+  setopts(options) {
+    this._options = options;
+  }
+
+  evaluateChallenge(challenge) {
+    throw new Error("evaluateChallenge should be implemented");
+  }
+}
+
+module.exports = SaslMechanismBase;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7a5cb9c8/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js
new file mode 100644
index 0000000..be418be
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js
@@ -0,0 +1,37 @@
+'use strict';
+
+const SaslMechanismBase = require('./sasl-mechanism-base');
+
+class SaslMechanismPlain extends SaslMechanismBase {
+  get name() {
+    return 'PLAIN';
+  }
+  
+  evaluateChallenge(challenge) {
+    if (this._hasInitialResponse(challenge)) {
+      return Promise.resolve({ 'saslMechanism': this.name, 'sasl': this._saslArgument() });
+    }
+    
+    return Promise.resolve({ 'sasl': this._saslArgument() });
+  }
+
+  _saslArgument() {
+    if (this._options.username === undefined || this._options.username.length === 0 
+      || this._options.password === undefined || this._options.password.length === 0 ) {
+        throw new Error('No Credentials Supplied');
+    }
+
+    const authstr = ((this._options.authId !== undefined && this._options.authId.length) ? this._options.authId : '')
+      + `\0${this._options.username}\0${this._options.password}`;
+    return new Buffer(authstr).toString('base64');
+  }
+
+  _hasInitialResponse(challenge) {
+    if (challenge === undefined || challenge === null) {
+      return false;
+    }
+    return true;
+  }
+}
+
+module.exports = SaslMechanismPlain;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7a5cb9c8/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 c60492e..04deee7 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
@@ -163,7 +163,7 @@ class DriverRemoteConnection extends RemoteConnection {
     }
 
     if (response.status.code === responseStatusCode.authenticationChallenge && this._authenticator) {
-      this._authenticator.evaluateChallenge(response).then(res => {
+      this._authenticator.evaluateChallenge(response.result.data).then(res => {
         return this.submit(null, 'authentication', res, response.requestId);
       }).catch(handler.callback);
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7a5cb9c8/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
index fb4c5af..4b63ab5 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
@@ -5,25 +5,25 @@ const Authenticator = require('./authenticator');
 class SaslAuthenticator extends Authenticator {
   /**
    * Creates a new instance of SaslAuthenticator.
-   * @param {Object} [credentials] The authentication credential options.
-   * @param {String} [credentials.username] The user for the authentication response.
-   * @param {String} [credentials.password] The plaintext password for authentication response.
+   * @param {Object} [options] The authentication options.
+   * @param {Object} [options.mechanism] The mechanism to be used for authentication.
+   * @param {String} [options.hostname] The hostname of the client.
+   * @param {*} [options] Other mechanism specific options.
    * @constructor
    */
-  constructor(credentials) {
-    super(credentials);
+  constructor(options) {
+    super(options);
+
+    if (options.mechanism === null || options.mechanism === undefined) {
+      throw new Error('No Sasl Mechanism Specified');
+    }
+
+    this._options = options;
+    this._options.mechanism.setopts(this._options);
   }
   
   evaluateChallenge(challenge) {
-    return Promise.resolve({ 'sasl': this.saslArgument() });
-  }
-
-  saslArgument() {
-    if (typeof this._credentials.username === "undefined" || this._credentials.username.length === 0 
-      || typeof this._credentials.password === "undefined" || this._credentials.password.length === 0 ) {
-        throw new Error('No Credentials Supplied');
-    }
-    return new Buffer(`\0${this._credentials.username}\0${this._credentials.password}`).toString('base64');
+    return Promise.resolve(this._options.mechanism.evaluateChallenge(challenge));
   }
 }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7a5cb9c8/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
index 5a90296..25e9557 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -21,14 +21,21 @@
  * @author Jorge Bay Gondra
  */
 'use strict';
+const os = require('os');
 
 const DriverRemoteConnection = require('../lib/driver/driver-remote-connection');
+const SaslAuthenticator = require('../lib/driver/sasl-authenticator');
+const SaslMechanismPlain = require('../lib/driver/auth/mechanisms/sasl-mechanism-plain');
 
 exports.getConnection = function getConnection(traversalSource) {
   return new DriverRemoteConnection('ws://localhost:45940/gremlin', { traversalSource: traversalSource });
 };
 
 exports.getSecureConnectionWithAuthenticator = function getConnection(traversalSource) {
-  const authenticator = new SaslAuthenticator({ username: 'stephen', password: 'password' });
-  return new DriverRemoteConnection('ws://localhost:45941/gremlin', { traversalSource: traversalSource, authenticator: authenticator, rejectUnauthorized: false });
+  const authenticator = new SaslAuthenticator({ mechanism: new SaslMechanismPlain(), username: 'stephen', password: 'password', authId: os.hostname() });
+  return new DriverRemoteConnection('wss://localhost:45941/gremlin', { 
+    traversalSource: traversalSource, 
+    authenticator: authenticator, 
+    rejectUnauthorized: false 
+  });
 };
\ No newline at end of file


[12/15] tinkerpop git commit: Tidying-up of authenticator and integeration tests.

Posted by jo...@apache.org.
Tidying-up of authenticator and integeration tests.


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

Branch: refs/heads/tp32
Commit: 18598baff6039dd281bb18d42524c3f317d97218
Parents: 8453b61
Author: Matthew Allen <ma...@runbox.com>
Authored: Wed Aug 1 20:30:13 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:39:29 2018 +0100

----------------------------------------------------------------------
 .../main/javascript/gremlin-javascript/index.js |  6 +-
 .../lib/driver/auth/authenticator.js            | 19 +++++
 .../auth/mechanisms/sasl-mechanism-base.js      | 18 ++++-
 .../auth/mechanisms/sasl-mechanism-plain.js     | 81 +++++++++++++++++---
 .../lib/driver/auth/sasl-authenticator.js       | 30 ++++++++
 .../lib/driver/authenticator.js                 | 14 ----
 .../lib/driver/sasl-authenticator.js            | 30 --------
 .../gremlin-javascript/test/helper.js           |  4 +-
 .../integration/sasl-authentication-tests.js    |  8 +-
 9 files changed, 143 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index 5ada391..d4c6d88 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -31,17 +31,13 @@ const rc = require('./lib/driver/remote-connection');
 const Bytecode = require('./lib/process/bytecode');
 const utils = require('./lib/utils');
 const DriverRemoteConnection = require('./lib/driver/driver-remote-connection');
-const Auth = require('./lib/driver/authenticator');
-const SaslAuth = require('./lib/driver/sasl-authenticator');
 
 module.exports = {
   driver: {
     RemoteConnection: rc.RemoteConnection,
     RemoteStrategy: rc.RemoteStrategy,
     RemoteTraversal: rc.RemoteTraversal,
-    DriverRemoteConnection: DriverRemoteConnection,
-    Authenticator: Auth,
-    SaslAuthenticator: SaslAuth
+    DriverRemoteConnection: DriverRemoteConnection
   },
   process: {
     Bytecode: Bytecode,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js
new file mode 100644
index 0000000..b57e385
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js
@@ -0,0 +1,19 @@
+'use strict';
+
+/** @abstract */
+class Authenticator {
+  constructor(options) {
+    this._options = options;
+  }
+  
+  /**
+   * @abstract
+   * Evaluates the challenge from the server and returns appropriate response.
+   * @param {String} challenge Challenge string presented by the server.
+   */
+  evaluateChallenge(challenge) {
+    throw new Error("evaluateChallenge should be implemented");
+  }
+}
+
+module.exports = Authenticator;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js
index 4b75778..b909cc8 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-base.js
@@ -20,17 +20,33 @@
 
 /** @abstract */
 class SaslMechanismBase {
+  constructor(options) {
+    this.setopts(options);
+  }
+
+  /**
+   * Returns the name of the mechanism
+   */
   get name() {
     return null;
   }
 
+  /**
+   * Set the options for the mechanism
+   * @param {object} options Options specific to the mechanism
+   */
   setopts(options) {
     this._options = options;
   }
 
+  /**
+   * @abstract
+   * Evaluates the challenge from the server and returns appropriate response
+   * @param {String} challenge Challenge string presented by the server
+   */
   evaluateChallenge(challenge) {
     throw new Error("evaluateChallenge should be implemented");
   }
 }
 
-module.exports = SaslMechanismBase;
\ No newline at end of file
+module.exports = SaslMechanismBase;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js
index be418be..597a929 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/mechanisms/sasl-mechanism-plain.js
@@ -1,31 +1,90 @@
+/*
+ *  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.
+ */
 'use strict';
 
 const SaslMechanismBase = require('./sasl-mechanism-base');
 
 class SaslMechanismPlain extends SaslMechanismBase {
+  /**
+   * Creates a new instance of SaslMechanismPlain.
+   * @param {Object} [options] The mechanism options.
+   * @param {String} [options.authzid] The identity of the client.
+   * @param {String} [options.username] The identity of user with access to server.
+   * @param {String} [options.password] The password of user with access to server.
+   * @constructor
+   */
+  constructor(options) {
+    super(options);
+
+    if (this._options.username === undefined
+      || this._options.username === null
+      || this._options.username.length == 0
+      || this._options.password === undefined
+      || this._options.password === null
+      || this._options.password.length == 0
+    ) {
+      throw new Error('Missing credentials for SASL PLAIN mechanism');
+    }
+  }
+
+  /**
+   * Returns the name of the mechanism
+   */
   get name() {
     return 'PLAIN';
   }
   
+  /**
+   * Evaluates the challenge from the server and returns appropriate response.
+   * @param {String} challenge Challenge string presented by the server.
+   * @return {Object} A Promise that resolves to a valid sasl response object.
+   */
   evaluateChallenge(challenge) {
     if (this._hasInitialResponse(challenge)) {
-      return Promise.resolve({ 'saslMechanism': this.name, 'sasl': this._saslArgument() });
+      return Promise.resolve({
+        'saslMechanism': this.name,
+        'sasl': this._saslArgument(this._options.authzid, this._options.username, this._options.password)
+      });
     }
     
-    return Promise.resolve({ 'sasl': this._saslArgument() });
+    return Promise.resolve({ 'sasl': this._saslArgument(this._options.authzid, this._options.username, this._options.password) });
   }
 
-  _saslArgument() {
-    if (this._options.username === undefined || this._options.username.length === 0 
-      || this._options.password === undefined || this._options.password.length === 0 ) {
-        throw new Error('No Credentials Supplied');
-    }
+  /**
+   * Generates a base64 encoded sasl argument based on the given parameters.
+   * @param {String} authzid Identitiy of the client.
+   * @param {String} username The identity of user with access to server.
+   * @param {String} password The password of user with access to server.
+   */
+  _saslArgument(authzid, username, password) {
+    if (authzid === undefined || authzid === null) authzid = '';
+    if (username === undefined || username === null) username = '';
+    if (password === undefined || password.length === null) password = '';
 
-    const authstr = ((this._options.authId !== undefined && this._options.authId.length) ? this._options.authId : '')
-      + `\0${this._options.username}\0${this._options.password}`;
-    return new Buffer(authstr).toString('base64');
+    return new Buffer(`${authzid}\0${username}\0${password}`).toString('base64');
   }
 
+  /**
+   * Checks challenge to see if we have the initial sasl response from the server.
+   * @param {String} challenge The challenge string from the server.
+   * @return {Boolean}
+   */
   _hasInitialResponse(challenge) {
     if (challenge === undefined || challenge === null) {
       return false;
@@ -34,4 +93,4 @@ class SaslMechanismPlain extends SaslMechanismBase {
   }
 }
 
-module.exports = SaslMechanismPlain;
\ No newline at end of file
+module.exports = SaslMechanismPlain;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
new file mode 100644
index 0000000..eb1fbe8
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const Authenticator = require('./authenticator');
+
+class SaslAuthenticator extends Authenticator {
+  /**
+   * Creates a new instance of SaslAuthenticator.
+   * @param {Object} [options] The authentication options.
+   * @param {Object} [options.mechanism] The mechanism to be used for authentication.
+   * @constructor
+   */
+  constructor(options) {
+    super(options);
+
+    if (options.mechanism === null || options.mechanism === undefined) {
+      throw new Error('No Sasl Mechanism Specified');
+    }
+  }
+  
+  /**
+   * Evaluates the challenge from the server and returns appropriate response.
+   * @param {String} challenge Challenge string presented by the server.
+   * @return {Object} A Promise that resolves to a valid sasl response object.
+   */
+  evaluateChallenge(challenge) {
+    return Promise.resolve(this._options.mechanism.evaluateChallenge(challenge));
+  }
+}
+
+module.exports = SaslAuthenticator;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
deleted file mode 100644
index c57cec5..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
+++ /dev/null
@@ -1,14 +0,0 @@
-'use strict';
-
-/** @abstract */
-class Authenticator {
-  constructor(credentials) {
-    this._credentials = credentials;
-  }
-  
-  evaluateChallenge(challenge) {
-    throw new Error("evaluateChallenge should be implemented");
-  }
-}
-
-module.exports = Authenticator;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
deleted file mode 100644
index 4b63ab5..0000000
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
+++ /dev/null
@@ -1,30 +0,0 @@
-'use strict';
-
-const Authenticator = require('./authenticator');
-
-class SaslAuthenticator extends Authenticator {
-  /**
-   * Creates a new instance of SaslAuthenticator.
-   * @param {Object} [options] The authentication options.
-   * @param {Object} [options.mechanism] The mechanism to be used for authentication.
-   * @param {String} [options.hostname] The hostname of the client.
-   * @param {*} [options] Other mechanism specific options.
-   * @constructor
-   */
-  constructor(options) {
-    super(options);
-
-    if (options.mechanism === null || options.mechanism === undefined) {
-      throw new Error('No Sasl Mechanism Specified');
-    }
-
-    this._options = options;
-    this._options.mechanism.setopts(this._options);
-  }
-  
-  evaluateChallenge(challenge) {
-    return Promise.resolve(this._options.mechanism.evaluateChallenge(challenge));
-  }
-}
-
-module.exports = SaslAuthenticator;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
index e1c24a3..82c47be 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -24,7 +24,7 @@
 const os = require('os');
 
 const DriverRemoteConnection = require('../lib/driver/driver-remote-connection');
-const SaslAuthenticator = require('../lib/driver/sasl-authenticator');
+const SaslAuthenticator = require('../lib/driver/auth/sasl-authenticator');
 const SaslMechanismPlain = require('../lib/driver/auth/mechanisms/sasl-mechanism-plain');
 
 exports.getConnection = function getConnection(traversalSource) {
@@ -32,7 +32,7 @@ exports.getConnection = function getConnection(traversalSource) {
 };
 
 exports.getSecureConnectionWithAuthenticator = function getConnection(traversalSource) {
-  const authenticator = new SaslAuthenticator({ mechanism: new SaslMechanismPlain(), username: 'stephen', password: 'password', authId: os.hostname() });
+  const authenticator = new SaslAuthenticator({ mechanism: new SaslMechanismPlain({ username: 'stephen', password: 'password', authzid: os.hostname() }) });
   return new DriverRemoteConnection('ws://localhost:45941/gremlin', { 
     traversalSource: traversalSource, 
     authenticator: authenticator, 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/18598baf/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
index f38d087..c9450f8 100644
--- 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
@@ -49,16 +49,16 @@ describe('DriverRemoteConnectionWithSaslAuthenticator', function () {
         });
     });
     it('should send the request with invalid credentials and parse the response error', function () {
-      connection._authenticator.username = 'Bob';
+      connection._authenticator._options.mechanism._options.username = 'Bob';
       return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
         .catch(function (err) {
           assert.ok(err);
           assert.ok(err.message.indexOf('401') > 0);
         });
     });
-    it('should send incorrect conifugration to the authenticator and parse the response error', function () {
-      delete connection._authenticator.username;
-      delete connection._authenticator.password;
+    it('should send incorrect configuration to the authenticator and parse the response error', function () {
+      delete connection._authenticator._options.mechanism._options.username;
+      delete connection._authenticator._options.mechanism._options.password;
       return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
         .catch(function (err) {
           assert.ok(err);


[11/15] tinkerpop git commit: Added PlainTextSaslAuthenticator helper and updated the tests to use it.

Posted by jo...@apache.org.
Added PlainTextSaslAuthenticator helper and updated the tests to use it.


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

Branch: refs/heads/tp32
Commit: cc57c2b886652bcdad127bb0358c9b85156b5156
Parents: 18598ba
Author: Matthew Allen <ma...@runbox.com>
Authored: Mon Aug 13 21:08:25 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:39:29 2018 +0100

----------------------------------------------------------------------
 .../auth/plain-text-sasl-authenticator.js       | 53 ++++++++++++++++++++
 .../lib/driver/auth/sasl-authenticator.js       |  2 +-
 .../gremlin-javascript/test/helper.js           |  7 ++-
 .../integration/sasl-authentication-tests.js    |  9 +---
 4 files changed, 59 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cc57c2b8/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js
new file mode 100644
index 0000000..b8f104d
--- /dev/null
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js
@@ -0,0 +1,53 @@
+/*
+ *  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.
+ */
+'use strict';
+
+const Authenticator = require('./authenticator');
+const SaslMechanismPlain = require('./mechanisms/sasl-mechanism-plain');
+
+class PlainTextSaslAuthenticator extends Authenticator {
+  /**
+   * Creates a new instance of PlainTextSaslAuthenticator.
+   * @param {string} username Username to log into the server.
+   * @param {string} password Password for the user.
+   * @constructor
+   */
+  constructor(username, password, authzid) {
+    const options = {
+      mechanism: new SaslMechanismPlain({
+        'username': username,
+        'password': password,
+        'authzid': authzid
+      })
+    };
+
+    super(options);
+  }
+  
+  /**
+   * Evaluates the challenge from the server and returns appropriate response.
+   * @param {String} challenge Challenge string presented by the server.
+   * @return {Object} A Promise that resolves to a valid sasl response object.
+   */
+  evaluateChallenge(challenge) {
+    return this._options.mechanism.evaluateChallenge(challenge);
+  }
+}
+
+module.exports = PlainTextSaslAuthenticator;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cc57c2b8/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
index eb1fbe8..cdf56e1 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
@@ -23,7 +23,7 @@ class SaslAuthenticator extends Authenticator {
    * @return {Object} A Promise that resolves to a valid sasl response object.
    */
   evaluateChallenge(challenge) {
-    return Promise.resolve(this._options.mechanism.evaluateChallenge(challenge));
+    return this._options.mechanism.evaluateChallenge(challenge);
   }
 }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cc57c2b8/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
index 82c47be..899a8ad 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -24,15 +24,14 @@
 const os = require('os');
 
 const DriverRemoteConnection = require('../lib/driver/driver-remote-connection');
-const SaslAuthenticator = require('../lib/driver/auth/sasl-authenticator');
-const SaslMechanismPlain = require('../lib/driver/auth/mechanisms/sasl-mechanism-plain');
+const PlainTextSaslAuthenticator = require('../lib/driver/auth/plain-text-sasl-authenticator');
 
 exports.getConnection = function getConnection(traversalSource) {
   return new DriverRemoteConnection('ws://localhost:45940/gremlin', { traversalSource: traversalSource });
 };
 
-exports.getSecureConnectionWithAuthenticator = function getConnection(traversalSource) {
-  const authenticator = new SaslAuthenticator({ mechanism: new SaslMechanismPlain({ username: 'stephen', password: 'password', authzid: os.hostname() }) });
+exports.getSecureConnectionWithPlainTextSaslAuthenticator = function getConnection(traversalSource) {
+  const authenticator = new PlainTextSaslAuthenticator('stephen', 'password');
   return new DriverRemoteConnection('ws://localhost:45941/gremlin', { 
     traversalSource: traversalSource, 
     authenticator: authenticator, 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/cc57c2b8/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
index c9450f8..2cf1dff 100644
--- 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
@@ -17,9 +17,6 @@
  *  under the License.
  */
 
-/**
- * @author Jorge Bay Gondra
- */
 'use strict';
 
 const assert = require('assert');
@@ -29,10 +26,10 @@ const helper = require('../helper');
 
 let connection;
 
-describe('DriverRemoteConnectionWithSaslAuthenticator', function () {
+describe('DriverRemoteConnectionWithPlainTextSaslAuthenticator', function () {
   before(function () {
     this.timeout(20000);
-    connection = helper.getSecureConnectionWithAuthenticator(null);
+    connection = helper.getSecureConnectionWithPlainTextSaslAuthenticator(null);
     return connection.open();
   });
   after(function () {
@@ -44,8 +41,6 @@ describe('DriverRemoteConnectionWithSaslAuthenticator', function () {
         .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 invalid credentials and parse the response error', function () {


[13/15] tinkerpop git commit: Updated documentation reflecting TINKERPOP-1977 changes. Added helper for auth to the gremlin-javascript exports.

Posted by jo...@apache.org.
Updated documentation reflecting TINKERPOP-1977 changes.
Added helper for auth to the gremlin-javascript exports.


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

Branch: refs/heads/tp32
Commit: a561ee01455757ed2948aab3eb46e327310ce73a
Parents: cc57c2b
Author: Matthew Allen <ma...@runbox.com>
Authored: Thu Aug 23 06:44:58 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:44:58 2018 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                                          | 1 +
 docs/src/reference/gremlin-variants.asciidoc                | 9 +++++++++
 docs/src/upgrade/release-3.2.x-incubating.asciidoc          | 2 ++
 .../src/main/javascript/gremlin-javascript/index.js         | 6 +++++-
 4 files changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a561ee01/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index eb1a6c5..f12c4ad 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -51,6 +51,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Fixed a bug in `TinkerGraphCountStrategy`, which didn't consider that certain map steps may not emit an element.
 * Fixed a bug in JavaScript GLV where DriverRemoteConnection close() method didn't returned a Promise instance.
 * Bumped to Jackson 2.9.6.
+* Sasl Plain Text Authentication added to Gremlin Javascript.
 
 [[release-3-2-9]]
 === TinkerPop 3.2.9 (Release Date: May 8, 2018)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a561ee01/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index e8b4c21..290b39b 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -484,6 +484,15 @@ const graph = new Graph();
 const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
 ----
 
+or for Gremlin Servers requiring SASL authentication
+
+[source,javascript]
+----
+const graph = new Graph();
+const Authenicator = gremlin.driver.auth.PlainTextSaslAuthenicator;
+const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', { authenticator: new Authenticator(username, password, optionalAuthzid) });
+----
+
 When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via
 the registered `RemoteConnection`. The bytecode is used to construct the equivalent traversal at the remote
 traversal source.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a561ee01/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index af03937..6f2aff8 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -29,6 +29,8 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.2.10/CHANGELOG.as
 
 === Upgrading for Users
 
+The Gremlin Javascript Driver now supports SASL Plain Text authentication against a Gremlin Server. See: link:http://tinkerpop.apache.org/docs/current/reference#gremlin-javascript[Reference Documentation - Gremlin Javasctipt]
+
 ==== Bulk Import and Export
 
 TinkerPop has provided some general methods for importing and exporting data, but more and more graph providers are

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a561ee01/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index d4c6d88..9cc6349 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -31,13 +31,17 @@ const rc = require('./lib/driver/remote-connection');
 const Bytecode = require('./lib/process/bytecode');
 const utils = require('./lib/utils');
 const DriverRemoteConnection = require('./lib/driver/driver-remote-connection');
+const PlainTextSaslAuthenticator = require('./lib/driver/auth/plain-text-sasl-authenticator');
 
 module.exports = {
   driver: {
     RemoteConnection: rc.RemoteConnection,
     RemoteStrategy: rc.RemoteStrategy,
     RemoteTraversal: rc.RemoteTraversal,
-    DriverRemoteConnection: DriverRemoteConnection
+    DriverRemoteConnection: DriverRemoteConnection,
+    auth: {
+      PlainTextSaslAuthenticator: PlainTextSaslAuthenticator
+    }
   },
   process: {
     Bytecode: Bytecode,


[06/15] tinkerpop git commit: Updated Sasl test to remove gmodern traversal

Posted by jo...@apache.org.
Updated Sasl test to remove gmodern traversal


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

Branch: refs/heads/tp32
Commit: 5e5a09b35c4e897979c35be0dd3485c5900964e6
Parents: 8098733
Author: Matthew Allen <ma...@runbox.com>
Authored: Wed Jul 18 23:06:38 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:37:59 2018 +0100

----------------------------------------------------------------------
 .../test/integration/sasl-authentication-tests.js           | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5e5a09b3/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
index d517d22..f38d087 100644
--- 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
@@ -31,7 +31,8 @@ let connection;
 
 describe('DriverRemoteConnectionWithSaslAuthenticator', function () {
   before(function () {
-    connection = helper.getSecureConnectionWithAuthenticator('gmodern');
+    this.timeout(20000);
+    connection = helper.getSecureConnectionWithAuthenticator(null);
     return connection.open();
   });
   after(function () {
@@ -43,11 +44,11 @@ describe('DriverRemoteConnectionWithSaslAuthenticator', function () {
         .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);
+          //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 () {
+    it('should send the request with invalid credentials and parse the response error', function () {
       connection._authenticator.username = 'Bob';
       return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
         .catch(function (err) {


[07/15] tinkerpop git commit: Fix for incorrect code in _adaptArgs function.

Posted by jo...@apache.org.
Fix for incorrect code in _adaptArgs function.


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

Branch: refs/heads/tp32
Commit: 80987330fb9a724e7c94cf1c49f1bec1c8d125da
Parents: f67fea4
Author: Matthew Allen <ma...@runbox.com>
Authored: Fri Jul 13 00:58:52 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:37:59 2018 +0100

----------------------------------------------------------------------
 .../gremlin-javascript/lib/driver/driver-remote-connection.js    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/80987330/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 bec599b..c60492e 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
@@ -216,8 +216,8 @@ class DriverRemoteConnection extends RemoteConnection {
 
     if (args instanceof Object) {
       let newObj = {};
-      Object.keys(args).forEach((key, val) => {
-        newObj[key] = this._adaptArgs(val);
+      Object.keys(args).forEach((key) => {
+        newObj[key] = this._adaptArgs(args[key]);
       });
       return newObj;
     }


[03/15] tinkerpop git commit: Abstracted transport out of the authenticator class. Added authenticator and sasl implmentation to global export. Added more testing of the sasl authenticator implementation.

Posted by jo...@apache.org.
Abstracted transport out of the authenticator class.
Added authenticator and sasl implmentation to global export.
Added more testing of the sasl authenticator implementation.


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

Branch: refs/heads/tp32
Commit: 6f65b92e7ac92cf4da105d9fef71ac51c6121013
Parents: c8ae3c8
Author: Matthew Allen <ma...@runbox.com>
Authored: Mon Jul 9 22:49:41 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:36:58 2018 +0100

----------------------------------------------------------------------
 .../main/javascript/gremlin-javascript/index.js |  6 ++++-
 .../lib/driver/authenticator.js                 |  4 +--
 .../lib/driver/driver-remote-connection.js      | 17 +++++++-----
 .../lib/driver/remote-connection.js             |  4 ++-
 .../lib/driver/sasl-authenticator.js            | 27 +++++---------------
 .../integration/sasl-authentication-tests.js    | 10 +++++++-
 6 files changed, 36 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6f65b92e/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index d4c6d88..5ada391 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -31,13 +31,17 @@ const rc = require('./lib/driver/remote-connection');
 const Bytecode = require('./lib/process/bytecode');
 const utils = require('./lib/utils');
 const DriverRemoteConnection = require('./lib/driver/driver-remote-connection');
+const Auth = require('./lib/driver/authenticator');
+const SaslAuth = require('./lib/driver/sasl-authenticator');
 
 module.exports = {
   driver: {
     RemoteConnection: rc.RemoteConnection,
     RemoteStrategy: rc.RemoteStrategy,
     RemoteTraversal: rc.RemoteTraversal,
-    DriverRemoteConnection: DriverRemoteConnection
+    DriverRemoteConnection: DriverRemoteConnection,
+    Authenticator: Auth,
+    SaslAuthenticator: SaslAuth
   },
   process: {
     Bytecode: Bytecode,

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6f65b92e/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
index 053aecd..fe83077 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/authenticator.js
@@ -6,9 +6,9 @@ class Authenticator {
     this._credentials = credentials;
   }
   
-  evaluateChallenge(ws, header) {
+  async evaluateChallenge(challenge) {
     throw new Error("evaluateChallenge should be implemented");
   }
 }
 
-module.exports = Authenticator;
\ No newline at end of file
+module.exports = Authenticator;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6f65b92e/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 0f46745..facc0b8 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
@@ -105,24 +105,24 @@ class DriverRemoteConnection extends RemoteConnection {
   }
 
   /** @override */
-  submit(bytecode) {
+  submit(bytecode, op, args) {
     return this.open().then(() => new Promise((resolve, reject) => {
       const requestId = utils.getUuid();
       this._responseHandlers[requestId] = {
         callback: (err, result) => err ? reject(err) : resolve(result),
         result: null
       };
-      const message = bufferFromString(this._header + JSON.stringify(this._getRequest(requestId, bytecode)));
+      const message = bufferFromString(this._header + JSON.stringify(this._getRequest(requestId, bytecode, op, args)));
       this._ws.send(message);
     }));
   }
 
-  _getRequest(id, bytecode) {
+  _getRequest(id, bytecode, op, args) {
     return ({
       'requestId': { '@type': 'g:UUID', '@value': id },
-      'op': 'bytecode',
+      'op': op || 'bytecode',
       'processor': 'traversal',
-      'args': {
+      'args': args || {
         'gremlin': this._writer.adaptObject(bytecode),
         'aliases': { 'g': this.traversalSource }
       }
@@ -157,7 +157,12 @@ class DriverRemoteConnection extends RemoteConnection {
     }
 
     if (response.status.code === responseStatusCode.authenticationChallenge && this._authenticator) {
-       this._authenticator.evaluateChallenge(this._ws, this._header);
+      this._authenticator.evaluateChallenge(response).then(res => {
+        this.submit('', 'authentication', res);
+      }, err => {
+        return handler.callback(err);
+      });
+       
        return;
     }
     else if (response.status.code >= 400) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6f65b92e/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 2672ff4..46918df 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -33,9 +33,11 @@ class RemoteConnection {
   /**
    * @abstract
    * @param {Bytecode} bytecode
+   * @param {String} op Operation to perform, defaults to bytecode.
+   * @param {Object} args The arguments for the operation. Defaults to
    * @returns {Promise}
    */
-  submit(bytecode) {
+  submit(bytecode, op, args) {
     throw new Error('submit() was not implemented');
   };
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6f65b92e/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
index 1f08b7d..d7db3de 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/sasl-authenticator.js
@@ -1,7 +1,6 @@
 'use strict';
 
 const Authenticator = require('./authenticator');
-const utils = require('../utils');
 
 class SaslAuthenticator extends Authenticator {
   /**
@@ -15,31 +14,17 @@ class SaslAuthenticator extends Authenticator {
     super(credentials);
   }
   
-  evaluateChallenge(ws, header) {
-    const message = bufferFromString(header + JSON.stringify({
-      'requestId': { '@type': 'g:UUID', '@value': utils.getUuid() },
-      'op': 'authentication',
-      'processor': 'traversal',
-      'args': {
-        'sasl': this.saslArgument()
-      }
-    }));
-    
-    return ws.send(message);
+  async evaluateChallenge(challenge) {
+    return Promise.resolve({ 'sasl': this.saslArgument() });
   }
 
   saslArgument() {
-    if (this._credentials.username === null || this._credentials.username.length === 0 
-      || this._credentials.password === null || this._credentials.password.length === 0 ) {
-      return '';
+    if (typeof this._credentials.username === "undefined" || this._credentials.username.length === 0 
+      || typeof this._credentials.password === "undefined" || this._credentials.password.length === 0 ) {
+        throw new Error('No Credentials Supplied');
     }
     return new Buffer(`\0${this._credentials.username}\0${this._credentials.password}`).toString('base64');
   }
 }
 
-
-const bufferFromString = (Int8Array.from !== Buffer.from && Buffer.from) || function newBuffer(text) {
-  return new Buffer(text, 'utf8');
-};
-
-module.exports = SaslAuthenticator;
\ No newline at end of file
+module.exports = SaslAuthenticator;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6f65b92e/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
index c5dc48f..d517d22 100644
--- 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
@@ -55,5 +55,13 @@ describe('DriverRemoteConnectionWithSaslAuthenticator', function () {
           assert.ok(err.message.indexOf('401') > 0);
         });
     });
+    it('should send incorrect conifugration to the authenticator and parse the response error', function () {
+      delete connection._authenticator.username;
+      delete connection._authenticator.password;
+      return connection.submit(new Bytecode().addStep('V', []).addStep('tail', []))
+        .catch(function (err) {
+          assert.ok(err);
+        });
+    });
   });
-});
\ No newline at end of file
+});


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

Posted by jo...@apache.org.
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/tp32
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


[14/15] tinkerpop git commit: TINKERPOP-1977 Fix license, typo and default serialization format

Posted by jo...@apache.org.
TINKERPOP-1977 Fix license, typo and default serialization format


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

Branch: refs/heads/tp32
Commit: e61fcf1c639ee02482f339c691cdbcabe281bc72
Parents: a561ee0
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Aug 23 10:16:17 2018 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Thu Aug 23 10:16:17 2018 +0200

----------------------------------------------------------------------
 docs/src/reference/gremlin-variants.asciidoc     |  7 +++----
 .../main/javascript/gremlin-javascript/index.js  |  2 ++
 .../lib/driver/auth/authenticator.js             | 19 +++++++++++++++++++
 .../driver/auth/plain-text-sasl-authenticator.js |  2 ++
 .../lib/driver/auth/sasl-authenticator.js        | 19 +++++++++++++++++++
 .../lib/driver/driver-remote-connection.js       |  2 +-
 6 files changed, 46 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e61fcf1c/docs/src/reference/gremlin-variants.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-variants.asciidoc b/docs/src/reference/gremlin-variants.asciidoc
index 290b39b..5122136 100644
--- a/docs/src/reference/gremlin-variants.asciidoc
+++ b/docs/src/reference/gremlin-variants.asciidoc
@@ -484,13 +484,12 @@ const graph = new Graph();
 const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
 ----
 
-or for Gremlin Servers requiring SASL authentication
+Gremlin-JavaScript supports plain text SASL authentication, you can set it on the connection options.
 
 [source,javascript]
 ----
-const graph = new Graph();
-const Authenicator = gremlin.driver.auth.PlainTextSaslAuthenicator;
-const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', { authenticator: new Authenticator(username, password, optionalAuthzid) });
+const authenticator = new gremlin.driver.auth.PlainTextSaslAuthenticator('myuser', 'mypassword');
+const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', { authenticator });
 ----
 
 When a traversal from the `GraphTraversalSource` is iterated, the traversal’s `Bytecode` is sent over the wire via

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e61fcf1c/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
index 9cc6349..c2e810d 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/index.js
@@ -31,6 +31,7 @@ const rc = require('./lib/driver/remote-connection');
 const Bytecode = require('./lib/process/bytecode');
 const utils = require('./lib/utils');
 const DriverRemoteConnection = require('./lib/driver/driver-remote-connection');
+const Authenticator = require('./lib/driver/auth/authenticator');
 const PlainTextSaslAuthenticator = require('./lib/driver/auth/plain-text-sasl-authenticator');
 
 module.exports = {
@@ -40,6 +41,7 @@ module.exports = {
     RemoteTraversal: rc.RemoteTraversal,
     DriverRemoteConnection: DriverRemoteConnection,
     auth: {
+      Authenticator: Authenticator,
       PlainTextSaslAuthenticator: PlainTextSaslAuthenticator
     }
   },

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e61fcf1c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js
index b57e385..6b9b1c7 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/authenticator.js
@@ -1,3 +1,22 @@
+/*
+ *  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.
+ */
+
 'use strict';
 
 /** @abstract */

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e61fcf1c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js
index b8f104d..72c73ba 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/plain-text-sasl-authenticator.js
@@ -16,6 +16,7 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
+
 'use strict';
 
 const Authenticator = require('./authenticator');
@@ -26,6 +27,7 @@ class PlainTextSaslAuthenticator extends Authenticator {
    * Creates a new instance of PlainTextSaslAuthenticator.
    * @param {string} username Username to log into the server.
    * @param {string} password Password for the user.
+   * @param {string} [authzid] Optional id
    * @constructor
    */
   constructor(username, password, authzid) {

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e61fcf1c/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
index cdf56e1..e93a7af 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/auth/sasl-authenticator.js
@@ -1,3 +1,22 @@
+/*
+ *  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.
+ */
+
 'use strict';
 
 const Authenticator = require('./authenticator');

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e61fcf1c/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 04deee7..15836ba 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-v3.0+json';
+const defaultMimeType = 'application/vnd.gremlin-v2.0+json';
 
 class DriverRemoteConnection extends RemoteConnection {
   /**


[05/15] tinkerpop git commit: Submit can accept an existing requestId. Args supplied to _getRequest are run through the GraphSONWriter. Improved promise error handling on authenticator challenge. Tidying up of code formatting and documentation. Integrati

Posted by jo...@apache.org.
Submit can accept an existing requestId.
Args supplied to _getRequest are run through the GraphSONWriter.
Improved promise error handling on authenticator challenge.
Tidying up of code formatting and documentation.
Integration test updated to use secure gremlin server port.


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

Branch: refs/heads/tp32
Commit: f67fea49da3ca788f39c3824c3398f1a7aae65f0
Parents: 0e05499
Author: Matthew Allen <ma...@runbox.com>
Authored: Wed Jul 11 21:38:56 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:37:55 2018 +0100

----------------------------------------------------------------------
 .../lib/driver/driver-remote-connection.js      | 50 +++++++++++++++-----
 .../lib/driver/remote-connection.js             |  5 +-
 .../gremlin-javascript/test/helper.js           |  8 ++++
 3 files changed, 49 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f67fea49/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 facc0b8..bec599b 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
@@ -105,19 +105,25 @@ class DriverRemoteConnection extends RemoteConnection {
   }
 
   /** @override */
-  submit(bytecode, op, args) {
+  submit(bytecode, op, args, requestId) {
     return this.open().then(() => new Promise((resolve, reject) => {
-      const requestId = utils.getUuid();
-      this._responseHandlers[requestId] = {
-        callback: (err, result) => err ? reject(err) : resolve(result),
-        result: null
-      };
+      if (requestId === null || requestId === undefined) {
+        requestId = utils.getUuid();
+        this._responseHandlers[requestId] = {
+          callback: (err, result) => err ? reject(err) : resolve(result),
+          result: null
+        };
+      }
       const message = bufferFromString(this._header + JSON.stringify(this._getRequest(requestId, bytecode, op, args)));
       this._ws.send(message);
     }));
   }
 
   _getRequest(id, bytecode, op, args) {
+    if (args) {
+      args = this._adaptArgs(args);
+    }
+
     return ({
       'requestId': { '@type': 'g:UUID', '@value': id },
       'op': op || 'bytecode',
@@ -158,12 +164,10 @@ class DriverRemoteConnection extends RemoteConnection {
 
     if (response.status.code === responseStatusCode.authenticationChallenge && this._authenticator) {
       this._authenticator.evaluateChallenge(response).then(res => {
-        this.submit('', 'authentication', res);
-      }, err => {
-        return handler.callback(err);
-      });
-       
-       return;
+        return this.submit(null, 'authentication', res, response.requestId);
+      }).catch(handler.callback);
+
+      return;
     }
     else if (response.status.code >= 400) {
       // callback in error
@@ -200,6 +204,28 @@ class DriverRemoteConnection extends RemoteConnection {
   }
 
   /**
+   * Takes the given args map and ensures all arguments are passed through to _write.adaptObject
+   * @param {Object} args Map of arguments to process
+   * @returns {Object}
+   * @private
+   */
+  _adaptArgs(args) {
+    if (Array.isArray(args)) {
+      return args.map(val => this._adaptArgs(val));
+    }
+
+    if (args instanceof Object) {
+      let newObj = {};
+      Object.keys(args).forEach((key, val) => {
+        newObj[key] = this._adaptArgs(val);
+      });
+      return newObj;
+    }
+    
+    return this._writer.adaptObject(args);
+  }
+
+  /**
    * Closes the Connection.
    * @return {Promise}
    */

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f67fea49/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
index 46918df..be6f962 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/remote-connection.js
@@ -34,10 +34,11 @@ class RemoteConnection {
    * @abstract
    * @param {Bytecode} bytecode
    * @param {String} op Operation to perform, defaults to bytecode.
-   * @param {Object} args The arguments for the operation. Defaults to
+   * @param {Object} args The arguments for the operation. Defaults to an associative array containing values for "aliases" and "gremlin" keyss.
+   * @param {String} requestId A requestId for the current request. If none provided then a requestId is generated internally.
    * @returns {Promise}
    */
-  submit(bytecode, op, args) {
+  submit(bytecode, op, args, requestId) {
     throw new Error('submit() was not implemented');
   };
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f67fea49/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
index 546840e..99fea7f 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -26,4 +26,12 @@ const DriverRemoteConnection = require('../lib/driver/driver-remote-connection')
 
 exports.getConnection = function getConnection(traversalSource) {
   return new DriverRemoteConnection('ws://localhost:45940/gremlin', { traversalSource: traversalSource });
+<<<<<<< HEAD
+=======
+};
+
+exports.getSecureConnectionWithAuthenticator = function getConnection(traversalSource) {
+  const authenticator = new SaslAuthenticator({ username: 'stephen', password: 'password' });
+  return new DriverRemoteConnection('wss://localhost:45941/gremlin', { traversalSource: traversalSource, authenticator: authenticator, rejectUnauthorized: false });
+>>>>>>> 65de11c3c8... Submit can accept an existing requestId.
 };
\ No newline at end of file


[10/15] tinkerpop git commit: Fix for integration test Gremlin Server connection.

Posted by jo...@apache.org.
Fix for integration test Gremlin Server connection.


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

Branch: refs/heads/tp32
Commit: 8453b61cfd398fe53387439056315304bc22ea4f
Parents: 7a5cb9c
Author: Matthew Allen <ma...@runbox.com>
Authored: Sun Jul 29 16:02:12 2018 +0100
Committer: Matthew Allen <ma...@runbox.com>
Committed: Thu Aug 23 06:39:29 2018 +0100

----------------------------------------------------------------------
 .../src/main/javascript/gremlin-javascript/test/helper.js          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8453b61c/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
index 25e9557..e1c24a3 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/test/helper.js
@@ -33,7 +33,7 @@ exports.getConnection = function getConnection(traversalSource) {
 
 exports.getSecureConnectionWithAuthenticator = function getConnection(traversalSource) {
   const authenticator = new SaslAuthenticator({ mechanism: new SaslMechanismPlain(), username: 'stephen', password: 'password', authId: os.hostname() });
-  return new DriverRemoteConnection('wss://localhost:45941/gremlin', { 
+  return new DriverRemoteConnection('ws://localhost:45941/gremlin', { 
     traversalSource: traversalSource, 
     authenticator: authenticator, 
     rejectUnauthorized: false