0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-28 07:59:02 +01:00
mongodb/jstests/ssl/ssl_options.js
W. Brad Moore 3cbd53553c SERVER-84397: Use proper SSL options in tests
GitOrigin-RevId: 2ceb3b5faa6e0038e0f6d2f4326241b735b83535
2024-02-01 15:32:18 +00:00

49 lines
1.7 KiB
JavaScript

// Test redaction of passwords in command line SSL option parsing.
import {requireSSLProvider} from "jstests/ssl/libs/ssl_helpers.js";
requireSSLProvider('openssl', function() {
const baseName = "jstests_ssl_ssl_options";
jsTest.log("Testing censorship of ssl options");
const mongodConfig = {
tlsCertificateKeyFile: "jstests/libs/password_protected.pem",
tlsMode: "requireTLS",
tlsCertificateKeyFilePassword: "qwerty",
tlsClusterPassword: "qwerty",
tlsCAFile: "jstests/libs/ca.pem"
};
const mongodSource = MongoRunner.runMongod(mongodConfig);
const getCmdLineOptsResult = mongodSource.adminCommand("getCmdLineOpts");
let i;
let 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] === "--tlsPEMKeyPassword" ||
getCmdLineOptsResult.argv[i] === "--tlsClusterPassword") {
isPassword = true;
}
}
assert.eq(getCmdLineOptsResult.parsed.net.tls.certificateKeyFilePassword,
"<password>",
"Password not properly censored: " + tojson(getCmdLineOptsResult));
assert.eq(getCmdLineOptsResult.parsed.net.tls.clusterPassword,
"<password>",
"Password not properly censored: " + tojson(getCmdLineOptsResult));
MongoRunner.stopMongod(mongodSource);
print(baseName + " succeeded.");
});