summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2016-01-13 16:37:57 -0500
committerBenety Goh <benety@mongodb.com>2016-01-14 10:36:57 -0500
commit000cc6041846ac1e658e915dea7ecab0f030218c (patch)
tree7d0838ed31e5773cb7fca3f29329686a1db3b224 /jstests
parent302072ddf3bcd173b23d3c1544b7c6e39d01c259 (diff)
downloadmongo-000cc6041846ac1e658e915dea7ecab0f030218c.tar.gz
SERVER-22109 applyOps should validate database name in index spec when creating indexes
(cherry picked from commit 3fa4cdc79b04639061f0d13b68b60c3e3e5102b6)
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/apply_ops1.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/jstests/core/apply_ops1.js b/jstests/core/apply_ops1.js
index 7cf4d3dc0fc..6129c202d59 100644
--- a/jstests/core/apply_ops1.js
+++ b/jstests/core/apply_ops1.js
@@ -102,6 +102,17 @@
ErrorCodes.InvalidNamespace,
'applyOps should fail on system.indexes insert operation with invalid index namespace');
+ // Inconsistent database name in index spec namespace.
+ assert.commandFailedWithCode(
+ db.adminCommand({applyOps: [{op: 'i', ns: db.getName() + '.system.indexes', o: {
+ ns: 'baddbprefix' + t.getFullName(),
+ key: {a: 1},
+ name: 'a_1',
+ }}]}),
+ ErrorCodes.InvalidNamespace,
+ 'applyOps should fail on system.indexes insert operation with index namespace containing ' +
+ 'inconsistent database name');
+
// Valid 'ns' field value in unknown operation type 'x'.
assert.commandFailed(
db.adminCommand({applyOps: [{op: 'x', ns: t.getFullName()}]}),