summaryrefslogtreecommitdiff
path: root/jstests/auth/log_userid_off.js
blob: 62d0af74c02c1f8181c5360678965bc786c94e89 (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
/**
 * Tests that logged users will not show up in the log.
 *
 * @param mongo {Mongo} connection object.
 */
var doTest = function(mongo, callSetParam) {
    var TEST_USER = 'foo';
    var TEST_PWD = 'bar';
    var testDB = mongo.getDB('test');

    testDB.createUser({user: TEST_USER, pwd: TEST_PWD, roles: jsTest.basicUserRoles});
    testDB.auth(TEST_USER, TEST_PWD);

    testDB.runCommand({dbStats: 1});

    var log = testDB.adminCommand({getLog: 'global'});
    log.log.forEach(function(line) {
        assert.eq(-1, line.indexOf('user: foo@'), 'user logged: ' + line);
    });

    // logUserIds should not be settable
    var res = testDB.runCommand({setParameter: 1, logUserIds: 1});
    assert(!res.ok);

    testDB.runCommand({dbStats: 1});

    log = testDB.adminCommand({getLog: 'global'});
    log.log.forEach(function(line) {
        assert.eq(-1, line.indexOf('user: foo@'), 'user logged: ' + line);
    });
};

var mongo = MongoRunner.runMongod({verbose: 5});
doTest(mongo);
MongoRunner.stopMongod(mongo.port);

var st = new ShardingTest({shards: 1, verbose: 5});
doTest(st.s);
st.stop();