summaryrefslogtreecommitdiff
path: root/jstests/auth/benchrun_scram.js
blob: c2a0745443aab97729f61b9077bc58376f4e438d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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");
})();