All files / node-activedirectory/lib/services/internal service.isAllowedReferral.js

33.33% Statements 4/12
0% Branches 0/4
0% Functions 0/2
40% Lines 4/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 221x 1x 1x                                     1x
const _                                             = require('underscore');
let log                                             = require('./service.log');
let defaultReferrals = originalDefaultReferrals     = require('../../configs/config.defaultReferrals');
 
 
/**
 * Checks to see if the specified referral or "chase" is allowed.
 * @param {String} referral The referral to inspect.
 * @returns {Boolean} True if the referral should be followed, false if otherwise.
 */
function isAllowedReferral(referral) {
    log.trace('isAllowedReferral(%j)', referral);
    if (!defaultReferrals.enabled) return (false);
    if (!referral) return (false);
 
    return (!_.any(defaultReferrals.exclude, function (exclusion) {
        var re = new RegExp(exclusion, "i");
        return (re.test(referral));
    }));
}
 
module.exports = isAllowedReferral;