All files / mongoose/lib/helpers/topology isSSLError.js

37.5% Statements 3/8
0% Branches 0/6
0% Functions 0/2
37.5% Lines 3/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    1x   1x     1x                  
'use strict';
 
const getConstructorName = require('../getConstructorName');
 
const nonSSLMessage = 'Client network socket disconnected before secure TLS ' +
  'connection was established';
 
module.exports = function isSSLError(topologyDescription) {
  if (getConstructorName(topologyDescription) !== 'TopologyDescription') {
    return false;
  }
 
  const descriptions = Array.from(topologyDescription.servers.values());
  return descriptions.length > 0 &&
    descriptions.every(descr => descr.error && descr.error.message.indexOf(nonSSLMessage) !== -1);
};