summaryrefslogtreecommitdiff
path: root/jstests/auth/clac_system_colls.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/auth/clac_system_colls.js')
-rw-r--r--jstests/auth/clac_system_colls.js53
1 files changed, 30 insertions, 23 deletions
diff --git a/jstests/auth/clac_system_colls.js b/jstests/auth/clac_system_colls.js
index 3f1782cfbb9..527f6c29e5d 100644
--- a/jstests/auth/clac_system_colls.js
+++ b/jstests/auth/clac_system_colls.js
@@ -9,53 +9,60 @@ function runTest(admindb) {
admindb.createUser({user: "admin", pwd: "pwd", roles: ["userAdminAnyDatabase"]});
assert.eq(1, admindb.auth("admin", "pwd"));
- var sysCollections = ["system.indexes", "system.js", "system.namespaces",
- "system.profile", "system.roles", "system.users"];
+ var sysCollections = [
+ "system.indexes",
+ "system.js",
+ "system.namespaces",
+ "system.profile",
+ "system.roles",
+ "system.users"
+ ];
var sysPrivs = new Array();
for (var i in sysCollections) {
- sysPrivs.push({resource: {db:admindb.getName(), collection:sysCollections[i]},
- actions:['find']});
+ sysPrivs.push(
+ {resource: {db: admindb.getName(), collection: sysCollections[i]}, actions: ['find']});
}
- var findPriv = {resource: {db:admindb.getName(), collection:""},
- actions:['find']};
+ var findPriv = {
+ resource: {db: admindb.getName(), collection: ""},
+ actions: ['find']
+ };
- admindb.createRole({role:"FindInDB",
- roles:[],
- privileges:[findPriv]});
- admindb.createRole({role:"FindOnSysRes",
- roles:[],
- privileges:sysPrivs});
+ admindb.createRole({role: "FindInDB", roles: [], privileges: [findPriv]});
+ admindb.createRole({role: "FindOnSysRes", roles: [], privileges: sysPrivs});
-
- admindb.createUser({user:"sysUser", pwd:"pwd", roles:["FindOnSysRes"]});
- admindb.createUser({user:"user", pwd:"pwd", roles:["FindInDB"]});
+ admindb.createUser({user: "sysUser", pwd: "pwd", roles: ["FindOnSysRes"]});
+ admindb.createUser({user: "user", pwd: "pwd", roles: ["FindInDB"]});
// Verify the find on all collections exludes system collections
- assert.eq(1,admindb.auth("user", "pwd"));
+ assert.eq(1, admindb.auth("user", "pwd"));
- assert.doesNotThrow(function() {admindb.foo.findOne();});
+ assert.doesNotThrow(function() {
+ admindb.foo.findOne();
+ });
for (var i in sysCollections) {
- assert.commandFailed(admindb.runCommand({count:sysCollections[i]}));
+ assert.commandFailed(admindb.runCommand({count: sysCollections[i]}));
}
// Verify that find on system collections gives find permissions
- assert.eq(1,admindb.auth("sysUser", "pwd"));
+ assert.eq(1, admindb.auth("sysUser", "pwd"));
- assert.throws(function() {admindb.foo.findOne();});
+ assert.throws(function() {
+ admindb.foo.findOne();
+ });
for (var i in sysCollections) {
- assert.commandWorked(admindb.runCommand({count:sysCollections[i]}));
+ assert.commandWorked(admindb.runCommand({count: sysCollections[i]}));
}
admindb.logout();
}
jsTest.log('Test standalone');
-var conn = MongoRunner.runMongod({ auth:'' });
+var conn = MongoRunner.runMongod({auth: ''});
runTest(conn.getDB("admin"));
MongoRunner.stopMongod(conn.port);
jsTest.log('Test sharding');
-var st = new ShardingTest({ shards:2, config:3, keyFile:'jstests/libs/key1' });
+var st = new ShardingTest({shards: 2, config: 3, keyFile: 'jstests/libs/key1'});
runTest(st.s.getDB("admin"));
st.stop();