diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-08-16 21:10:33 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-08-17 01:48:12 +0000 |
commit | 3cc779415f2777223b5549d3dfd1b85eef01842b (patch) | |
tree | e165efebd7b0d7d83c68f0de5d88d46b3ac2285e /jstests/ssl | |
parent | ecd1e0b022a68110ada6517f84ffd91ea8a91bca (diff) | |
download | mongo-3cc779415f2777223b5549d3dfd1b85eef01842b.tar.gz |
Revert "SERVER-48693 Add network counter for cluster authentication"
This reverts commit 24dd72daae9e4cf59ad51910058bc111f20edbff.
Diffstat (limited to 'jstests/ssl')
-rw-r--r-- | jstests/ssl/auth-counters.js | 65 | ||||
-rw-r--r-- | jstests/ssl/speculative-auth-replset.js | 11 | ||||
-rw-r--r-- | jstests/ssl/speculative-auth-sharding.js | 25 | ||||
-rw-r--r-- | jstests/ssl/speculative-authenticate.js | 32 |
4 files changed, 23 insertions, 110 deletions
diff --git a/jstests/ssl/auth-counters.js b/jstests/ssl/auth-counters.js index 04274ef8578..6eaafa3735e 100644 --- a/jstests/ssl/auth-counters.js +++ b/jstests/ssl/auth-counters.js @@ -3,13 +3,11 @@ (function() { 'use strict'; -const x509 = "MONGODB-X509"; const mongod = MongoRunner.runMongod({ auth: '', tlsMode: 'requireTLS', tlsCertificateKeyFile: 'jstests/libs/server.pem', tlsCAFile: 'jstests/libs/ca.pem', - clusterAuthMode: "x509", }); const admin = mongod.getDB('admin'); const external = mongod.getDB('$external'); @@ -22,79 +20,46 @@ external.createUser({user: X509USER, roles: []}); // This test ignores counters for SCRAM-SHA-*. // For those, see jstests/auth/auth-counters.js -const expected = assert.commandWorked(admin.runCommand({serverStatus: 1})) - .security.authentication.mechanisms[x509]; +const expected = { + received: 0, + successful: 0 +}; function assertStats() { const mechStats = assert.commandWorked(admin.runCommand({serverStatus: 1})) - .security.authentication.mechanisms[x509]; - try { - assert.eq(mechStats.authenticate.received, expected.authenticate.received); - assert.eq(mechStats.authenticate.successful, expected.authenticate.successful); - assert.eq(mechStats.clusterAuthenticate.received, expected.clusterAuthenticate.received); - assert.eq(mechStats.clusterAuthenticate.successful, - expected.clusterAuthenticate.successful); - } catch (e) { - print("mechStats: " + tojson(mechStats)); - print("expected: " + tojson(expected)); - throw e; - } + .security.authentication.mechanisms['MONGODB-X509'] + .authenticate; + assert.eq(mechStats.received, expected.received); + assert.eq(mechStats.successful, expected.successful); } function assertSuccess(creds) { assert.eq(external.auth(creds), true); external.logout(); - ++expected.authenticate.received; - ++expected.authenticate.successful; + ++expected.received; + ++expected.successful; assertStats(); } function assertFailure(creds) { assert.eq(external.auth(creds), false); - ++expected.authenticate.received; - assertStats(); -} - -function assertSuccessInternal() { - assert.eq(runMongoProgram("mongo", - "--tls", - "--port", - mongod.port, - "--tlsCertificateKeyFile", - "jstests/libs/server.pem", - "--tlsCAFile", - "jstests/libs/ca.pem", - "--authenticationDatabase", - "$external", - "--authenticationMechanism", - "MONGODB-X509", - "--eval", - ";"), - 0); - ++expected.authenticate.received; - ++expected.authenticate.successful; - ++expected.clusterAuthenticate.received; - ++expected.clusterAuthenticate.successful; + ++expected.received; assertStats(); } // User from certificate should work. -assertSuccess({mechanism: x509}); +assertSuccess({mechanism: 'MONGODB-X509'}); // Explicitly named user. -assertSuccess({user: X509USER, mechanism: x509}); - -// Cluster auth counter checks. -// We can't test failures with the __system user without the handshake failing, -// which won't increment the counters. -assertSuccessInternal(); +assertSuccess({user: X509USER, mechanism: 'MONGODB-X509'}); // Fails once the user no longer exists. external.dropUser(X509USER); -assertFailure({mechanism: x509}); +assertFailure({mechanism: 'MONGODB-X509'}); const finalStats = assert.commandWorked(admin.runCommand({serverStatus: 1})).security.authentication.mechanisms; MongoRunner.stopMongod(mongod); + printjson(finalStats); })(); diff --git a/jstests/ssl/speculative-auth-replset.js b/jstests/ssl/speculative-auth-replset.js index d23ad32802b..3c10b53b678 100644 --- a/jstests/ssl/speculative-auth-replset.js +++ b/jstests/ssl/speculative-auth-replset.js @@ -37,16 +37,13 @@ const mechStats = printjson(mechStats); assert(mechStats['MONGODB-X509'] !== undefined); Object.keys(mechStats).forEach(function(mech) { - const specStats = mechStats[mech].speculativeAuthenticate; - const clusterStats = mechStats[mech].clusterAuthenticate; + const stats = mechStats[mech].speculativeAuthenticate; if (mech === 'MONGODB-X509') { - assert.gte(specStats.received, 2); - assert.gte(clusterStats.received, 2); + assert.gte(stats.received, 2); } else { - assert.eq(specStats.received, 0); + assert.eq(stats.received, 0); } - assert.eq(specStats.received, specStats.successful); - assert.eq(clusterStats.received, clusterStats.successful); + assert.eq(stats.received, stats.successful); }); admin.logout(); diff --git a/jstests/ssl/speculative-auth-sharding.js b/jstests/ssl/speculative-auth-sharding.js index 7a198c7983b..56af5fddaca 100644 --- a/jstests/ssl/speculative-auth-sharding.js +++ b/jstests/ssl/speculative-auth-sharding.js @@ -55,17 +55,6 @@ assert.eq(runMongoProgram('mongo', '--eval', ';'), 0); -assert.eq(runMongoProgram('mongo', - uri, - '--tls', - '--tlsCertificateKeyFile', - SERVER_CERT, - '--tlsCAFile', - CA_CERT, - '--tlsAllowInvalidHostnames', - '--eval', - ';'), - 0); const authStats = assert.commandWorked(admin.runCommand({serverStatus: 1})) .security.authentication.mechanisms['MONGODB-X509']; @@ -74,20 +63,14 @@ jsTest.log('Authenticated stats: ' + tojson(authStats)); // Got and succeeded an additional speculation. const initSpec = initialStats.speculativeAuthenticate; const authSpec = authStats.speculativeAuthenticate; -assert.eq(authSpec.received, initSpec.received + 2); -assert.eq(authSpec.successful, initSpec.successful + 2); +assert.eq(authSpec.received, initSpec.received + 1); +assert.eq(authSpec.successful, initSpec.successful + 1); // Got and succeeded an additional auth. const initAuth = initialStats.authenticate; const authAuth = authStats.authenticate; -assert.eq(authAuth.received, initAuth.received + 2); -assert.eq(authAuth.successful, initAuth.successful + 2); - -// Got and succeeded intra-cluster auth. -const initCluster = initialStats.clusterAuthenticate; -const authCluster = authStats.clusterAuthenticate; -assert.eq(authCluster.received, initCluster.received + 1); -assert.eq(authCluster.successful, initCluster.successful + 1); +assert.eq(authAuth.received, initAuth.received + 1); +assert.eq(authAuth.successful, initAuth.successful + 1); ///////////////////////////////////////////////////////////////////////////// diff --git a/jstests/ssl/speculative-authenticate.js b/jstests/ssl/speculative-authenticate.js index 492469466df..41b7139230f 100644 --- a/jstests/ssl/speculative-authenticate.js +++ b/jstests/ssl/speculative-authenticate.js @@ -8,7 +8,6 @@ const mongod = MongoRunner.runMongod({ tlsMode: 'requireTLS', tlsCertificateKeyFile: 'jstests/libs/server.pem', tlsCAFile: 'jstests/libs/ca.pem', - clusterAuthMode: "x509", }); const admin = mongod.getDB('admin'); const external = mongod.getDB('$external'); @@ -33,19 +32,6 @@ function test(uri) { assert.eq(0, x509); } -function testInternal(uri) { - const x509 = runMongoProgram('mongo', - '--tls', - '--tlsCAFile', - 'jstests/libs/ca.pem', - '--tlsCertificateKeyFile', - 'jstests/libs/server.pem', - uri, - '--eval', - ';'); - assert.eq(0, x509); -} - function assertStats(cb) { const mechStats = assert.commandWorked(admin.runCommand({serverStatus: 1})) .security.authentication.mechanisms; @@ -78,23 +64,5 @@ assertStats(function(mechStats) { assert.eq(stats.successful, 1); }); -// We haven't done any cluster auth yet, so clusterAuthenticate counts should be 0 -assertStats(function(mechStats) { - const stats = mechStats['MONGODB-X509'].clusterAuthenticate; - assert.eq(stats.received, 0); - assert.eq(stats.successful, 0); -}); - -// Connect intra-cluster with speculation. -testInternal(baseURI + '?authMechanism=MONGODB-X509'); -assertStats(function(mechStats) { - const specStats = mechStats['MONGODB-X509'].speculativeAuthenticate; - const clusterStats = mechStats['MONGODB-X509'].clusterAuthenticate; - assert.eq(specStats.received, 2); - assert.eq(specStats.successful, 2); - assert.eq(clusterStats.received, 1); - assert.eq(clusterStats.successful, 1); -}); - MongoRunner.stopMongod(mongod); })(); |