Skip to content

Commit

Permalink
Merge pull request #151 from appscot/jwt
Browse files Browse the repository at this point in the history
OrientJS JWT config useToken + docs + test
  • Loading branch information
dmarcelino authored Jul 7, 2016
2 parents 4c2da6c + a3e3849 commit 804d89a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
63 changes: 60 additions & 3 deletions test/integration-orientdb/tests/config/options.test..js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
});
});
});

});


});
});

0 comments on commit 804d89a

Please sign in to comment.