From fd87c439fad2cc97a2c97c4c8413c2c853375620 Mon Sep 17 00:00:00 2001 From: Robin Orheden Date: Tue, 27 Oct 2015 17:12:06 +0100 Subject: [PATCH] refactor options.apiKey to options.client.apiKey --- lib/authc/OAuthBasicExchangeAuthenticator.js | 7 ++-- lib/authc/OauthAccessTokenAuthenticator.js | 6 ++-- lib/jwt/jwt-authentication-result.js | 9 ++--- lib/jwt/jwt-authenticator.js | 2 +- lib/resource/ApiKey.js | 3 +- lib/resource/Application.js | 6 ++-- lib/resource/AuthenticationResult.js | 2 +- test/it/api_auth_it.js | 6 ++-- test/it/client_credential_auth_it.js | 2 +- test/it/jwt_authenticator_it.js | 2 +- test/it/oauth_authenticator_it.js | 2 +- test/sp.ds.datastore_test.js | 34 +++++++++++++------ test/sp.ds.requestExecutor_test.js | 6 ++-- test/sp.resource.accountStoreMapping_test.js | 4 +-- test/sp.resource.account_test.js | 12 ++++--- test/sp.resource.application_test.js | 23 ++++++++----- test/sp.resource.authenticationResult_test.js | 2 +- test/sp.resource.collectionResource_test.js | 10 +++--- test/sp.resource.customData_test.js | 8 ++--- ...sp.resource.directoryChildResource_test.js | 2 +- test/sp.resource.directory_test.js | 2 +- test/sp.resource.groupMembership_test.js | 2 +- test/sp.resource.group_test.js | 2 +- test/sp.resource.instanceResource_test.js | 4 +-- test/sp.resource.resource_test.js | 6 ++-- test/sp.resource.tenant_test.js | 2 +- 26 files changed, 96 insertions(+), 70 deletions(-) diff --git a/lib/authc/OAuthBasicExchangeAuthenticator.js b/lib/authc/OAuthBasicExchangeAuthenticator.js index 0b2ac047..6b89e615 100644 --- a/lib/authc/OAuthBasicExchangeAuthenticator.js +++ b/lib/authc/OAuthBasicExchangeAuthenticator.js @@ -67,20 +67,23 @@ OAuthBasicExchangeAuthenticator.prototype.buildTokenResponse = function buildTok OAuthBasicExchangeAuthenticator.prototype.buildAccesstoken = function buildAccesstoken(account) { var self = this; - var now = nowEpochSeconds(); + var _jwt = { sub: self.id, iss: self.application.href, iat: now, exp: now + self.ttl }; + var scope = self.scopeFactory(account,self.requestedScope); + if(scope){ // TODO v1.0.0 - remove string option, should be array only _jwt.scope = Array.isArray(scope) ? scope.join(' ') : scope; } - return self._token = jwt.encode(_jwt,self.application.dataStore.requestExecutor.options.apiKey.secret,'HS256'); + + return self._token = jwt.encode(_jwt, self.application.dataStore.requestExecutor.options.client.apiKey.secret, 'HS256'); }; module.exports = OAuthBasicExchangeAuthenticator; diff --git a/lib/authc/OauthAccessTokenAuthenticator.js b/lib/authc/OauthAccessTokenAuthenticator.js index 5312910a..e8ce5a45 100644 --- a/lib/authc/OauthAccessTokenAuthenticator.js +++ b/lib/authc/OauthAccessTokenAuthenticator.js @@ -8,7 +8,7 @@ var utils = require('../utils'); var nowEpochSeconds = utils.nowEpochSeconds; -function getJwt(token,secret){ +function getJwt(token, secret){ var jwtObject; try{ jwtObject = jwt.decode(token, secret); @@ -36,8 +36,8 @@ function validateJwt(jwtObject){ } -function OauthAccessTokenAuthenticator(application,token){ - var jwtObject = getJwt(token,application.dataStore.requestExecutor.options.apiKey.secret); +function OauthAccessTokenAuthenticator(application, token){ + var jwtObject = getJwt(token, application.dataStore.requestExecutor.options.client.apiKey.secret); if(jwtObject instanceof Error){ return jwtObject; diff --git a/lib/jwt/jwt-authentication-result.js b/lib/jwt/jwt-authentication-result.js index 2971ef52..6757ba0c 100644 --- a/lib/jwt/jwt-authentication-result.js +++ b/lib/jwt/jwt-authentication-result.js @@ -6,7 +6,6 @@ function JwtAuthenticationResult(application,data) { if (!(this instanceof JwtAuthenticationResult)) { return new JwtAuthenticationResult(application,data); }else{ - /* Take all the properties of the data response, and put them on this object - but convert underscores to camelcase cuz @@ -25,16 +24,18 @@ function JwtAuthenticationResult(application,data) { */ this.application = application; + var apiKey = application.dataStore.requestExecutor.options.client.apiKey; if(this.accessToken){ - this.accessToken = nJwt.verify(this.accessToken,application.dataStore.requestExecutor.options.apiKey.secret); + this.accessToken = nJwt.verify(this.accessToken, apiKey.secret); this.account = { href: this.accessToken.body.sub }; } if(this.refreshToken){ - this.refreshToken = nJwt.verify(this.refreshToken,application.dataStore.requestExecutor.options.apiKey.secret); + this.refreshToken = nJwt.verify(this.refreshToken, apiKey.secret); } + return this; } } @@ -50,4 +51,4 @@ JwtAuthenticationResult.prototype.getAccount = function getAccount(callback) { this.application.dataStore.getResource(this.account.href, require('../resource/Account'), callback); }; -module.exports = JwtAuthenticationResult; \ No newline at end of file +module.exports = JwtAuthenticationResult; diff --git a/lib/jwt/jwt-authenticator.js b/lib/jwt/jwt-authenticator.js index 3c20ffcb..bae55b7c 100644 --- a/lib/jwt/jwt-authenticator.js +++ b/lib/jwt/jwt-authenticator.js @@ -35,7 +35,7 @@ JwtAuthenticator.prototype.unauthenticated = function unauthenticated(){ JwtAuthenticator.prototype.authenticate = function authenticate(token,cb){ var self = this; - var secret = self.application.dataStore.requestExecutor.options.apiKey.secret; + var secret = self.application.dataStore.requestExecutor.options.client.apiKey.secret; njwt.verify(token,secret,function(err,jwt){ if(err){ diff --git a/lib/resource/ApiKey.js b/lib/resource/ApiKey.js index 3390f4c1..52c1d38d 100644 --- a/lib/resource/ApiKey.js +++ b/lib/resource/ApiKey.js @@ -15,7 +15,7 @@ ApiKey.prototype._getDecryptedSecret = function _getDecryptedSecret(callback) { var salt = self.apiKeyMetaData.encryptionKeySalt; var iterations = self.apiKeyMetaData.encryptionKeyIterations; var keyLengthBits = self.apiKeyMetaData.encryptionKeySize; - var password = new Buffer(self.dataStore.requestExecutor.options.apiKey.secret); + var password = new Buffer(self.dataStore.requestExecutor.options.client.apiKey.secret); var encryptedSecret = new Buffer(self.secret,'base64'); var iv = encryptedSecret.slice(0,16); var rawEncryptedValue = encryptedSecret.slice(16); @@ -34,7 +34,6 @@ ApiKey.prototype._getDecryptedSecret = function _getDecryptedSecret(callback) { } callback(null,decrypted); }); - }; ApiKey.prototype._setApiKeyMetaData = function _setApiKeyMetaData(obj){ diff --git a/lib/resource/Application.js b/lib/resource/Application.js index 9d65839d..f86e50a2 100644 --- a/lib/resource/Application.js +++ b/lib/resource/Application.js @@ -28,7 +28,7 @@ Application.prototype.createIdSiteUrl = function createIdSiteUrl(_options) { var options = typeof _options === "object" ? _options : {}; var p = url.parse(self.href); var base = p.protocol + '//' + p.host; - var apiKey = self.dataStore.requestExecutor.options.apiKey; + var apiKey = self.dataStore.requestExecutor.options.client.apiKey; var nonce = uuid(); var state = options.state || ''; @@ -87,8 +87,8 @@ Application.prototype.handleIdSiteCallback = function handleIdSiteCallback(respo var params = (url.parse(responseUri,true).query) || {}; var token = params.jwtResponse || ''; - var secret = self.dataStore.requestExecutor.options.apiKey.secret; - var apiKeyId = self.dataStore.requestExecutor.options.apiKey.id; + var secret = self.dataStore.requestExecutor.options.client.apiKey.secret; + var apiKeyId = self.dataStore.requestExecutor.options.client.apiKey.id; var responseJwt = self._decodeJwt(token,secret); diff --git a/lib/resource/AuthenticationResult.js b/lib/resource/AuthenticationResult.js index 8548f72f..6b99dc90 100644 --- a/lib/resource/AuthenticationResult.js +++ b/lib/resource/AuthenticationResult.js @@ -27,7 +27,7 @@ AuthenticationResult.prototype.getJwt = function getJwt() { iss: self.application.href, sub: self.forApiKey ? self.forApiKey.id : self.account.href, jti: utils.uuid() - },self.application.dataStore.requestExecutor.options.apiKey.secret) + },self.application.dataStore.requestExecutor.options.client.apiKey.secret) .setExpiration(new Date().getTime() + (3600*1000)); }; diff --git a/test/it/api_auth_it.js b/test/it/api_auth_it.js index cbcd9800..ff78faac 100644 --- a/test/it/api_auth_it.js +++ b/test/it/api_auth_it.js @@ -305,7 +305,7 @@ describe('Application.authenticateApiRequest',function(){ before(function(done){ var decodedJwt = nJwt.verify(accessToken, - client._dataStore.requestExecutor.options.apiKey.secret,'HS256'); + client._dataStore.requestExecutor.options.client.apiKey.secret,'HS256'); decodedJwt.body.scope += ' things-i-cant-have'; var tamperedToken = nJwt.create(decodedJwt.body,'not the same key','HS256').compact(); var requestObject = { @@ -569,7 +569,7 @@ describe('Application.authenticateApiRequest',function(){ },function(err,value){ result = [err,value]; decodedAccessToken = nJwt.verify(result[1].tokenResponse.access_token, - client._dataStore.requestExecutor.options.apiKey.secret,'HS256'); + client._dataStore.requestExecutor.options.client.apiKey.secret,'HS256'); done(); }); }); @@ -620,7 +620,7 @@ describe('Application.authenticateApiRequest',function(){ result = [err,value]; tokenResponse = value.tokenResponse; decodedAccessToken = nJwt.verify(result[1].tokenResponse.access_token, - client._dataStore.requestExecutor.options.apiKey.secret,'HS256'); + client._dataStore.requestExecutor.options.client.apiKey.secret,'HS256'); done(); }); }); diff --git a/test/it/client_credential_auth_it.js b/test/it/client_credential_auth_it.js index 09d97bca..37249b40 100644 --- a/test/it/client_credential_auth_it.js +++ b/test/it/client_credential_auth_it.js @@ -59,7 +59,7 @@ describe('Client Credential Authentication',function(){ it('should return an access token',function(done){ assert.isString(accessToken); - var secret = client._dataStore.requestExecutor.options.apiKey.secret; + var secret = client._dataStore.requestExecutor.options.client.apiKey.secret; nJwt.verify(accessToken,secret,function(err,jwt){ if(err){ throw err; } // The subject should be the account diff --git a/test/it/jwt_authenticator_it.js b/test/it/jwt_authenticator_it.js index a165368f..a7fe7e62 100644 --- a/test/it/jwt_authenticator_it.js +++ b/test/it/jwt_authenticator_it.js @@ -51,7 +51,7 @@ describe('JwtAuthenticator',function(){ expiredToken = nJwt.create( {hello:'world'}, - application.dataStore.requestExecutor.options.apiKey.secret + application.dataStore.requestExecutor.options.client.apiKey.secret ).setExpiration(new Date().getTime()) .compact(); diff --git a/test/it/oauth_authenticator_it.js b/test/it/oauth_authenticator_it.js index 7c41b732..8733efb9 100644 --- a/test/it/oauth_authenticator_it.js +++ b/test/it/oauth_authenticator_it.js @@ -57,7 +57,7 @@ describe('OAuthAuthenticator',function(){ expiredToken = nJwt.create( {hello:'world'}, - application.dataStore.requestExecutor.options.apiKey.secret + application.dataStore.requestExecutor.options.client.apiKey.secret ).setExpiration(new Date().getTime()) .compact(); diff --git a/test/sp.ds.datastore_test.js b/test/sp.ds.datastore_test.js index ae6bb370..52a90c14 100644 --- a/test/sp.ds.datastore_test.js +++ b/test/sp.ds.datastore_test.js @@ -16,14 +16,14 @@ describe('ds:', function () { describe('when constructed', function () { describe('and request executor not provided in config', function () { - var ds = new DataStore({apiKey: {id: 1, secret: 2}}); + var ds = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); it('should create instance of default RequestExecutor', function () { ds.requestExecutor.should.be.an.instanceof(RequestExecutor); }); }); describe('and request executor was provided in config', function () { - var reqExec = new RequestExecutor({apiKey: {id: 1, secret: 2}}); + var reqExec = new RequestExecutor({client: {apiKey: {id: 1, secret: 2}}}); var ds = new DataStore({requestExecutor: reqExec}); it('should reuse provided request executor instance', function () { ds.requestExecutor.should.be.equal(reqExec); @@ -44,8 +44,12 @@ describe('ds:', function () { describe('getResource()', function () { var ds = new DataStore({ - cacheOptions: { store: 'memory' }, - apiKey: {id: 1, secret: 2} + cacheOptions: { + store: 'memory' + }, + client: { + apiKey: {id: 1, secret: 2} + } }); describe('without required params', function () { @@ -167,7 +171,9 @@ describe('ds:', function () { tti: 60 } }, - apiKey: {id: 1, secret: 2} + client: { + apiKey: {id: 1, secret: 2} + } }); var href = '/tenants/3' + random(); @@ -216,7 +222,9 @@ describe('ds:', function () { tti: 60 } }, - apiKey: {id: 1, secret: 2} + client: { + apiKey: {id: 1, secret: 2} + } }); var href = '/tenants/3' + random(); @@ -251,7 +259,9 @@ describe('ds:', function () { tti: 60 } }, - apiKey: {id: 1, secret: 2} + client: { + apiKey: {id: 1, secret: 2} + } }); var href = '/tenants/3' + random(); @@ -317,7 +327,9 @@ describe('ds:', function () { ttl: 60, tti: 60 }, - apiKey: {id: 1, secret: 2} + client: { + apiKey: {id: 1, secret: 2} + } }); var href = '/tenants/2' + random(); @@ -369,7 +381,9 @@ describe('ds:', function () { ttl: 60, tti: 60 }, - apiKey: {id: 1, secret: 2} + client: { + apiKey: {id: 1, secret: 2} + } }); var href = '/tenants/2' + random(); @@ -408,4 +422,4 @@ describe('ds:', function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/sp.ds.requestExecutor_test.js b/test/sp.ds.requestExecutor_test.js index c482e331..4cb0ff8b 100644 --- a/test/sp.ds.requestExecutor_test.js +++ b/test/sp.ds.requestExecutor_test.js @@ -25,12 +25,12 @@ describe('ds:', function () { }); }); describe('create with required options', function () { - var reqExec = new RequestExecutor({apiKey: apiKey}); + var reqExec = new RequestExecutor({client: {apiKey: apiKey}}); it('should instantiate request authenticator', function () { reqExec.requestAuthenticator.should.be.ok; }); it('should store options', function () { - reqExec.options.apiKey.should.be.equal(apiKey); + reqExec.options.client.apiKey.should.be.equal(apiKey); }); it('should set headers user agent as stormpath-sdk', function () { reqExec.options.headers['User-Agent'].should @@ -40,7 +40,7 @@ describe('ds:', function () { }); describe('call to execute', function () { - var reqExec = new RequestExecutor({apiKey: apiKey}); + var reqExec = new RequestExecutor({client: {apiKey: apiKey} }); function exec(req, cb) { return function () { diff --git a/test/sp.resource.accountStoreMapping_test.js b/test/sp.resource.accountStoreMapping_test.js index 27deaec9..2d0a03c8 100644 --- a/test/sp.resource.accountStoreMapping_test.js +++ b/test/sp.resource.accountStoreMapping_test.js @@ -13,7 +13,7 @@ var BASE_URL = u.BASE_URL; describe('Resources: ', function () { "use strict"; describe('Account Store Mapping resource', function () { - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); describe('get application', function () { var asm, appData, app, app2, accountStoreMapping; @@ -148,4 +148,4 @@ describe('Resources: ', function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/sp.resource.account_test.js b/test/sp.resource.account_test.js index fd9df820..52119244 100644 --- a/test/sp.resource.account_test.js +++ b/test/sp.resource.account_test.js @@ -19,10 +19,12 @@ describe('Resources: ', function () { "use strict"; describe('Account resource class', function () { var dataStore = new DataStore({ - apiKey: { - id: 1, - // this secret will decrypt the api keys correctly - secret: '6b2c3912-4779-49c1-81e7-23c204f43d2d' + client: { + apiKey: { + id: 1, + // this secret will decrypt the api keys correctly + secret: '6b2c3912-4779-49c1-81e7-23c204f43d2d' + } } }); @@ -463,4 +465,4 @@ describe('Resources: ', function () { }); -}); \ No newline at end of file +}); diff --git a/test/sp.resource.application_test.js b/test/sp.resource.application_test.js index cde92b13..de7baa7c 100644 --- a/test/sp.resource.application_test.js +++ b/test/sp.resource.application_test.js @@ -27,10 +27,12 @@ describe('Resources: ', function () { describe('Application resource', function () { var dataStore = new DataStore({ - apiKey: { - id: 1, - // this secret will decrypt the api keys correctly - secret: '6b2c3912-4779-49c1-81e7-23c204f43d2d' + client: { + apiKey: { + id: 1, + // this secret will decrypt the api keys correctly + secret: '6b2c3912-4779-49c1-81e7-23c204f43d2d' + } } }); describe('authenticate account', function () { @@ -38,7 +40,7 @@ describe('Resources: ', function () { describe('createIdSiteUrl', function () { var clientApiKeySecret = uuid(); - var dataStore = new DataStore({apiKey: {id: '1', secret: clientApiKeySecret}}); + var dataStore = new DataStore({client: {apiKey: {id: '1', secret: clientApiKeySecret}}}); var app = { href:'http://api.stormpath.com/v1/applications/' + uuid() }; @@ -74,7 +76,7 @@ describe('Resources: ', function () { describe('createIdSiteUrl with logout option', function () { var clientApiKeySecret = uuid(); - var dataStore = new DataStore({apiKey: {id: '1', secret: clientApiKeySecret}}); + var dataStore = new DataStore({client:{apiKey: {id: '1', secret: clientApiKeySecret}}}); var app = { href:'http://api.stormpath.com/v1/applications/' + uuid() }; @@ -114,7 +116,12 @@ describe('Resources: ', function () { self.clientApiKeySecret = uuid(); self.clientApiKeyId = uuid(); var dataStore = new DataStore({ - apiKey: {id: self.clientApiKeyId, secret: self.clientApiKeySecret} + client: { + apiKey: { + id: self.clientApiKeyId, + secret: self.clientApiKeySecret + } + } }); var app = {href:'http://api.stormpath.com/v1/applications/'+uuid()}; self.application = new Application(app, dataStore); @@ -1113,7 +1120,7 @@ describe('Resources: ', function () { describe('resend verification email', function () { var app, createResourceStub; var options = {login:uuid()}; - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); before(function (done) { app = new Application( diff --git a/test/sp.resource.authenticationResult_test.js b/test/sp.resource.authenticationResult_test.js index 98e3d468..543ad8a0 100644 --- a/test/sp.resource.authenticationResult_test.js +++ b/test/sp.resource.authenticationResult_test.js @@ -8,7 +8,7 @@ var DataStore = require('../lib/ds/DataStore'); describe('Resources: ', function () { "use strict"; describe('Authentication Result resource', function () { - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); describe('get accounts', function () { describe('if accounts not set', function () { //var authcResult = new AuthenticationResult(); diff --git a/test/sp.resource.collectionResource_test.js b/test/sp.resource.collectionResource_test.js index 4a23bbd4..1450d79c 100644 --- a/test/sp.resource.collectionResource_test.js +++ b/test/sp.resource.collectionResource_test.js @@ -69,7 +69,7 @@ describe('Resources: ', function () { }); describe('if items already converted', function () { - var ds = new DataStore({apiKey: apiKey}); + var ds = new DataStore({client: {apiKey: apiKey}}); var data = {items: [ new Tenant({href: ''}, ds), new Tenant({href: ''}, ds) @@ -168,7 +168,7 @@ describe('Resources: ', function () { describe('with items list', function () { var cr, sandbox, iteratorSpy, cbSpy, getResourceStub; - var ds = new DataStore({apiKey: apiKey}); + var ds = new DataStore({client: {apiKey: apiKey}}); var data = { offset: 0, items:[ @@ -210,7 +210,7 @@ describe('Resources: ', function () { describe('when all items in current page are processed', function () { var sandbox; var cr, iteratorSpy, getResourceStub; - var ds = new DataStore({apiKey: apiKey}); + var ds = new DataStore({client: {apiKey: apiKey}}); var query = {q: 'boom!'}; var data = { href: 'test_href', @@ -269,7 +269,7 @@ describe('Resources: ', function () { }); describe('async methods with pagination', function(){ - var ds = new DataStore({apiKey: {id:1, secret: 2}}); + var ds = new DataStore({client: {apiKey: {id:1, secret: 2}}}); function test(method){ return function(){ @@ -894,4 +894,4 @@ describe('Resources: ', function () { describe('concatSeries', test('concatSeries')); }); }); -}); \ No newline at end of file +}); diff --git a/test/sp.resource.customData_test.js b/test/sp.resource.customData_test.js index afb2dcfa..3e6d4e2e 100644 --- a/test/sp.resource.customData_test.js +++ b/test/sp.resource.customData_test.js @@ -22,7 +22,7 @@ describe('Resources: ', function () { before(function () { sandbox = sinon.sandbox.create(); // arrange - dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); fieldName = 'field_name_to_remove'; dcrJSON = { href: 'some_href', @@ -66,7 +66,7 @@ describe('Resources: ', function () { describe('when fetched via resource.getCustomData',function(){ var resource; - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); var sandbox = sinon.sandbox.create(); var cacheSpy = sinon.spy(dataStore.cacheHandler.cacheManager.caches.customData,'put'); var parentHref = 'http://api.stormpath.com/v1/accounts/' + common.uuid(); @@ -100,7 +100,7 @@ describe('Resources: ', function () { var resource, dataStore, saveResourceStub, sandbox; before(function(){ - dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); resource = instantiate(Account, { href: common.uuid(), customData:{ @@ -146,4 +146,4 @@ describe('Resources: ', function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/sp.resource.directoryChildResource_test.js b/test/sp.resource.directoryChildResource_test.js index 7a9bfeb2..694cdb7f 100644 --- a/test/sp.resource.directoryChildResource_test.js +++ b/test/sp.resource.directoryChildResource_test.js @@ -8,7 +8,7 @@ var DataStore = require('../lib/ds/DataStore'); describe('Resources: ', function () { describe('Directory Child resource', function () { - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); describe('get directory', function () { describe('if directory href not set', function () { diff --git a/test/sp.resource.directory_test.js b/test/sp.resource.directory_test.js index 16455aee..0b96f989 100644 --- a/test/sp.resource.directory_test.js +++ b/test/sp.resource.directory_test.js @@ -14,7 +14,7 @@ var DataStore = require('../lib/ds/DataStore'); describe('Resources: ', function () { describe('Directory resource', function () { - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); describe('get accounts', function () { describe('if accounts not set', function () { diff --git a/test/sp.resource.groupMembership_test.js b/test/sp.resource.groupMembership_test.js index 405f03ba..77ec0441 100644 --- a/test/sp.resource.groupMembership_test.js +++ b/test/sp.resource.groupMembership_test.js @@ -8,7 +8,7 @@ var DataStore = require('../lib/ds/DataStore'); describe('Resources: ', function () { describe('Group Membership resource', function () { - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); describe('get account', function () { describe('if group membership href not set', function () { diff --git a/test/sp.resource.group_test.js b/test/sp.resource.group_test.js index 47843f37..1dd79caa 100644 --- a/test/sp.resource.group_test.js +++ b/test/sp.resource.group_test.js @@ -12,7 +12,7 @@ var GroupMembership = require('../lib/resource/GroupMembership'); describe('Resources: ', function () { "use strict"; describe('Group resource', function () { - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); describe('add account', function () { describe('if group href not set', function () { diff --git a/test/sp.resource.instanceResource_test.js b/test/sp.resource.instanceResource_test.js index 49f986e6..6bcbf063 100644 --- a/test/sp.resource.instanceResource_test.js +++ b/test/sp.resource.instanceResource_test.js @@ -10,7 +10,7 @@ var DataStore = require('../lib/ds/DataStore'); describe('Resources: ', function () { describe('InstanceResource class', function(){ - var ds = new DataStore({apiKey:{id:1,secret:2}}); + var ds = new DataStore({client: {apiKey:{id:1,secret:2}}}); var app = {href: '/href'}; var instanceResource = new InstanceResource({ applications: app, @@ -194,4 +194,4 @@ describe('Resources: ', function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/sp.resource.resource_test.js b/test/sp.resource.resource_test.js index f3a2375e..3d90e0a8 100644 --- a/test/sp.resource.resource_test.js +++ b/test/sp.resource.resource_test.js @@ -13,7 +13,7 @@ describe('Resources: ', function () { var resource, ds; var obj = {data: 'boom!', data2: 'boom2!'}; before(function () { - ds = new DataStore({apiKey:apiKey}); + ds = new DataStore({client: {apiKey:apiKey}}); resource = new Resource(obj, ds); }); @@ -49,7 +49,7 @@ describe('Resources: ', function () { var resource, ds; var hack = 'boom!'; before(function () { - ds = new DataStore({apiKey:apiKey}); + ds = new DataStore({client: {apiKey:apiKey}}); ds.hack = hack; resource = new Resource(ds); @@ -65,4 +65,4 @@ describe('Resources: ', function () { }); }); }); -}); \ No newline at end of file +}); diff --git a/test/sp.resource.tenant_test.js b/test/sp.resource.tenant_test.js index b1d3a691..c1c4744a 100644 --- a/test/sp.resource.tenant_test.js +++ b/test/sp.resource.tenant_test.js @@ -11,7 +11,7 @@ var DataStore = require('../lib/ds/DataStore'); describe('Resources: ', function () { describe('Tenant resource class', function () { - var dataStore = new DataStore({apiKey: {id: 1, secret: 2}}); + var dataStore = new DataStore({client: {apiKey: {id: 1, secret: 2}}}); describe('get applications', function () { describe('if application not set', function () { //var tenant = new Tenant();