diff options
author | Adam Cooper <adam.cooper@mongodb.com> | 2019-10-01 22:03:41 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-01 22:03:41 +0000 |
commit | 8be05f0607113b2406d6d6c4fc5c0f998b012812 (patch) | |
tree | ebf8cc0886cf5b1541a59899b740f1990dd0cb1a /jstests/ssl/sni_name_advertisement.js | |
parent | be20a34cf0af56cccc378861abb43e528daacea5 (diff) | |
download | mongo-8be05f0607113b2406d6d6c4fc5c0f998b012812.tar.gz |
SERVER-43234 Fix temporary changes made to SERVER-42287
Diffstat (limited to 'jstests/ssl/sni_name_advertisement.js')
-rw-r--r-- | jstests/ssl/sni_name_advertisement.js | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/jstests/ssl/sni_name_advertisement.js b/jstests/ssl/sni_name_advertisement.js index 7403bcd8f23..53891bc0457 100644 --- a/jstests/ssl/sni_name_advertisement.js +++ b/jstests/ssl/sni_name_advertisement.js @@ -4,6 +4,7 @@ (function() { 'use strict'; +load('jstests/ssl/libs/ssl_helpers.js'); let path = "jstests/libs/"; let pemKeyFile = path + "server.pem"; @@ -16,13 +17,13 @@ let params = { tlsCAFile: caFile, tlsMode: "preferTLS", bind_ip: testURL, - tlsAllowInvalidHostnames: "" + tlsAllowInvalidCertificates: "" }; /* we will have two test server configurations: one that is bound to a URL, and one that is bound to * an IP address * The bind_ip here is only to confirm that mongod and the shell are on the same page. bind_ip is - * not what is used for testing SNI advertisement. That is the IP address supplied to the shell. */ + * not what is used for testing SNI advertisement. That is the name supplied to the shell. */ let ipParams = Object.merge(params, {bind_ip: testIP}); let urlParams = params; @@ -47,8 +48,13 @@ function getSNISharded(params) { host: params.bind_ip, other: {configOptions: params, mongosOptions: params, shardOptions: params} }); - let db = s.shard0.getDB("admin"); - const sni = db.runCommand({whatsmysni: 1})['sni']; + let db = s.getDB("admin"); + + // sort of have to fish out the value from deep within the output of multicast + const multicastData = + assert.commandWorked(db.runCommand({multicast: {whatsmysni: 1}}))["hosts"]; + const hostName = Object.keys(multicastData)[0]; + const sni = multicastData[hostName]["data"]["sni"]; s.stop(); @@ -57,15 +63,22 @@ function getSNISharded(params) { // TODO SERVER-41045 remove if-statement once SNI is supported on Windows if (!_isWindows()) { - jsTestLog("Testing mongod bound to URL " + testURL); - assert.eq(testURL, getSNI(urlParams), "URL host is not advertised as SNI name in basic mongod"); + jsTestLog("Testing mongod bound to host " + testURL); + assert.eq(testURL, getSNI(urlParams), "Hostname is not advertised as SNI name in basic mongod"); + jsTestLog("Testing sharded configuration bound to host " + testURL); assert.eq(testURL, getSNISharded(urlParams), - "URL host is not advertised as SNI name in sharded mongod"); + "Hostname is not advertised as SNI name in sharded mongod"); + // apple's TLS stack does not allow us to selectively remove SNI names, so IP addresses are + // still advertised + const desiredOutput = determineSSLProvider() === "apple" ? testIP : false; jsTestLog("Testing mongod bound to IP " + testIP); - assert.eq(false, getSNI(ipParams), "IP host is advertised as SNI name in basic mongod"); assert.eq( - false, getSNISharded(ipParams), "IP host is advertised as SNI name in sharded mongod"); + desiredOutput, getSNI(ipParams), "IP address is advertised as SNI name in basic mongod"); + jsTestLog("Testing sharded configuration bound to IP " + testIP); + assert.eq(desiredOutput, + getSNISharded(ipParams), + "IP address is advertised as SNI name in sharded mongod"); } })();
\ No newline at end of file |