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

100% Statements 8/8
75% Branches 3/4
100% Functions 1/1
100% Lines 8/8

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 22 23 24 25 26 27 281x 1x             1x   2x                   2x 8x     2x     1x
const _             = require('underscore');
const defaultOpts   = require('../../configs/config.defaultClientOpts');
/**
 * From the list of options, retrieves the ldapjs client specific options.
 *
 * @param {Object} opts The opts to parse.
 * @returns {Object} The ldapjs opts.
 */
const getLdapClientOpts = function (Opts) {
 
    let opts = (_.pick(Opts || {},
        // Client
        'url',
        'host', 'port', 'secure', 'tlsOptions',
        'socketPath', 'log', 'timeout', 'idleTimeout',
        'reconnect', 'queue', 'queueSize', 'queueTimeout',
        'queueDisable', 'bindDN', 'bindCredentials',
        'maxConnections', 'reconnect', 'checkInterval', 'maxIdleTime'
    ));
 
    for(key in defaultOpts){
        opts[key] = opts[key] || defaultOpts[key];
    }
 
    return opts;
}
 
module.exports = getLdapClientOpts;