add type field to clients table

This commit is contained in:
Girish Ramakrishnan
2015-10-15 16:31:45 -07:00
parent d0dfe1ef7f
commit 9c157246b7
17 changed files with 151 additions and 78 deletions

View File

@@ -790,6 +790,7 @@ describe('database', function () {
var CLIENT_0 = {
id: 'cid-0',
appId: 'someappid_0',
type: clientdb.TYPE_OAUTH,
clientSecret: 'secret-0',
redirectURI: 'http://foo.bar',
scope: '*'
@@ -798,23 +799,17 @@ describe('database', function () {
var CLIENT_1 = {
id: 'cid-1',
appId: 'someappid_1',
type: clientdb.TYPE_OAUTH,
clientSecret: 'secret-',
redirectURI: 'http://foo.bar',
scope: '*'
};
var CLIENT_2 = {
id: 'cid-2',
appId: 'someappid_2',
clientSecret: 'secret-2',
redirectURI: 'http://foo.bar.baz',
scope: 'profile'
};
it('add succeeds', function (done) {
clientdb.add(CLIENT_0.id, CLIENT_0.appId, CLIENT_0.clientSecret, CLIENT_0.redirectURI, CLIENT_0.scope, function (error) {
clientdb.add(CLIENT_0.id, CLIENT_0.appId, CLIENT_0.type, CLIENT_0.clientSecret, CLIENT_0.redirectURI, CLIENT_0.scope, function (error) {
expect(error).to.be(null);
clientdb.add(CLIENT_1.id, CLIENT_1.appId, CLIENT_1.clientSecret, CLIENT_1.redirectURI, CLIENT_1.scope, function (error) {
clientdb.add(CLIENT_1.id, CLIENT_1.appId, CLIENT_0.type, CLIENT_1.clientSecret, CLIENT_1.redirectURI, CLIENT_1.scope, function (error) {
expect(error).to.be(null);
done();
});
@@ -822,7 +817,7 @@ describe('database', function () {
});
it('add same client id fails', function (done) {
clientdb.add(CLIENT_0.id, CLIENT_0.appId, CLIENT_0.clientSecret, CLIENT_0.redirectURI, CLIENT_0.scope, function (error) {
clientdb.add(CLIENT_0.id, CLIENT_0.appId, CLIENT_0.type, CLIENT_0.clientSecret, CLIENT_0.redirectURI, CLIENT_0.scope, function (error) {
expect(error).to.be.a(DatabaseError);
expect(error.reason).to.equal(DatabaseError.ALREADY_EXISTS);
done();
@@ -845,6 +840,14 @@ describe('database', function () {
});
});
it('getByAppIdAndType succeeds', function (done) {
clientdb.getByAppIdAndType(CLIENT_0.appId, CLIENT_0.type, function (error, result) {
expect(error).to.be(null);
expect(result).to.eql(CLIENT_0);
done();
});
});
it('getByAppId fails for unknown client id', function (done) {
clientdb.getByAppId(CLIENT_0.appId + CLIENT_0.appId, function (error, result) {
expect(error).to.be.a(DatabaseError);
@@ -865,6 +868,19 @@ describe('database', function () {
});
});
it('delByAppIdAndType succeeds', function (done) {
clientdb.delByAppIdAndType(CLIENT_1.appId, CLIENT_1.type, function (error) {
expect(error).to.be(null);
clientdb.getByAppIdAndType(CLIENT_1.appId, CLIENT_1.type, function (error, result) {
expect(error).to.be.a(DatabaseError);
expect(error.reason).to.equal(DatabaseError.NOT_FOUND);
expect(result).to.not.be.ok();
done();
});
});
});
it('delByAppId succeeds', function (done) {
clientdb.delByAppId(CLIENT_0.appId, function (error) {
expect(error).to.be(null);