diff --git a/lib/adapter.js b/lib/adapter.js index febfecf..d8f20ee 100644 --- a/lib/adapter.js +++ b/lib/adapter.js @@ -114,6 +114,9 @@ module.exports = (function() { // // Sets the oriento logger for error, log and debug. e.g.: { debug: console.log.bind(console) } orientoLogger : {}, + + // Enable JTW Token in orientjs. http://orientdb.com/docs/2.1/Network-Binary-Protocol.html#token + useToken : false, // // database username, by default uses connection username set on config // databaseUser : null, diff --git a/lib/connection.js b/lib/connection.js index 803191a..df68fd8 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -567,7 +567,7 @@ Connection.prototype._getOriento = function _getOriento(config) { password : config.password, transport : config.options.transport, enableRIDBags : false, - useToken : false, + useToken : config.options.useToken || false, logger : config.options.orientoLogger }; diff --git a/test/integration-orientdb/tests/config/options.test..js b/test/integration-orientdb/tests/config/options.test..js index ee9f504..3b73d44 100644 --- a/test/integration-orientdb/tests/config/options.test..js +++ b/test/integration-orientdb/tests/config/options.test..js @@ -40,9 +40,9 @@ describe('Config tests', function() { describe('pool', function() { - ///////////////////////////////////////////////////// - // TEST SETUP - //////////////////////////////////////////////////// + ///////////////////////////////////////////////////// + // TEST SETUP + //////////////////////////////////////////////////// before(function (done) { // db created, let's close the connection so we can test logins @@ -91,5 +91,62 @@ describe('Config tests', function() { }); }); + + + describe('useToken', function() { + + ///////////////////////////////////////////////////// + // TEST SETUP + //////////////////////////////////////////////////// + + before(function (done) { + // db created, let's close the connection so we can test logins + self.waterline.teardown(done); + }); + + after(function (done) { + // let's log off last user because it may not have privileges to drop the db later on + self.waterline.teardown(function (err) { + if (err) {  return done(err); } + // and now we logon with original config + CREATE_TEST_WATERLINE(self, config, fixtures, done); + }); + }); + + ///////////////////////////////////////////////////// + // TEST METHODS + //////////////////////////////////////////////////// + + it('should be false', function (done) { + CREATE_TEST_WATERLINE(self, config, fixtures, function (err) { + if (err) {  return done(err); } + var server = self.collections.User.getServer(); + assert.equal(server.transport.useToken, false); + done(); + }); + }); + + it('should be true', function (done) { + self.waterline.teardown(function (err) { + if (err) {  return done(err); } + + var newConfig = _.cloneDeep(config); + + newConfig.options = { + useToken: true + }; + + CREATE_TEST_WATERLINE(self, newConfig, fixtures, function (err) { + if (err) {  return done(err); } + var server = self.collections.User.getServer(); + assert.equal(server.transport.useToken, true); + done(); + }); + }); + }); + + }); + + }); });