summaryrefslogtreecommitdiff
path: root/jstests/sslSpecial
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-06-29 18:35:47 -0400
committerAdam Midvidy <amidvidy@gmail.com>2015-06-30 16:50:38 -0400
commit2186037a81b3483681f23bc9c614f40ecc413326 (patch)
tree2b47aa8d9640ae1c26ec07cfa96f1dcf00117e9b /jstests/sslSpecial
parentfec53e85b90085e289bfac4d8defaaea2bfb52eb (diff)
downloadmongo-2186037a81b3483681f23bc9c614f40ecc413326.tar.gz
SERVER-19113 rewrite ssl_crl.js and ssl_mixedmode.js to not depend on legacy DBClientConnection behavior
Diffstat (limited to 'jstests/sslSpecial')
-rw-r--r--jstests/sslSpecial/ssl_mixedmode.js58
1 files changed, 16 insertions, 42 deletions
diff --git a/jstests/sslSpecial/ssl_mixedmode.js b/jstests/sslSpecial/ssl_mixedmode.js
index 701c5ea10d7..738aa26714f 100644
--- a/jstests/sslSpecial/ssl_mixedmode.js
+++ b/jstests/sslSpecial/ssl_mixedmode.js
@@ -1,50 +1,25 @@
// 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.
+// expected behavior is verified.
-var SERVER_CERT = "jstests/libs/server.pem"
-var CA_CERT = "jstests/libs/ca.pem"
-var CLIENT_CERT = "jstests/libs/client.pem"
-
-var baseName = "jstests_mixed_mode_ssl"
-port = allocatePorts(1)[0];
+load("jstests/libs/ssl_test.js");
function testCombination(sslMode, sslShell, shouldSucceed) {
- if (sslMode == "disabled") {
- MongoRunner.runMongod({port: port});
- }
- else {
- MongoRunner.runMongod({port: port,
- sslMode: sslMode,
- sslAllowInvalidCertificates: "",
- sslPEMKeyFile: SERVER_CERT,
- sslCAFile: CA_CERT});
- }
-
- var mongo;
- if (sslShell) {
- mongo = runMongoProgram("mongo", "--port", port, "--ssl",
- "--sslPEMKeyFile", CLIENT_CERT,
- "--sslAllowInvalidCertificates",
- "--eval", ";");
- }
- else {
- mongo = runMongoProgram("mongo", "--port", port,
- "--eval", ";");
- }
-
- if (shouldSucceed) {
- // runMongoProgram returns 0 on success
- assert.eq(0, mongo, "Connection attempt failed when it should succeed sslMode:" +
- sslMode + " SSL-shell:" + sslShell);
- }
- else {
- // runMongoProgram returns 1 on failure
- assert.eq(1, mongo, "Connection attempt succeeded when it should fail sslMode:" +
- sslMode + " SSL-shell:" + sslShell);
- }
- MongoRunner.stopMongod(port);
+
+ 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);
@@ -55,4 +30,3 @@ testCombination("disabled", true, false);
testCombination("allowSSL", true, true);
testCombination("preferSSL", true, true);
testCombination("requireSSL", true, true);
-