Skip to content

Commit

Permalink
Added an ssl test for turning off sslValidation
Browse files Browse the repository at this point in the history
  • Loading branch information
christkv committed Mar 26, 2015
1 parent 2771d2a commit 3223e1c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions test/functional/ssl_mongoclient_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,58 @@ exports['should correctly to replicaset using ssl connect with password'] = {
}
}

/**
* @ignore
*/
exports['should correctly connect using ssl with sslValidation turned off'] = {
metadata: { requires: { topology: 'ssl' } },

// The actual test we wish to run
test: function(configuration, test) {
var ReplSetManager = require('mongodb-tools').ReplSetManager
, MongoClient = configuration.require.MongoClient;

// All inserted docs
var docs = [];
var errs = [];
var insertDocs = [];

// Read the ca
var ca = [fs.readFileSync(__dirname + "/ssl/ca.pem")];
var cert = fs.readFileSync(__dirname + "/ssl/client.pem");
var key = fs.readFileSync(__dirname + "/ssl/client.pem");

var replicasetManager = new ReplSetManager({
host: "server"
, sslOnNormalPorts: null
, sslPEMKeyFile: __dirname + "/ssl/server.pem"
, secondaries:2
// EnsureUp options
, ssl: true
, rejectUnauthorized:false
, ca:ca
});

replicasetManager.start({kill: true, purge:true, signal: -9}, function(err, result) {
if(err != null) throw err;
// Connect and validate the server certificate
MongoClient.connect("mongodb://server:31000/test?ssl=true&replicaSet=rs&maxPoolSize=1", {
replSet: {
ssl:true
, sslValidate:false
}
}, function(err, db) {
test.equal(null, err);
test.ok(db != null);

db.close();

// replicasetManager.stop(function() {
test.done();
// });
});
});
}
}


0 comments on commit 3223e1c

Please sign in to comment.