mirror of https://github.com/mongodb/mongo
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
// Test the --tlsMode parameter
|
|
// This tests runs through the 8 possible combinations of tlsMode values
|
|
// and SSL-enabled and disabled shell respectively. For each combination
|
|
// expected behavior is verified.
|
|
import {TLSTest} from "jstests/libs/ssl_test.js";
|
|
function testCombination(tlsMode, sslShell, shouldSucceed) {
|
|
jsTest.log(
|
|
"TESTING: tlsMode = " +
|
|
tlsMode +
|
|
", sslShell = " +
|
|
(sslShell ? "true" : "false" + " (should " + (shouldSucceed ? "" : "not ") + "succeed)"),
|
|
);
|
|
|
|
let serverOptionOverrides = {tlsMode: tlsMode};
|
|
|
|
let clientOptions = sslShell ? TLSTest.prototype.defaultTLSClientOptions : TLSTest.prototype.noTLSClientOptions;
|
|
|
|
let fixture = new TLSTest(serverOptionOverrides, clientOptions);
|
|
|
|
if (shouldSucceed) {
|
|
assert(fixture.connectWorked());
|
|
} else {
|
|
assert(fixture.connectFails());
|
|
}
|
|
}
|
|
|
|
testCombination("disabled", false, true);
|
|
testCombination("allowTLS", false, true);
|
|
testCombination("preferTLS", false, true);
|
|
testCombination("requireTLS", false, false);
|
|
testCombination("disabled", true, false);
|
|
testCombination("allowTLS", true, true);
|
|
testCombination("preferTLS", true, true);
|
|
testCombination("requireTLS", true, true);
|