0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/ssl/ssl_options.js
2015-03-24 13:46:51 -04:00

36 lines
1.3 KiB
JavaScript

var baseName = "jstests_ssl_ssl_options";
jsTest.log("Testing censorship of ssl options");
var mongodConfig = { sslPEMKeyFile : "jstests/libs/password_protected.pem",
sslMode : "requireSSL",
sslPEMKeyPassword : "qwerty",
sslClusterPassword : "qwerty" };
var mongodSource = MongoRunner.runMongod(mongodConfig);
var getCmdLineOptsResult = mongodSource.adminCommand("getCmdLineOpts");
var i;
var isPassword = false;
for (i = 0; i < getCmdLineOptsResult.argv.length; i++) {
if (isPassword) {
assert.eq(getCmdLineOptsResult.argv[i], "<password>",
"Password not properly censored: " + tojson(getCmdLineOptsResult));
isPassword = false;
continue;
}
if (getCmdLineOptsResult.argv[i] === "--sslPEMKeyPassword" ||
getCmdLineOptsResult.argv[i] === "--sslClusterPassword") {
isPassword = true;
}
}
assert.eq(getCmdLineOptsResult.parsed.net.ssl.PEMKeyPassword, "<password>",
"Password not properly censored: " + tojson(getCmdLineOptsResult));
assert.eq(getCmdLineOptsResult.parsed.net.ssl.clusterPassword, "<password>",
"Password not properly censored: " + tojson(getCmdLineOptsResult));
MongoRunner.stopMongod(mongodSource.port);
print(baseName + " succeeded.");