summaryrefslogtreecommitdiff
path: root/jstests/auth/user_defined_roles.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/auth/user_defined_roles.js')
-rw-r--r--jstests/auth/user_defined_roles.js27
1 files changed, 12 insertions, 15 deletions
diff --git a/jstests/auth/user_defined_roles.js b/jstests/auth/user_defined_roles.js
index 0190ad9385e..c786018dbb5 100644
--- a/jstests/auth/user_defined_roles.js
+++ b/jstests/auth/user_defined_roles.js
@@ -12,8 +12,8 @@ function runTest(conn) {
conn.getDB('admin').createUser({user: 'admin', pwd: 'pwd', roles: ['root']});
conn.getDB('admin').auth('admin', 'pwd');
- conn.getDB('admin')
- .createUser({user: 'userAdmin', pwd: 'pwd', roles: ['userAdminAnyDatabase']});
+ conn.getDB('admin').createUser(
+ {user: 'userAdmin', pwd: 'pwd', roles: ['userAdminAnyDatabase']});
conn.getDB('admin').logout();
var userAdminConn = new Mongo(conn.host);
@@ -99,12 +99,11 @@ function runTest(conn) {
testDB.updateUser('testUser', {customData: {zipCode: 10036}});
});
assert.eq(null, testDB.getUser('testUser').customData);
- testUserAdmin.grantPrivilegesToRole(
- 'testRole1',
- [{
- resource: {db: 'test', collection: ''},
- actions: ['changeOwnPassword', 'changeOwnCustomData']
- }]);
+ testUserAdmin.grantPrivilegesToRole('testRole1',
+ [{
+ resource: {db: 'test', collection: ''},
+ actions: ['changeOwnPassword', 'changeOwnCustomData']
+ }]);
testDB.changeUserPassword('testUser', 'password');
assert(!testDB.auth('testUser', 'pwd'));
assert(testDB.auth('testUser', 'password'));
@@ -124,11 +123,9 @@ function runTest(conn) {
assert.eq(10036, testDB.getUser('testUser').customData.zipCode);
// Test changeAnyPassword/changeAnyCustomData
- testUserAdmin.grantPrivilegesToRole('testRole2',
- [{
- resource: {db: 'test', collection: ''},
- actions: ['changePassword', 'changeCustomData']
- }]);
+ testUserAdmin.grantPrivilegesToRole('testRole2', [
+ {resource: {db: 'test', collection: ''}, actions: ['changePassword', 'changeCustomData']}
+ ]);
testDB.changeUserPassword('testUser', 'pwd');
assert(!testDB.auth('testUser', 'password'));
assert(testDB.auth('testUser', 'pwd'));
@@ -137,8 +134,8 @@ function runTest(conn) {
// Test privileges on the cluster resource
assert.commandFailed(testDB.runCommand({serverStatus: 1}));
- adminUserAdmin.grantPrivilegesToRole(
- 'adminRole', [{resource: {cluster: true}, actions: ['serverStatus']}]);
+ adminUserAdmin.grantPrivilegesToRole('adminRole',
+ [{resource: {cluster: true}, actions: ['serverStatus']}]);
assert.commandWorked(testDB.serverStatus());
}