rename setup and teardown functions of oauth addon
This commit is contained in:
@@ -11,8 +11,8 @@ exports = module.exports = {
|
|||||||
getBindsSync: getBindsSync,
|
getBindsSync: getBindsSync,
|
||||||
|
|
||||||
// exported for testing
|
// exported for testing
|
||||||
_allocateOAuthCredentials: allocateOAuthCredentials,
|
_setupOauth: setupOauth,
|
||||||
_removeOAuthCredentials: removeOAuthCredentials
|
_teardownOauth: teardownOauth
|
||||||
};
|
};
|
||||||
|
|
||||||
var appdb = require('./appdb.js'),
|
var appdb = require('./appdb.js'),
|
||||||
@@ -45,10 +45,10 @@ var NOOP = function (app, callback) { return callback(); };
|
|||||||
// teardown is destructive. app data stored with the addon is lost
|
// teardown is destructive. app data stored with the addon is lost
|
||||||
var KNOWN_ADDONS = {
|
var KNOWN_ADDONS = {
|
||||||
oauth: {
|
oauth: {
|
||||||
setup: allocateOAuthCredentials,
|
setup: setupOauth,
|
||||||
teardown: removeOAuthCredentials,
|
teardown: teardownOauth,
|
||||||
backup: NOOP,
|
backup: NOOP,
|
||||||
restore: allocateOAuthCredentials
|
restore: setupOauth
|
||||||
},
|
},
|
||||||
ldap: {
|
ldap: {
|
||||||
setup: setupLdap,
|
setup: setupLdap,
|
||||||
@@ -229,7 +229,7 @@ function getBindsSync(app, addons) {
|
|||||||
return binds;
|
return binds;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allocateOAuthCredentials(app, callback) {
|
function setupOauth(app, callback) {
|
||||||
assert.strictEqual(typeof app, 'object');
|
assert.strictEqual(typeof app, 'object');
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ function allocateOAuthCredentials(app, callback) {
|
|||||||
var redirectURI = 'https://' + config.appFqdn(app.location);
|
var redirectURI = 'https://' + config.appFqdn(app.location);
|
||||||
var scope = 'profile,roleUser';
|
var scope = 'profile,roleUser';
|
||||||
|
|
||||||
debugApp(app, 'allocateOAuthCredentials: id:%s clientSecret:%s', id, clientSecret);
|
debugApp(app, 'setupOauth: id:%s clientSecret:%s', id, clientSecret);
|
||||||
|
|
||||||
clientdb.delByAppId('addon-' + appId, function (error) { // remove existing creds
|
clientdb.delByAppId('addon-' + appId, function (error) { // remove existing creds
|
||||||
if (error && error.reason !== DatabaseError.NOT_FOUND) return callback(error);
|
if (error && error.reason !== DatabaseError.NOT_FOUND) return callback(error);
|
||||||
@@ -260,11 +260,11 @@ function allocateOAuthCredentials(app, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeOAuthCredentials(app, callback) {
|
function teardownOauth(app, callback) {
|
||||||
assert.strictEqual(typeof app, 'object');
|
assert.strictEqual(typeof app, 'object');
|
||||||
assert.strictEqual(typeof callback, 'function');
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
debugApp(app, 'removeOAuthCredentials');
|
debugApp(app, 'teardownOauth');
|
||||||
|
|
||||||
clientdb.delByAppId('addon-' + app.id, function (error) {
|
clientdb.delByAppId('addon-' + app.id, function (error) {
|
||||||
if (error && error.reason !== DatabaseError.NOT_FOUND) console.error(error);
|
if (error && error.reason !== DatabaseError.NOT_FOUND) console.error(error);
|
||||||
|
|||||||
@@ -136,21 +136,21 @@ describe('apptask', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('allocate OAuth credentials', function (done) {
|
it('allocate OAuth credentials', function (done) {
|
||||||
addons._allocateOAuthCredentials(APP, function (error) {
|
addons._setupOauth(APP, function (error) {
|
||||||
expect(error).to.be(null);
|
expect(error).to.be(null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('remove OAuth credentials', function (done) {
|
it('remove OAuth credentials', function (done) {
|
||||||
addons._removeOAuthCredentials(APP, function (error) {
|
addons._teardownOauth(APP, function (error) {
|
||||||
expect(error).to.be(null);
|
expect(error).to.be(null);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('remove OAuth credentials twice succeeds', function (done) {
|
it('remove OAuth credentials twice succeeds', function (done) {
|
||||||
addons._removeOAuthCredentials(APP, function (error) {
|
addons._teardownOauth(APP, function (error) {
|
||||||
expect(!error).to.be.ok();
|
expect(!error).to.be.ok();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user