summaryrefslogtreecommitdiff
path: root/jstests/sslSpecial
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:17:50 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2016-03-09 12:18:14 -0500
commit4ae691e8edc87d0e3cfb633bb91c328426be007b (patch)
tree52079a593f54382ca13a2e741633eab1b6271893 /jstests/sslSpecial
parenta025d43f3ce2efc1fb1282a718f5d286fa0a4dc1 (diff)
downloadmongo-4ae691e8edc87d0e3cfb633bb91c328426be007b.tar.gz
SERVER-22468 Format JS code with approved style in jstests/
Diffstat (limited to 'jstests/sslSpecial')
-rw-r--r--jstests/sslSpecial/set_parameter_nossl.js6
-rw-r--r--jstests/sslSpecial/ssl_mixedmode.js13
-rw-r--r--jstests/sslSpecial/upgrade_to_ssl_nossl.js16
-rw-r--r--jstests/sslSpecial/upgrade_to_x509_ssl_nossl.js83
4 files changed, 76 insertions, 42 deletions
diff --git a/jstests/sslSpecial/set_parameter_nossl.js b/jstests/sslSpecial/set_parameter_nossl.js
index 280d47b6130..74bab379aa0 100644
--- a/jstests/sslSpecial/set_parameter_nossl.js
+++ b/jstests/sslSpecial/set_parameter_nossl.js
@@ -7,12 +7,10 @@ function testTransition(newSSLMode, newClusterAuthMode) {
// If no parameters are given sslMode defaults to disabled
var conn = MongoRunner.runMongod({clusterAuthMode: "keyFile"});
var adminDB = conn.getDB("admin");
- var res = adminDB.runCommand({ "setParameter" : 1,
- "sslMode" : newSSLMode });
+ var res = adminDB.runCommand({"setParameter": 1, "sslMode": newSSLMode});
assert(!res["ok"]);
- var res = adminDB.runCommand({ "setParameter" : 1,
- "clusterAuthMode" : newClusterAuthMode });
+ var res = adminDB.runCommand({"setParameter": 1, "clusterAuthMode": newClusterAuthMode});
assert(!res["ok"]);
MongoRunner.stopMongod(conn.port);
}
diff --git a/jstests/sslSpecial/ssl_mixedmode.js b/jstests/sslSpecial/ssl_mixedmode.js
index 738aa26714f..085740f0a26 100644
--- a/jstests/sslSpecial/ssl_mixedmode.js
+++ b/jstests/sslSpecial/ssl_mixedmode.js
@@ -6,17 +6,16 @@
load("jstests/libs/ssl_test.js");
function testCombination(sslMode, sslShell, shouldSucceed) {
+ var serverOptionOverrides = {
+ sslMode: sslMode
+ };
- var serverOptionOverrides = {sslMode: sslMode};
-
- var clientOptions = sslShell ?
- SSLTest.prototype.defaultSSLClientOptions :
- SSLTest.prototype.noSSLClientOptions;
+ var clientOptions =
+ sslShell ? SSLTest.prototype.defaultSSLClientOptions : SSLTest.prototype.noSSLClientOptions;
var fixture = new SSLTest(serverOptionOverrides, clientOptions);
- print("Trying sslMode: '" + sslMode +
- "' with sslShell = " + sslShell +
+ print("Trying sslMode: '" + sslMode + "' with sslShell = " + sslShell +
"; expect connection to " + (shouldSucceed ? "SUCCEED" : "FAIL"));
assert.eq(shouldSucceed, fixture.connectWorked());
diff --git a/jstests/sslSpecial/upgrade_to_ssl_nossl.js b/jstests/sslSpecial/upgrade_to_ssl_nossl.js
index 53f7bd77fb9..11d43040d93 100644
--- a/jstests/sslSpecial/upgrade_to_ssl_nossl.js
+++ b/jstests/sslSpecial/upgrade_to_ssl_nossl.js
@@ -9,26 +9,26 @@
load("jstests/ssl/libs/ssl_helpers.js");
-var rst = new ReplSetTest({ name: 'sslSet', nodes: 3, nodeOptions : {sslMode:"disabled"} });
+var rst = new ReplSetTest({name: 'sslSet', nodes: 3, nodeOptions: {sslMode: "disabled"}});
rst.startSet();
rst.initiate();
var rstConn1 = rst.getPrimary();
-rstConn1.getDB("test").a.insert({a:1, str:"TESTTESTTEST"});
+rstConn1.getDB("test").a.insert({a: 1, str: "TESTTESTTEST"});
assert.eq(1, rstConn1.getDB("test").a.count(), "Error interacting with replSet");
print("===== UPGRADE disabled -> allowSSL =====");
-rst.upgradeSet({sslMode:"allowSSL", sslPEMKeyFile: SERVER_CERT, sslAllowInvalidCertificates:""});
+rst.upgradeSet({sslMode: "allowSSL", sslPEMKeyFile: SERVER_CERT, sslAllowInvalidCertificates: ""});
var rstConn2 = rst.getPrimary();
-rstConn2.getDB("test").a.insert({a:2, str:"TESTTESTTEST"});
+rstConn2.getDB("test").a.insert({a: 2, str: "TESTTESTTEST"});
assert.eq(2, rstConn2.getDB("test").a.count(), "Error interacting with replSet");
print("===== UPGRADE allowSSL -> preferSSL =====");
-rst.upgradeSet({sslMode:"preferSSL", sslPEMKeyFile: SERVER_CERT, sslAllowInvalidCertificates:""});
+rst.upgradeSet({sslMode: "preferSSL", sslPEMKeyFile: SERVER_CERT, sslAllowInvalidCertificates: ""});
var rstConn3 = rst.getPrimary();
-rstConn3.getDB("test").a.insert({a:3, str:"TESTTESTTEST"});
+rstConn3.getDB("test").a.insert({a: 3, str: "TESTTESTTEST"});
assert.eq(3, rstConn3.getDB("test").a.count(), "Error interacting with replSet");
-var canConnectSSL = runMongoProgram("mongo", "--port", rst.ports[0],
- "--ssl", "--sslAllowInvalidCertificates", "--eval", ";");
+var canConnectSSL = runMongoProgram(
+ "mongo", "--port", rst.ports[0], "--ssl", "--sslAllowInvalidCertificates", "--eval", ";");
assert.eq(0, canConnectSSL, "SSL Connection attempt failed when it should succeed");
diff --git a/jstests/sslSpecial/upgrade_to_x509_ssl_nossl.js b/jstests/sslSpecial/upgrade_to_x509_ssl_nossl.js
index 1d18dc2225d..ec29c991e9d 100644
--- a/jstests/sslSpecial/upgrade_to_x509_ssl_nossl.js
+++ b/jstests/sslSpecial/upgrade_to_x509_ssl_nossl.js
@@ -19,9 +19,13 @@ function authAllNodes() {
}
}
-opts = {sslMode:"disabled", clusterAuthMode:"keyFile", keyFile: KEYFILE};
+opts = {
+ sslMode: "disabled",
+ clusterAuthMode: "keyFile",
+ keyFile: KEYFILE
+};
var NUM_NODES = 3;
-var rst = new ReplSetTest({ name: 'sslSet', nodes: NUM_NODES, nodeOptions : opts });
+var rst = new ReplSetTest({name: 'sslSet', nodes: NUM_NODES, nodeOptions: opts});
rst.startSet();
rst.initiate();
@@ -29,54 +33,87 @@ rst.initiate();
var rstConn1 = rst.getPrimary();
rstConn1.getDB("admin").createUser({user: "root", pwd: "pwd", roles: ["root"]}, {w: NUM_NODES});
rstConn1.getDB("admin").auth("root", "pwd");
-rstConn1.getDB("test").a.insert({a:1, str:"TESTTESTTEST"});
+rstConn1.getDB("test").a.insert({a: 1, str: "TESTTESTTEST"});
assert.eq(1, rstConn1.getDB("test").a.count(), "Error interacting with replSet");
print("===== UPGRADE disabled,keyFile -> allowSSL,sendKeyfile =====");
authAllNodes();
-rst.upgradeSet({sslMode:"allowSSL", sslPEMKeyFile: SERVER_CERT,
- sslAllowInvalidCertificates:"",
- clusterAuthMode:"sendKeyFile", keyFile: KEYFILE,
- sslCAFile: CA_CERT}, "root", "pwd");
+rst.upgradeSet(
+ {
+ sslMode: "allowSSL",
+ sslPEMKeyFile: SERVER_CERT,
+ sslAllowInvalidCertificates: "",
+ clusterAuthMode: "sendKeyFile",
+ keyFile: KEYFILE,
+ sslCAFile: CA_CERT
+ },
+ "root",
+ "pwd");
authAllNodes();
rst.awaitReplication();
var rstConn2 = rst.getPrimary();
-rstConn2.getDB("test").a.insert({a:2, str:"CHECKCHECKCHECK"});
+rstConn2.getDB("test").a.insert({a: 2, str: "CHECKCHECKCHECK"});
assert.eq(2, rstConn2.getDB("test").a.count(), "Error interacting with replSet");
print("===== UPGRADE allowSSL,sendKeyfile -> preferSSL,sendX509 =====");
-rst.upgradeSet({sslMode:"preferSSL", sslPEMKeyFile: SERVER_CERT,
- sslAllowInvalidCertificates:"",
- clusterAuthMode:"sendX509", keyFile: KEYFILE,
- sslCAFile: CA_CERT}, "root", "pwd");
+rst.upgradeSet(
+ {
+ sslMode: "preferSSL",
+ sslPEMKeyFile: SERVER_CERT,
+ sslAllowInvalidCertificates: "",
+ clusterAuthMode: "sendX509",
+ keyFile: KEYFILE,
+ sslCAFile: CA_CERT
+ },
+ "root",
+ "pwd");
authAllNodes();
rst.awaitReplication();
var rstConn3 = rst.getPrimary();
-rstConn3.getDB("test").a.insert({a:3, str:"PEASandCARROTS"});
+rstConn3.getDB("test").a.insert({a: 3, str: "PEASandCARROTS"});
assert.eq(3, rstConn3.getDB("test").a.count(), "Error interacting with replSet");
-var canConnectSSL = runMongoProgram("mongo", "--port", rst.ports[0], "--ssl",
+var canConnectSSL = runMongoProgram("mongo",
+ "--port",
+ rst.ports[0],
+ "--ssl",
"--sslAllowInvalidCertificates",
- "--sslPEMKeyFile", CLIENT_CERT, "--eval", ";");
+ "--sslPEMKeyFile",
+ CLIENT_CERT,
+ "--eval",
+ ";");
assert.eq(0, canConnectSSL, "SSL Connection attempt failed when it should succeed");
print("===== UPGRADE preferSSL,sendX509 -> preferSSL,x509 =====");
-//we cannot upgrade past preferSSL here because it will break the test client
-rst.upgradeSet({sslMode:"preferSSL", sslPEMKeyFile: SERVER_CERT,
- sslAllowInvalidCertificates:"",
- clusterAuthMode:"x509", keyFile: KEYFILE,
- sslCAFile: CA_CERT}, "root", "pwd");
+// we cannot upgrade past preferSSL here because it will break the test client
+rst.upgradeSet(
+ {
+ sslMode: "preferSSL",
+ sslPEMKeyFile: SERVER_CERT,
+ sslAllowInvalidCertificates: "",
+ clusterAuthMode: "x509",
+ keyFile: KEYFILE,
+ sslCAFile: CA_CERT
+ },
+ "root",
+ "pwd");
authAllNodes();
rst.awaitReplication();
var rstConn4 = rst.getPrimary();
-rstConn4.getDB("test").a.insert({a:4, str:"BEEP BOOP"});
+rstConn4.getDB("test").a.insert({a: 4, str: "BEEP BOOP"});
rst.awaitReplication();
assert.eq(4, rstConn4.getDB("test").a.count(), "Error interacting with replSet");
// Test that an ssl connection can still be made
-var canConnectSSL = runMongoProgram("mongo", "--port", rst.ports[0], "--ssl",
+var canConnectSSL = runMongoProgram("mongo",
+ "--port",
+ rst.ports[0],
+ "--ssl",
"--sslAllowInvalidCertificates",
- "--sslPEMKeyFile", CLIENT_CERT, "--eval", ";");
+ "--sslPEMKeyFile",
+ CLIENT_CERT,
+ "--eval",
+ ";");
assert.eq(0, canConnectSSL, "SSL Connection attempt failed when it should succeed");