summaryrefslogtreecommitdiff
path: root/jstests/core/evalh.js
blob: 11e672f6bf45f48d6b910ea6acb9d43612856b6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * Test that db.eval does not support auth.
 */
(function() {
    'use strict';

    assert.writeOK(db.evalprep.insert({}), "db must exist for eval to succeed");
    db.evalprep.drop();

    // The db.auth method call getMongo().auth but catches the exception.
    assert.eq(0, db.eval('db.auth("reader", "reader")'));

    // Call the native implementation auth function and verify it does not exist under the db.eval
    // javascript context.
    assert.throws(function() {
        db.eval('db.getMongo().auth("reader", "reader")');
    });
})();