0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00
mongodb/jstests/sslSpecial/ssl_mixedmode.js
2016-05-28 17:55:12 -04:00

30 lines
1.1 KiB
JavaScript

// Test the --sslMode parameter
// This tests runs through the 8 possible combinations of sslMode values
// and SSL-enabled and disabled shell respectively. For each combination
// expected behavior is verified.
load("jstests/libs/ssl_test.js");
function testCombination(sslMode, sslShell, shouldSucceed) {
var serverOptionOverrides = {sslMode: sslMode};
var clientOptions =
sslShell ? SSLTest.prototype.defaultSSLClientOptions : SSLTest.prototype.noSSLClientOptions;
var fixture = new SSLTest(serverOptionOverrides, clientOptions);
print("Trying sslMode: '" + sslMode + "' with sslShell = " + sslShell +
"; expect connection to " + (shouldSucceed ? "SUCCEED" : "FAIL"));
assert.eq(shouldSucceed, fixture.connectWorked());
}
testCombination("disabled", false, true);
testCombination("allowSSL", false, true);
testCombination("preferSSL", false, true);
testCombination("requireSSL", false, false);
testCombination("disabled", true, false);
testCombination("allowSSL", true, true);
testCombination("preferSSL", true, true);
testCombination("requireSSL", true, true);