Skip to content

Commit

Permalink
RHMAP-11703 - function refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rachael-oregan committed Nov 30, 2016
1 parent 0edbcc2 commit 90cfe24
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ var auth = {
}
},
/**
* @param {object} req
* @param {object} res
* @param {object} cb
* New endpoint required as autentication ($fh.auth) requests not handled
* correctly in local development/Studio Preview -
* correctly in local development/Studio Preview -
* the js sdk dertermines envrironment mode from url string.
* New endpoint determines environment mode from env var,
* New endpoint determines environment mode from env var,
* sends request (req) and calls user provided function (cb).
* @param {object} req
* @param {object} res
* @param {object} cb
*/
getEnvironmentMode: function (req, res, cb) {
performAuth: function (req, res, cb) {
// "FH_USE_LOCAL_DB" env var determines if the app is running in local mode.
if (process.env.FH_USE_LOCAL_DB) {
// In local mode, invoke user function
Expand Down
8 changes: 4 additions & 4 deletions test/test_fhauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ module.exports = {
/**
* @param {object} finish
*/
getEnvModeLocal : function(finish) {
performAuthLocalDev : function(finish) {
process.env.FH_USE_LOCAL_DB = 'true';

var req = _.noop;
var res = {body: 'test'};

$fh.auth.getEnvironmentMode(req, res, function(err, resp) {
$fh.auth.performAuth(req, res, function(err, resp) {
assert.notEqual(resp.body, 'productionMode');
finish();
});
Expand All @@ -36,13 +36,13 @@ module.exports = {
/**
* @param {object} finish
*/
getEnvModeRemote: function(finish) {
performAuthProductionDev: function(finish) {
process.env.FH_USE_LOCAL_DB = '';

var req = {body: 'test'};
var res = _.noop;

$fh.auth.getEnvironmentMode(req, res, function(err, resp) {
$fh.auth.performAuth(req, res, function(err, resp) {
assert.equal(resp.body, 'productionMode')
finish();
});
Expand Down

0 comments on commit 90cfe24

Please sign in to comment.