summaryrefslogtreecommitdiff
path: root/jstests/core/index_create_with_nul_in_name.js
blob: c128dcc58808f0e0fe4705b31ce3897ef4a05b5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// SERVER-16672 disallow creating indexes with NUL bytes in the name

(function() {
    'use strict';

    var coll = db.create_index_with_nul_in_name;
    coll.drop();

    var idx = {key: {'a': 1}, name: 'foo\0bar', ns: coll.getFullName()};

    var res = coll.runCommand('createIndexes', {indexes: [idx]});
    assert.commandFailed(res, tojson(res));
    assert.eq(res.code, 67);  // CannotCreateIndex
}());