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

« back to all changes in this revision

Viewing changes to jstests/auth/indexSystemUsers.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:
2
2
// dropDups.
3
3
var conn = MongoRunner.runMongod({auth : ""});
4
4
 
5
 
function assertGLENotOK(status) {
6
 
    assert(status.ok && status.err !== null,
7
 
           "Expected not-OK status object; found " + tojson(status));
8
 
}
9
 
 
10
5
var adminDB = conn.getDB("admin");
11
6
var testDB = conn.getDB("test");
12
 
adminDB.addUser({user:'admin', pwd:'x', roles:['userAdminAnyDatabase']});
 
7
adminDB.createUser({user:'admin', pwd:'x', roles:['userAdminAnyDatabase']});
13
8
adminDB.auth('admin','x');
14
 
adminDB.addUser({user:'mallory', pwd:'x', roles:[], otherDBRoles:{test:['readWrite']}});
15
 
testDB.addUser({user:'user1', pwd:'x', roles:['read']});
16
 
testDB.addUser({user:'user2', pwd:'x', roles:['read']});
17
 
assert.eq(2, testDB.system.users.count());
 
9
adminDB.createUser({user:'mallory', pwd:'x', roles:['readWriteAnyDatabase']});
 
10
testDB.createUser({user:'user', pwd:'x', roles:['read']});
 
11
assert.eq(3, adminDB.system.users.count());
18
12
adminDB.logout();
19
13
 
20
14
adminDB.auth('mallory', 'x');
21
 
testDB.system.users.createIndex({haxx:1}, {unique:true, dropDups:true});
22
 
assertGLENotOK(testDB.getLastErrorObj());
23
 
testDB.exploit.system.indexes.insert({ns: "test.system.users", key: { haxx: 1.0 }, name: "haxx_1",
24
 
                                      unique: true, dropDups: true});
25
 
assertGLENotOK(testDB.getLastErrorObj());
 
15
var res = adminDB.system.users.createIndex({ haxx: 1 }, { unique: true, dropDups: true });
 
16
assert(!res.ok);
 
17
assert.eq(13, res.code); // unauthorized
 
18
assert.writeError(adminDB.exploit.system.indexes.insert({ ns: "admin.system.users",
 
19
                                                          key: { haxx: 1.0 },
 
20
                                                          name: "haxx_1",
 
21
                                                          unique: true,
 
22
                                                          dropDups: true }));
26
23
// Make sure that no indexes were built.
27
24
assert.eq(null,
28
 
          testDB.system.namespaces.findOne(
29
 
              {$and : [{name : /^test\.system\.users\.\$/},
30
 
                       {name : {$ne : "test.system.users.$_id_"}},
31
 
                       {name : {$ne : "test.system.users.$user_1_userSource_1"}} ]}));
 
25
          adminDB.system.namespaces.findOne(
 
26
              {$and : [{name : /^admin\.system\.users\.\$/},
 
27
                       {name : {$ne : "admin.system.users.$_id_"}},
 
28
                       {name : {$ne : "admin.system.users.$user_1_db_1"}} ]}));
32
29
adminDB.logout();
33
30
 
34
31
adminDB.auth('admin','x');
35
32
// Make sure that no users were actually dropped
36
 
assert.eq(2, testDB.system.users.count());
 
 
b'\\ No newline at end of file'
 
33
assert.eq(3, adminDB.system.users.count());