forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssl_mixedmode.js
29 lines (24 loc) · 1.2 KB
/
ssl_mixedmode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 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);