diff --git a/src/test/database-test.js b/src/test/database-test.js index f87805e3b..ad142612a 100644 --- a/src/test/database-test.js +++ b/src/test/database-test.js @@ -820,17 +820,6 @@ describe('database', function () { }); }); - it('delByIdentifier succeeds', function (done) { - tokendb.add(TOKEN_1, function (error) { - expect(error).to.be(null); - - tokendb.delByIdentifier(TOKEN_1.identifier, function (error) { - expect(error).to.be(null); - done(); - }); - }); - }); - it('cannot delete previously delete record', function (done) { tokendb.del(TOKEN_0.id, function (error) { expect(error).to.be.a(BoxError); @@ -839,20 +828,6 @@ describe('database', function () { }); }); - it('getByIdentifierAndClientId succeeds', function (done) { - tokendb.add(TOKEN_0, function (error) { - expect(error).to.be(null); - - tokendb.getByIdentifierAndClientId(TOKEN_0.identifier, TOKEN_0.clientId, function (error, result) { - expect(error).to.be(null); - expect(result).to.be.an(Array); - expect(result.length).to.equal(1); - expect(result[0]).to.eql(TOKEN_0); - done(); - }); - }); - }); - it('delExpired succeeds', function (done) { tokendb.add(TOKEN_2, function (error) { expect(error).to.be(null); @@ -870,36 +845,6 @@ describe('database', function () { }); }); }); - - it('delByIdentifierAndClientId succeeds', function (done) { - tokendb.delByIdentifierAndClientId(TOKEN_0.identifier, TOKEN_0.clientId, function (error) { - expect(error).to.be(null); - - tokendb.getByAccessToken(TOKEN_0.accessToken, function (error, result) { - expect(error).to.be.a(BoxError); - expect(error.reason).to.be(BoxError.NOT_FOUND); - expect(result).to.not.be.ok(); - done(); - }); - }); - }); - - it('delByClientId succeeds', function (done) { - tokendb.add(TOKEN_0, function (error) { - expect(error).to.be(null); - - tokendb.delByClientId(TOKEN_0.clientId, function (error) { - expect(error).to.not.be.ok(); - - tokendb.getByAccessToken(TOKEN_0.accessToken, function (error, result) { - expect(error).to.be.a(BoxError); - expect(error.reason).to.be(BoxError.NOT_FOUND); - expect(result).to.not.be.ok(); - done(); - }); - }); - }); - }); }); describe('apps', function () { diff --git a/src/tokendb.js b/src/tokendb.js index 164b3240b..75fc7fe1a 100644 --- a/src/tokendb.js +++ b/src/tokendb.js @@ -8,11 +8,7 @@ exports = module.exports = { delByAccessToken: delByAccessToken, add: add, del: del, - delByClientId: delByClientId, getByIdentifier: getByIdentifier, - delByIdentifier: delByIdentifier, - getByIdentifierAndClientId: getByIdentifierAndClientId, - delByIdentifierAndClientId: delByIdentifierAndClientId, delExpired: delExpired, _clear: clear @@ -95,18 +91,6 @@ function del(id, callback) { }); } -function delByClientId(clientId, callback) { - assert.strictEqual(typeof clientId, 'string'); - assert.strictEqual(typeof callback, 'function'); - - database.query('DELETE FROM tokens WHERE clientId = ?', [ clientId ], function (error, result) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - if (result.affectedRows !== 1) return callback(new BoxError(BoxError.NOT_FOUND, 'Token not found')); - - return callback(null); - }); -} - function getByIdentifier(identifier, callback) { assert.strictEqual(typeof identifier, 'string'); assert.strictEqual(typeof callback, 'function'); @@ -118,44 +102,6 @@ function getByIdentifier(identifier, callback) { }); } -function delByIdentifier(identifier, callback) { - assert.strictEqual(typeof identifier, 'string'); - assert.strictEqual(typeof callback, 'function'); - - database.query('DELETE FROM tokens WHERE identifier = ?', [ identifier ], function (error, result) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - if (result.affectedRows !== 1) return callback(new BoxError(BoxError.NOT_FOUND, 'Token not found')); - - return callback(null); - }); -} - -function getByIdentifierAndClientId(identifier, clientId, callback) { - assert.strictEqual(typeof identifier, 'string'); - assert.strictEqual(typeof clientId, 'string'); - assert.strictEqual(typeof callback, 'function'); - - database.query('SELECT ' + TOKENS_FIELDS + ' FROM tokens WHERE identifier=? AND clientId=?', [ identifier, clientId ], function (error, results) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - if (results.length === 0) return callback(new BoxError(BoxError.NOT_FOUND, 'Token not found')); - - callback(null, results); - }); -} - -function delByIdentifierAndClientId(identifier, clientId, callback) { - assert.strictEqual(typeof identifier, 'string'); - assert.strictEqual(typeof clientId, 'string'); - assert.strictEqual(typeof callback, 'function'); - - database.query('DELETE FROM tokens WHERE identifier = ? AND clientId = ?', [ identifier, clientId ], function (error, result) { - if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error)); - if (result.affectedRows !== 1) return callback(new BoxError(BoxError.NOT_FOUND, 'Token not found')); - - return callback(null); - }); -} - function delExpired(callback) { assert.strictEqual(typeof callback, 'function');