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

    assert.writeOK(db.evalprep.insert({}), "db must exist for eval to succeed");
    assert(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")');
    });
})();