summaryrefslogtreecommitdiff
path: root/jstests/auth/show_log_auth.js
blob: 05df5f20610bae7926e8224bbeaa84d04cdcb352 (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
// test that "show log dbname" and "show logs" have good err messages when unauthorized

var baseName = "jstests_show_log_auth";

var m = MongoRunner.runMongod({auth: "", bind_ip: "127.0.0.1", nojournal: "", smallfiles: ""});
var db = m.getDB("admin");

db.createUser({user: "admin", pwd: "pass", roles: jsTest.adminUserRoles});

function assertStartsWith(s, prefix) {
    assert.eq(s.substr(0, prefix.length), prefix);
}

assertStartsWith(print
                     .captureAllOutput(function() {
                         shellHelper.show('logs');
                     })
                     .output[0],
                 'Error while trying to show logs');

assertStartsWith(print
                     .captureAllOutput(function() {
                         shellHelper.show('log ' + baseName);
                     })
                     .output[0],
                 'Error while trying to show ' + baseName + ' log');

db.auth("admin", "pass");
db.shutdownServer();