~ubuntu-branches/ubuntu/utopic/mongodb/utopic

« back to all changes in this revision

Viewing changes to jstests/validate_user_documents.js

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-07-03 09:23:46 UTC
  • mfrom: (1.3.10) (44.1.14 sid)
  • Revision ID: package-import@ubuntu.com-20140703092346-c5bvt46wnzougyly
Tags: 1:2.6.3-0ubuntu1
* New upstream stable release:
  - Dropped patches, included upstream:
    + 0003-All-platforms-but-Windows-find-hash-in-std-tr1.patch
    + 0008-Use-system-libstemmer.patch
    + 0011-Use-a-signed-char-to-store-BSONType-enumerations.patch
    + 0001-SERVER-12064-Atomic-operations-for-gcc-non-Intel-arc.patch
    + 0002-SERVER-12065-Support-ARM-and-AArch64-builds.patch
  - d/p/*: Refreshed/rebased remaining patches.
  - Use system provided libyaml-cpp:
    + d/control: Add libyaml-cpp-dev to BD's.
    + d/rules: Enable --with-system-yaml option.
    + d/p/fix-yaml-detection.patch: Fix detection of libyaml-cpp library.
  - d/mongodb-server.mongodb.upstart: Sync changes from upstream.
  - d/control,mongodb-dev.*: Drop mongodb-dev package; it has no reverse
    dependencies and upstream no longer install header files.
  - d/NEWS: Point users to upstream upgrade documentation for upgrades
    from 2.4 to 2.6.
* Merge from Debian unstable.
* d/control: BD on libv8-3.14-dev to ensure that transitioning to new v8
  versions is a explicit action due to changes in behaviour in >= 3.25
  (LP: #1295723).
* d/mongodb-server.prerm: Dropped debug echo call from maintainer script
  (LP: #1294455).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Ensure that inserts and updates of the system.users collection validate the schema of inserted
2
 
// documents.
3
 
 
4
 
mydb = db.getSisterDB( "validate_user_documents" );
5
 
 
6
 
function assertGLEOK(status) {
7
 
    assert(status.ok && status.err === null,
8
 
           "Expected OK status object; found " + tojson(status));
9
 
}
10
 
 
11
 
function assertGLENotOK(status) {
12
 
    assert(status.ok && status.err !== null,
13
 
           "Expected not-OK status object; found " + tojson(status));
14
 
}
15
 
 
16
 
mydb.dropDatabase();
17
 
 
18
 
//
19
 
// Tests of the insert path
20
 
//
21
 
 
22
 
// Valid compatibility document; insert should succeed.
23
 
mydb.system.users.insert({ user: "spencer", pwd: hex_md5("spencer:mongo:a"), readOnly: true });
24
 
assertGLEOK(mydb.getLastErrorObj());
25
 
 
26
 
// Invalid compatibility document; insert should fail.
27
 
mydb.system.users.insert({ user: "andy", readOnly: true });
28
 
assertGLENotOK(mydb.getLastErrorObj());
29
 
 
30
 
// Valid extended document; insert should succeed.
31
 
mydb.system.users.insert({ user: "spencer", userSource: "test2", roles: ["dbAdmin"] });
32
 
assertGLEOK(mydb.getLastErrorObj());
33
 
 
34
 
// Invalid extended document; insert should fail.
35
 
mydb.system.users.insert({ user: "andy", userSource: "test2", roles: ["dbAdmin", 15] });
36
 
assertGLENotOK(mydb.getLastErrorObj());
37
 
 
38
 
 
39
 
//
40
 
// Tests of the update path
41
 
//
42
 
 
43
 
// Update a document in a legal way, expect success.
44
 
mydb.system.users.update({user: "spencer", userSource: null}, { $set: {readOnly: false} });
45
 
assertGLEOK(mydb.getLastErrorObj());
46
 
 
47
 
 
48
 
// Update a document in a way that is illegal, expect failure.
49
 
mydb.system.users.update({user: "spencer", userSource: null}, { $unset: {pwd: 1} });
50
 
assertGLENotOK(mydb.getLastErrorObj());
51
 
 
52
 
mydb.dropDatabase();