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

30 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)"));
var serverOptionOverrides = {tlsMode: tlsMode, setParameter: {enableTestCommands: 1}};
var clientOptions =
sslShell ? TLSTest.prototype.defaultTLSClientOptions : TLSTest.prototype.noTLSClientOptions;
var fixture = new TLSTest(serverOptionOverrides, clientOptions);
assert.eq(shouldSucceed, fixture.connectWorked());
}
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);