From 7eef36be761b550bd5aeace4494852eb87e085a4 Mon Sep 17 00:00:00 2001 From: Adam Rayner Date: Tue, 1 Feb 2022 16:25:00 +0000 Subject: SERVER-62334 Use SASL mech negotiation to get mech for DBClientBase::auth --- jstests/auth/benchrun_scram.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 jstests/auth/benchrun_scram.js (limited to 'jstests/auth/benchrun_scram.js') diff --git a/jstests/auth/benchrun_scram.js b/jstests/auth/benchrun_scram.js new file mode 100644 index 00000000000..c2a0745443a --- /dev/null +++ b/jstests/auth/benchrun_scram.js @@ -0,0 +1,40 @@ +// Ensure that benchRun tests are able to use either SCRAM-SHA-1 or SCRAM-SHA-256 via mech +// negotiation from server +(function() { +"use strict"; + +function benchRunnerAuthWithProvidedMech(mechanism) { + var m = MongoRunner.runMongod({setParameter: 'authenticationMechanisms=' + mechanism}); + + const db = 'admin'; + const user = 'scram_test'; + const pwd = 'something'; + + const admin = m.getDB(db); + admin.createUser({user: user, pwd: pwd, roles: [], mechanisms: [mechanism]}); + + const ops = []; + + const seconds = 1; + + const benchArgs = { + ops: ops, + parallel: 2, + seconds: seconds, + host: m.host, + db: db, + username: user, + password: pwd + }; + + const res = assert.doesNotThrow( + benchRun, [benchArgs], "BenchRun attempted SASL negotiation. Server supports " + mechanism); + + printjson(res); + + MongoRunner.stopMongod(m); +} + +benchRunnerAuthWithProvidedMech("SCRAM-SHA-1"); +benchRunnerAuthWithProvidedMech("SCRAM-SHA-256"); +})(); -- cgit v1.2.1