diff options
56 files changed, 159 insertions, 139 deletions
diff --git a/jstests/auth/auth1.js b/jstests/auth/auth1.js index 9419230869d..a7b67cdb04b 100644 --- a/jstests/auth/auth1.js +++ b/jstests/auth/auth1.js @@ -18,10 +18,10 @@ tRO = dbRO[ baseName ]; db.dropAllUsers(); -db.getSisterDB( "admin" ).addUser({user: "super", pwd: "super", roles: ["__system"] }); +db.getSisterDB( "admin" ).createUser({user: "super", pwd: "super", roles: ["__system"] }); db.getSisterDB("admin").auth("super", "super"); -db.addUser({user: "eliot" , pwd: "eliot", roles: jsTest.basicUserRoles }); -db.addUser({user: "guest" , pwd: "guest", roles: jsTest.readOnlyUserRoles}); +db.createUser({user: "eliot" , pwd: "eliot", roles: jsTest.basicUserRoles }); +db.createUser({user: "guest" , pwd: "guest", roles: jsTest.readOnlyUserRoles}); db.getSisterDB("admin").logout(); assert.throws( function() { t.findOne() }, [], "read without login" ); diff --git a/jstests/auth/auth2.js b/jstests/auth/auth2.js index 9e070e0bb68..84b7a0c7fd2 100644 --- a/jstests/auth/auth2.js +++ b/jstests/auth/auth2.js @@ -12,7 +12,7 @@ t.drop(); users = db.getCollection( "system.users" ); assert.eq( 0 , users.count() ); -db.addUser({user: "eliot" , pwd: "eliot", roles: jsTest.adminUserRoles}); +db.createUser({user: "eliot" , pwd: "eliot", roles: jsTest.adminUserRoles}); assert.throws( function(){ db.users.count(); } ) diff --git a/jstests/auth/auth3.js b/jstests/auth/auth3.js index b4ac14593a7..3bd518bffb4 100644 --- a/jstests/auth/auth3.js +++ b/jstests/auth/auth3.js @@ -2,7 +2,7 @@ var conn = MongoRunner.runMongod({auth : "", port : 31001}); var admin = conn.getDB("admin"); -admin.addUser({user:"foo",pwd: "bar", roles: jsTest.adminUserRoles}); +admin.createUser({user:"foo",pwd: "bar", roles: jsTest.adminUserRoles}); print("make sure curop, killop, and unlock fail"); diff --git a/jstests/auth/auth_helpers.js b/jstests/auth/auth_helpers.js index f36b8c12c1e..d97e37e2d2f 100644 --- a/jstests/auth/auth_helpers.js +++ b/jstests/auth/auth_helpers.js @@ -27,7 +27,7 @@ var admin = conn.getDB('admin'); var testedSomething = false; -admin.addUser({user:'andy', pwd: 'a', roles: jsTest.adminUserRoles}); +admin.createUser({user:'andy', pwd: 'a', roles: jsTest.adminUserRoles}); // If the server supports them MONGODB-CR, try all the ways to call db.auth that use MONGODB-CR. if (hasMongoCR) { diff --git a/jstests/auth/basic_role_auth.js b/jstests/auth/basic_role_auth.js index 747ecba9eae..c25adb34330 100644 --- a/jstests/auth/basic_role_auth.js +++ b/jstests/auth/basic_role_auth.js @@ -193,7 +193,7 @@ var testOps = function(db, allowedActions) { }); checkErr(allowedActions.hasOwnProperty('user_w'), function() { - db.addUser({user:'a', pwd: 'a', roles: jsTest.basicUserRoles}); + db.createUser({user:'a', pwd: 'a', roles: jsTest.basicUserRoles}); db.dropUser('a'); }, db); @@ -486,8 +486,8 @@ var runTests = function(conn) { adminDB.kill_cursor.insert({ x: x }); } - adminDB.addUser({ user: 'root', pwd: AUTH_INFO.admin.root.pwd, - roles: AUTH_INFO.admin.root.roles }); + adminDB.createUser({ user: 'root', pwd: AUTH_INFO.admin.root.pwd, + roles: AUTH_INFO.admin.root.roles }); adminDB.auth('root', AUTH_INFO.admin.root.pwd); for (var dbName in AUTH_INFO) { @@ -500,7 +500,7 @@ var runTests = function(conn) { } var info = dbObj[userName]; - conn.getDB(dbName).addUser({ user: userName, + conn.getDB(dbName).createUser({ user: userName, pwd: info.pwd, roles: info.roles }); } } diff --git a/jstests/auth/commands_builtin_roles.js b/jstests/auth/commands_builtin_roles.js index 11dd02819a0..aa627ec4091 100644 --- a/jstests/auth/commands_builtin_roles.js +++ b/jstests/auth/commands_builtin_roles.js @@ -97,7 +97,7 @@ function runOneTest(conn, t) { function createUsers(conn) { var adminDb = conn.getDB(adminDbName); - adminDb.addUser({ + adminDb.createUser({ user: "admin", pwd: "password", roles: ["__system"] @@ -107,7 +107,7 @@ function createUsers(conn) { for (var i = 0; i < roles.length; i++) { r = roles[i]; r.db = conn.getDB(r.dbname); - r.db.addUser({user: "user|" + r.role, pwd: "password", roles: [r.role]}); + r.db.createUser({user: "user|" + r.role, pwd: "password", roles: [r.role]}); } adminDb.logout(); } diff --git a/jstests/auth/commands_user_defined_roles.js b/jstests/auth/commands_user_defined_roles.js index 0c258138eee..fd6b6aafe91 100644 --- a/jstests/auth/commands_user_defined_roles.js +++ b/jstests/auth/commands_user_defined_roles.js @@ -143,7 +143,7 @@ function runOneTest(conn, t) { function createUsers(conn) { var adminDb = conn.getDB(adminDbName); var firstDb = conn.getDB(firstDbName); - adminDb.addUser({ + adminDb.createUser({ user: "admin", pwd: "password", roles: ["__system"] diff --git a/jstests/auth/copyauth.js b/jstests/auth/copyauth.js index d82f5b22093..c84a22fda92 100644 --- a/jstests/auth/copyauth.js +++ b/jstests/auth/copyauth.js @@ -11,10 +11,10 @@ var baseName = "jstests_clone_copyauth"; var source = startMongod( "--auth", "--port", ports[ 0 ], "--dbpath", MongoRunner.dataPath + baseName + "_source", "--nohttpinterface", "--bind_ip", "127.0.0.1", "--smallfiles" ); var target = startMongod( "--port", ports[ 1 ], "--dbpath", MongoRunner.dataPath + baseName + "_target", "--nohttpinterface", "--bind_ip", "127.0.0.1", "--smallfiles" ); -source.getDB( "admin" ).addUser( "super", "super" ); +source.getDB( "admin" ).createUser({user: "super", pwd: "super", roles: jsTest.adminUserRoles}); source.getDB( "admin" ).auth( "super", "super" ); source.getDB( baseName )[ baseName ].save( {i:1} ); -source.getDB( baseName ).addUser( "foo", "bar" ); +source.getDB( baseName ).createUser({user: "foo", pwd: "bar", roles: jsTest.basicUserRoles}); source.getDB( "admin" ).logout(); assert.throws( function() { source.getDB( baseName )[ baseName ].findOne(); } ); @@ -31,7 +31,7 @@ assert.eq( 1, target.getDB( baseName )[ baseName ].findOne().i ); stopMongod( ports[ 1 ] ); var target = startMongod( "--auth", "--port", ports[ 1 ], "--dbpath", MongoRunner.dataPath + baseName + "_target", "--nohttpinterface", "--bind_ip", "127.0.0.1", "--smallfiles" ); -target.getDB( "admin" ).addUser( "super1", "super1" ); +target.getDB( "admin" ).createUser({user: "super1", pwd: "super1", roles: jsTest.adminUserRoles}); assert.throws( function() { source.getDB( baseName )[ baseName ].findOne(); } ); target.getDB( "admin" ).auth( "super1", "super1" ); diff --git a/jstests/auth/db_multiple_login.js b/jstests/auth/db_multiple_login.js index 8f72499a051..44aa496441c 100644 --- a/jstests/auth/db_multiple_login.js +++ b/jstests/auth/db_multiple_login.js @@ -33,10 +33,10 @@ var conn = MongoRunner.runMongod({ auth: "", smallfiles: "" }); var admin = conn.getDB("admin"); var test = conn.getDB("test"); -admin.addUser({user:'admin', pwd: 'a', roles: jsTest.adminUserRoles}); +admin.createUser({user:'admin', pwd: 'a', roles: jsTest.adminUserRoles}); assert(admin.auth('admin', 'a')); -test.addUser({user: 'reader', pwd: 'a', roles: [ "read" ]}); -test.addUser({user: 'writer', pwd: 'a', roles: [ "readWrite" ]}); +test.createUser({user: 'reader', pwd: 'a', roles: [ "read" ]}); +test.createUser({user: 'writer', pwd: 'a', roles: [ "readWrite" ]}); admin.logout(); // Nothing logged in, can neither read nor write. diff --git a/jstests/auth/indexSystemUsers.js b/jstests/auth/indexSystemUsers.js index 0ab2a0d2729..d8979dc89ae 100644 --- a/jstests/auth/indexSystemUsers.js +++ b/jstests/auth/indexSystemUsers.js @@ -9,10 +9,10 @@ function assertGLENotOK(status) { var adminDB = conn.getDB("admin"); var testDB = conn.getDB("test"); -adminDB.addUser({user:'admin', pwd:'x', roles:['userAdminAnyDatabase']}); +adminDB.createUser({user:'admin', pwd:'x', roles:['userAdminAnyDatabase']}); adminDB.auth('admin','x'); -adminDB.addUser({user:'mallory', pwd:'x', roles:['readWriteAnyDatabase']}); -testDB.addUser({user:'user', pwd:'x', roles:['read']}); +adminDB.createUser({user:'mallory', pwd:'x', roles:['readWriteAnyDatabase']}); +testDB.createUser({user:'user', pwd:'x', roles:['read']}); assert.eq(3, adminDB.system.users.count()); adminDB.logout(); diff --git a/jstests/auth/js_scope_leak.js b/jstests/auth/js_scope_leak.js index 59f384b44fd..e418157c195 100644 --- a/jstests/auth/js_scope_leak.js +++ b/jstests/auth/js_scope_leak.js @@ -14,8 +14,8 @@ var test = conn.getDB("test"); test.foo.insert({a:1}); test.getLastError(); assert.eq(1, test.foo.findOne().a); -test.addUser({user:'a', pwd: 'a', roles: jsTest.basicUserRoles}); -test.addUser({user:'b', pwd: 'b', roles: jsTest.basicUserRoles}); +test.createUser({user:'a', pwd: 'a', roles: jsTest.basicUserRoles}); +test.createUser({user:'b', pwd: 'b', roles: jsTest.basicUserRoles}); function missingOrEquals(string) { return 'function() { ' diff --git a/jstests/auth/localhostAuthBypass.js b/jstests/auth/localhostAuthBypass.js index 8d5c140fdc8..2df205d4489 100644 --- a/jstests/auth/localhostAuthBypass.js +++ b/jstests/auth/localhostAuthBypass.js @@ -10,9 +10,9 @@ var password = "bar"; var port = allocatePorts(1)[0]; var host = "localhost:" + port; -var addUser = function(mongo) { +var createUser = function(mongo) { print("============ adding a user."); - mongo.getDB("admin").addUser({user:username,pwd: password, roles: jsTest.adminUserRoles}); + mongo.getDB("admin").createUser({user:username,pwd: password, roles: jsTest.adminUserRoles}); }; var assertCannotRunCommands = function(mongo) { @@ -83,7 +83,7 @@ var runTest = function(useHostName) { assertCanRunCommands(mongo); - addUser(mongo); + createUser(mongo); assertCannotRunCommands(mongo); diff --git a/jstests/auth/log_user_basic.js b/jstests/auth/log_user_basic.js index ff088b53125..82702fc4756 100644 --- a/jstests/auth/log_user_basic.js +++ b/jstests/auth/log_user_basic.js @@ -77,7 +77,7 @@ var doTest = function(conn1, conn2) { var loginUser = function(connInfo, connAuth) { var db = connInfo.mongo.getDB(connAuth.db); - db.addUser({user: connAuth.user, pwd: connAuth.pwd, roles: jsTest.adminUserRoles}); + db.createUser({user: connAuth.user, pwd: connAuth.pwd, roles: jsTest.adminUserRoles}); db.auth(connAuth.user, connAuth.pwd); connInfo.users[connAuth.db] = connAuth.user; }; diff --git a/jstests/auth/log_userid_off.js b/jstests/auth/log_userid_off.js index a42213fd97e..abebda28709 100644 --- a/jstests/auth/log_userid_off.js +++ b/jstests/auth/log_userid_off.js @@ -8,7 +8,7 @@ var doTest = function (mongo, callSetParam) { var TEST_PWD = 'bar'; var testDB = mongo.getDB('test'); - testDB.addUser({user: TEST_USER, pwd: TEST_PWD, roles: jsTest.basicUserRoles}); + testDB.createUser({user: TEST_USER, pwd: TEST_PWD, roles: jsTest.basicUserRoles}); testDB.auth(TEST_USER, TEST_PWD); testDB.runCommand({ dbStats: 1 }); diff --git a/jstests/auth/logout_reconnect.js b/jstests/auth/logout_reconnect.js index 775c3010920..20d46836780 100644 --- a/jstests/auth/logout_reconnect.js +++ b/jstests/auth/logout_reconnect.js @@ -15,9 +15,9 @@ conn = MongoRunner.runMongod({ // create user with rw permissions and login var testDB = conn.getDB('test'); var adminDB = conn.getDB('admin'); -adminDB.addUser({user:'admin', pwd:'admin', roles:['userAdminAnyDatabase']}); +adminDB.createUser({user:'admin', pwd:'admin', roles:['userAdminAnyDatabase']}); adminDB.auth('admin','admin'); -testDB.addUser({user:'rwuser', pwd:'rwuser', roles:['readWrite']}) +testDB.createUser({user:'rwuser', pwd:'rwuser', roles:['readWrite']}) adminDB.logout(); testDB.auth('rwuser', 'rwuser'); diff --git a/jstests/auth/mr_auth.js b/jstests/auth/mr_auth.js index a9945b515c5..9e61cdcde4d 100644 --- a/jstests/auth/mr_auth.js +++ b/jstests/auth/mr_auth.js @@ -21,10 +21,10 @@ for( var i = 0; i < 1000; i++) t.insert( {_id:i, x:i%10, y:i%100} ); assert.eq( 1000, t.count(), "inserts failed" ); d.dropAllUsers(); -d.getSisterDB( "admin" ).addUser({user: "admin", pwd: "admin", roles: jsTest.adminUserRoles }); +d.getSisterDB( "admin" ).createUser({user: "admin", pwd: "admin", roles: jsTest.adminUserRoles }); d.getSisterDB( "admin" ).auth('admin', 'admin'); -d.addUser({user: "write" , pwd: "write", roles: jsTest.basicUserRoles}); -d.addUser({user: "read" , pwd: "read", roles: jsTest.readOnlyUserRoles}); +d.createUser({user: "write" , pwd: "write", roles: jsTest.basicUserRoles}); +d.createUser({user: "read" , pwd: "read", roles: jsTest.readOnlyUserRoles}); d.getSisterDB( "admin" ).logout(); t.mapReduce( map, red, {out: { inline: 1 }} ) diff --git a/jstests/auth/profile.js b/jstests/auth/profile.js index 9b828c24470..43e32b0dc58 100644 --- a/jstests/auth/profile.js +++ b/jstests/auth/profile.js @@ -3,8 +3,8 @@ var conn = startMongodTest(); var db1 = conn.getDB("profile-a"); var db2 = db1.getSisterDB("profile-b"); var username = "user"; -db1.addUser({user:username, pwd: "password", roles: jsTest.basicUserRoles}); -db2.addUser({user:username, pwd: "password", roles: jsTest.basicUserRoles}); +db1.createUser({user:username, pwd: "password", roles: jsTest.basicUserRoles}); +db2.createUser({user:username, pwd: "password", roles: jsTest.basicUserRoles}); function lastOp(db) { diff --git a/jstests/auth/readIndex.js b/jstests/auth/readIndex.js index 379d82e8ae8..8ef52d1b5e1 100644 --- a/jstests/auth/readIndex.js +++ b/jstests/auth/readIndex.js @@ -6,9 +6,9 @@ var testDB = conn.getDB("testdb"); testDB.foo.insert({a:1}); -testDB.addUser({user:'dbAdmin', - pwd:'password', - roles:['dbAdmin']}); +testDB.createUser({user:'dbAdmin', + pwd:'password', + roles:['dbAdmin']}); testDB.auth('dbAdmin', 'password'); testDB.foo.ensureIndex({a:1}); diff --git a/jstests/auth/readProfile.js b/jstests/auth/readProfile.js index 1b6ac67c7d7..8f782ecf5ac 100644 --- a/jstests/auth/readProfile.js +++ b/jstests/auth/readProfile.js @@ -3,12 +3,12 @@ var conn = MongoRunner.runMongod({auth : ""}); var adminDb = conn.getDB("admin"); var testDb = conn.getDB("testdb"); -adminDb.addUser({user:'admin', - pwd:'password', - roles:['userAdminAnyDatabase','dbAdminAnyDatabase', 'readWriteAnyDatabase']}); +adminDb.createUser({user:'admin', + pwd:'password', + roles:['userAdminAnyDatabase','dbAdminAnyDatabase', 'readWriteAnyDatabase']}); adminDb.auth('admin','password'); -testDb.addUser({user:'readUser',pwd:'password',roles:['read']}); +testDb.createUser({user:'readUser',pwd:'password',roles:['read']}); testDb.setProfilingLevel(2); adminDb.logout(); testDb.auth('readUser','password'); diff --git a/jstests/auth/rename.js b/jstests/auth/rename.js index 0cdf191ef26..1ed0e584811 100644 --- a/jstests/auth/rename.js +++ b/jstests/auth/rename.js @@ -10,11 +10,11 @@ db2 = m.getDB( baseName + '_other' ) admin = m.getDB( 'admin' ) // Setup initial data -admin.addUser({user:'admin', pwd: 'password', roles: jsTest.adminUserRoles}); +admin.createUser({user:'admin', pwd: 'password', roles: jsTest.adminUserRoles}); admin.auth('admin', 'password') -db1.addUser({user: "foo", pwd: "bar", roles: jsTest.basicUserRoles}); -db2.addUser({user: "bar", pwd: "foo", roles: jsTest.basicUserRoles}); +db1.createUser({user: "foo", pwd: "bar", roles: jsTest.basicUserRoles}); +db2.createUser({user: "bar", pwd: "foo", roles: jsTest.basicUserRoles}); printjson(db1.a.count()); db1.a.save({}); diff --git a/jstests/auth/renameSystemCollections.js b/jstests/auth/renameSystemCollections.js index 6186117552c..4537c1e0da4 100644 --- a/jstests/auth/renameSystemCollections.js +++ b/jstests/auth/renameSystemCollections.js @@ -9,19 +9,19 @@ var CodeUnauthorized = 13; var backdoorUserDoc = { user: 'backdoor', db: 'admin', pwd: 'hashed', roles: ['root'] } -adminDB.addUser({user:'userAdmin', - pwd:'password', - roles:['userAdminAnyDatabase']}); +adminDB.createUser({user:'userAdmin', + pwd:'password', + roles:['userAdminAnyDatabase']}); adminDB.auth('userAdmin', 'password'); -adminDB.addUser({user:'readWriteAdmin', - pwd:'password', - roles:['readWriteAnyDatabase']}); -adminDB.addUser({user:'readWriteAndUserAdmin', - pwd:'password', - roles:['readWriteAnyDatabase', 'userAdminAnyDatabase']}); -adminDB.addUser({user: 'root', pwd: 'password', roles: ['root']}); -adminDB.addUser({user: 'rootier', pwd: 'password', roles: ['__system']}); +adminDB.createUser({user:'readWriteAdmin', + pwd:'password', + roles:['readWriteAnyDatabase']}); +adminDB.createUser({user:'readWriteAndUserAdmin', + pwd:'password', + roles:['readWriteAnyDatabase', 'userAdminAnyDatabase']}); +adminDB.createUser({user: 'root', pwd: 'password', roles: ['root']}); +adminDB.createUser({user: 'rootier', pwd: 'password', roles: ['__system']}); adminDB.logout(); diff --git a/jstests/auth/server-4892.js b/jstests/auth/server-4892.js index bec2baf7e85..f8bafed82f3 100644 --- a/jstests/auth/server-4892.js +++ b/jstests/auth/server-4892.js @@ -49,9 +49,9 @@ with_mongod( ['--noauth'], function setupTest( mongod ) { conn = new Mongo( mongod.host ); admin = conn.getDB( 'admin' ); somedb = conn.getDB( 'somedb' ); - admin.addUser({user: 'admin', pwd: 'admin', roles: jsTest.adminUserRoles}); + admin.createUser({user: 'admin', pwd: 'admin', roles: jsTest.adminUserRoles}); admin.auth('admin', 'admin'); - somedb.addUser({user: 'frim', pwd: 'fram', roles: jsTest.basicUserRoles}); + somedb.createUser({user: 'frim', pwd: 'fram', roles: jsTest.basicUserRoles}); somedb.data.drop(); for (var i = 0; i < 10; ++i) { somedb.data.insert( { val: i } ); diff --git a/jstests/auth/show_log_auth.js b/jstests/auth/show_log_auth.js index 11c795b7593..dfc5c736714 100644 --- a/jstests/auth/show_log_auth.js +++ b/jstests/auth/show_log_auth.js @@ -6,7 +6,7 @@ var baseName = "jstests_show_log_auth"; var m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" , "--nojournal" , "--smallfiles" ); var db = m.getDB( "admin" ); -db.addUser({user: "admin" , pwd: "pass", roles: jsTest.adminUserRoles}); +db.createUser({user: "admin" , pwd: "pass", roles: jsTest.adminUserRoles}); // Temporarily capture this shell's print() output var oldprint = print, printed = []; diff --git a/jstests/auth/system_user_privileges.js b/jstests/auth/system_user_privileges.js index d77952e446b..7a3ab75f352 100644 --- a/jstests/auth/system_user_privileges.js +++ b/jstests/auth/system_user_privileges.js @@ -35,7 +35,7 @@ // // Preliminary set up. // - admin.addUser({user:'admin', pwd: 'a', roles: jsTest.adminUserRoles}); + admin.createUser({user:'admin', pwd: 'a', roles: jsTest.adminUserRoles}); admin.auth('admin', 'a'); // @@ -43,10 +43,10 @@ // add one on "local" // - test.addUser({user: '__system', pwd: 'a', roles: []}); - admin.addUser({user: '__system', pwd: 'a', roles: []}); + test.createUser({user: '__system', pwd: 'a', roles: []}); + admin.createUser({user: '__system', pwd: 'a', roles: []}); assert.throws(function() { - local.addUser({user: '__system', pwd: 'a', roles: []}); + local.createUser({user: '__system', pwd: 'a', roles: []}); }); // diff --git a/jstests/auth1.js b/jstests/auth1.js index 97732fa1a67..4ab26e8d2e5 100644 --- a/jstests/auth1.js +++ b/jstests/auth1.js @@ -4,7 +4,7 @@ mydb.dropAllUsers(); pass = "a" + Math.random(); //print( "password [" + pass + "]" ); -mydb.addUser({user: "eliot" ,pwd: pass, roles: jsTest.basicUserRoles}); +mydb.createUser({user: "eliot" ,pwd: pass, roles: jsTest.basicUserRoles}); assert( mydb.auth( "eliot" , pass ) , "auth failed" ); assert( ! mydb.auth( "eliot" , pass + "a" ) , "auth should have failed" ); @@ -23,14 +23,14 @@ assert( ! mydb.auth( "eliot" , pass2 ) , "didn't drop user" ); var a = mydb.getMongo().getDB( "admin" ); a.dropAllUsers(); pass = "c" + Math.random(); -a.addUser({user: "super", pwd: pass, roles: jsTest.adminUserRoles}); +a.createUser({user: "super", pwd: pass, roles: jsTest.adminUserRoles}); assert( a.auth( "super" , pass ) , "auth failed" ); assert( !a.auth( "super" , pass + "a" ) , "auth should have failed" ); mydb.dropAllUsers(); pass = "a" + Math.random(); -mydb.addUser({user: "eliot" , pwd: pass, roles: jsTest.basicUserRoles}); +mydb.createUser({user: "eliot" , pwd: pass, roles: jsTest.basicUserRoles}); assert.commandFailed( mydb.runCommand( { authenticate: 1, user: "eliot", nonce: "foo", key: "bar" } ) ); @@ -39,10 +39,10 @@ assert.commandFailed( mydb.runCommand( { authenticate: 1, user: "eliot", nonce: var before = a.system.users.count({db: mydb.getName()}); assert.throws( function(){ - mydb.addUser({ user: "" , pwd: "abc", roles: jsTest.basicUserRoles}); + mydb.createUser({ user: "" , pwd: "abc", roles: jsTest.basicUserRoles}); } , null , "C1" ) assert.throws( function(){ - mydb.addUser({ user: "abc" , pwd: "", roles: jsTest.basicUserRoles}); + mydb.createUser({ user: "abc" , pwd: "", roles: jsTest.basicUserRoles}); } , null , "C2" ) diff --git a/jstests/auth_copydb2.js b/jstests/auth_copydb2.js index 0503ad2f0d5..f04cd0b0d29 100644 --- a/jstests/auth_copydb2.js +++ b/jstests/auth_copydb2.js @@ -8,7 +8,7 @@ b.dropAllUsers(); a.foo.save( { a : 1 } ); -a.addUser({user: "chevy" , pwd: "chase", roles: jsTest.basicUserRoles}); +a.createUser({user: "chevy" , pwd: "chase", roles: jsTest.basicUserRoles}); assert.eq( 1 , a.foo.count() , "A" ); assert.eq( 0 , b.foo.count() , "B" ); diff --git a/jstests/connection_status.js b/jstests/connection_status.js index 1ef12988b75..08d05cbf28d 100644 --- a/jstests/connection_status.js +++ b/jstests/connection_status.js @@ -5,7 +5,7 @@ var myDB = db.getSiblingDB(dbName); myDB.dropAllUsers(); function test(userName) { - myDB.addUser({user: userName, pwd: "weak password", roles: jsTest.basicUserRoles}); + myDB.createUser({user: userName, pwd: "weak password", roles: jsTest.basicUserRoles}); myDB.auth(userName, "weak password"); var output = myDB.runCommand("connectionStatus"); diff --git a/jstests/evalb.js b/jstests/evalb.js index 4d655785397..0caae39498b 100644 --- a/jstests/evalb.js +++ b/jstests/evalb.js @@ -16,7 +16,7 @@ function lastOp() { try { username = 'jstests_evalb_user'; - db.addUser({user: username, pwd: 'password', roles: jsTest.basicUserRoles}); + db.createUser({user: username, pwd: 'password', roles: jsTest.basicUserRoles}); db.auth( username, 'password' ); t = db.evalb; diff --git a/jstests/profile1.js b/jstests/profile1.js index cc36cbb74dd..f72cdb9795d 100644 --- a/jstests/profile1.js +++ b/jstests/profile1.js @@ -18,7 +18,7 @@ db.dropDatabase(); try { username = "jstests_profile1_user"; - db.addUser({user: username, pwd: "password", roles: jsTest.basicUserRoles}); + db.createUser({user: username, pwd: "password", roles: jsTest.basicUserRoles}); db.auth( username, "password" ); function profileCursor( query ) { diff --git a/jstests/profile3.js b/jstests/profile3.js index 538bb2ece5d..a7072be235c 100644 --- a/jstests/profile3.js +++ b/jstests/profile3.js @@ -16,7 +16,7 @@ profileCursor = function( query ) { try { username = "jstests_profile3_user"; - db.addUser({user: username, pwd: "password", roles: jsTest.basicUserRoles}); + db.createUser({user: username, pwd: "password", roles: jsTest.basicUserRoles}); db.auth( username, "password" ); db.setProfilingLevel(0); diff --git a/jstests/profile4.js b/jstests/profile4.js index 9294b26ab33..445a4f20ede 100644 --- a/jstests/profile4.js +++ b/jstests/profile4.js @@ -31,7 +31,7 @@ function checkLastOp( spec ) { try { username = "jstests_profile4_user"; - db.addUser({user: username, pwd: "password", roles: jsTest.basicUserRoles}); + db.createUser({user: username, pwd: "password", roles: jsTest.basicUserRoles}); db.auth( username, "password" ); db.setProfilingLevel(0); diff --git a/jstests/repl/repl_auth.js b/jstests/repl/repl_auth.js index 28b7ab89da3..90c8f81f9d0 100644 --- a/jstests/repl/repl_auth.js +++ b/jstests/repl/repl_auth.js @@ -4,7 +4,8 @@ var baseName = "jstests_repl11test"; var keyFilePath = "jstests/libs/key1"; setAdmin = function( n ) { - n.getDB( "admin" ).addUser({user: "super", pwd: "super", roles: jsTest.adminUserRoles}, 3 ); + n.getDB( "admin" ).createUser({user: "super", pwd: "super", roles: jsTest.adminUserRoles}, + {w: 3, wtimeout: 30000}); } auth = function( n ) { @@ -16,7 +17,8 @@ doTest = function(signal, extraOpts) { rt = new ReplTest( baseName ); m = rt.start( true, {}, false, true ); - m.getDB( baseName ).addUser({user: "test", pwd: "test", roles: jsTest.basicUserRoles}, 3 ); + m.getDB( baseName ).createUser({user: "test", pwd: "test", roles: jsTest.basicUserRoles}, + {w: 3, wtimeout: 30000}); setAdmin( m ); rt.stop( true ); diff --git a/jstests/replsets/auth1.js b/jstests/replsets/auth1.js index 513a31b5880..c59a1119b73 100644 --- a/jstests/replsets/auth1.js +++ b/jstests/replsets/auth1.js @@ -36,8 +36,8 @@ run("chmod", "600", path+"key2"); print("add a user to server0: foo"); m = startMongodTest( port[0], name+"-0", 0 ); -m.getDB("admin").addUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}); -m.getDB("test").addUser({user: "bar", pwd: "baz", roles: jsTest.basicUserRoles}); +m.getDB("admin").createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}); +m.getDB("test").createUser({user: "bar", pwd: "baz", roles: jsTest.basicUserRoles}); print("make sure user is written before shutting down"); m.getDB("test").getLastError(); stopMongod(port[0]); diff --git a/jstests/replsets/auth2.js b/jstests/replsets/auth2.js index 7adb93a203e..7d8b329a4ff 100644 --- a/jstests/replsets/auth2.js +++ b/jstests/replsets/auth2.js @@ -84,7 +84,8 @@ var rs = setupReplSet(); var master = rs.getMaster(); print("add an admin user"); -master.getDB("admin").addUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles},3); +master.getDB("admin").createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}, + {w: 3, wtimeout: 30000}); m = rs.nodes[0]; print("starting 1 and 2 with key file"); diff --git a/jstests/replsets/auth3.js b/jstests/replsets/auth3.js index d9bd0e50275..eb597753f32 100644 --- a/jstests/replsets/auth3.js +++ b/jstests/replsets/auth3.js @@ -7,7 +7,8 @@ rs.initiate(); master = rs.getMaster(); print("adding user"); -master.getDB("admin").addUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}, 2); +master.getDB("admin").createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}, + {w: 2, wtimeout: 30000}); var checkValidState = function(i) { assert.soon(function() { diff --git a/jstests/replsets/localhostAuthBypass.js b/jstests/replsets/localhostAuthBypass.js index e171b944afc..ba48c3fd7dd 100644 --- a/jstests/replsets/localhostAuthBypass.js +++ b/jstests/replsets/localhostAuthBypass.js @@ -9,9 +9,9 @@ var memberCount = 3; var username = "foo"; var password = "bar"; -var addUser = function(mongo) { +var createUser = function(mongo) { print("============ adding a user."); - mongo.getDB("admin").addUser({user: username, pwd: password, roles: jsTest.adminUserRoles}); + mongo.getDB("admin").createUser({user: username, pwd: password, roles: jsTest.adminUserRoles}); }; var assertCannotRunCommands = function(mongo) { @@ -97,7 +97,7 @@ var runTest = function(useHostName) { assertCanRunCommands(mongo); - addUser(mongo); + createUser(mongo); assertCannotRunCommands(mongo); diff --git a/jstests/sharding/auth.js b/jstests/sharding/auth.js index 89d7671eea2..b00714eb1b4 100644 --- a/jstests/sharding/auth.js +++ b/jstests/sharding/auth.js @@ -52,7 +52,9 @@ if (user) { } else { print("adding user"); - s.getDB(adminUser.db).addUser({user: adminUser.username, pwd: adminUser.password, roles: jsTest.adminUserRoles}); + s.getDB(adminUser.db).createUser({user: adminUser.username, + pwd: adminUser.password, + roles: jsTest.adminUserRoles}); } login(adminUser); @@ -112,11 +114,14 @@ s.getDB("admin").runCommand({shardCollection : "test.foo", key : {x : 1}}); d1.waitForState( d1.getSecondaries(), d1.SECONDARY, 5 * 60 * 1000 ) -s.getDB(testUser.db).addUser({user: testUser.username, pwd: testUser.password , roles: jsTest.basicUserRoles}, 3 ) -s.getDB(testUserReadOnly.db).addUser(testUserReadOnly.username, - testUserReadOnly.password, - jsTest.readOnlyUserRoles, - 3); +s.getDB(testUser.db).createUser({user: testUser.username, + pwd: testUser.password, + roles: jsTest.basicUserRoles}, + {w: 3, wtimeout: 30000} ) +s.getDB(testUserReadOnly.db).createUser({user: testUserReadOnly.username, + pwd: testUserReadOnly.password, + roles: jsTest.readOnlyUserRoles}, + {w: 3, wtimeout:30000}); logout(adminUser); @@ -238,12 +243,14 @@ logout(adminUser); d2.waitForState( d2.getSecondaries(), d2.SECONDARY, 5 * 60 * 1000 ) // add admin on shard itself, hack to prevent localhost auth bypass -d1.getMaster().getDB(adminUser.db).addUser(adminUser.username, - adminUser.password, - jsTest.adminUserRoles, 3); -d2.getMaster().getDB(adminUser.db).addUser(adminUser.username, - adminUser.password, - jsTest.adminUserRoles, 3); +d1.getMaster().getDB(adminUser.db).createUser({user: adminUser.username, + pwd: adminUser.password, + roles: jsTest.adminUserRoles}, + {w: 3, wtimeout: 30000}); +d2.getMaster().getDB(adminUser.db).createUser({user: adminUser.username, + pwd: adminUser.password, + roles: jsTest.adminUserRoles}, + {w: 3, wtimeout: 30000}); login(testUser); print( "testing map reduce" ); diff --git a/jstests/sharding/auth2.js b/jstests/sharding/auth2.js index 480f5133499..5dd8618ee26 100644 --- a/jstests/sharding/auth2.js +++ b/jstests/sharding/auth2.js @@ -8,7 +8,7 @@ var mongos = st.s; var adminDB = mongos.getDB('admin'); var db = mongos.getDB('test') -adminDB.addUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles}); +adminDB.createUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles}); jsTestLog( "Add user was successful" ); diff --git a/jstests/sharding/authCommands.js b/jstests/sharding/authCommands.js index a8fec8de846..eb4c8267a81 100644 --- a/jstests/sharding/authCommands.js +++ b/jstests/sharding/authCommands.js @@ -24,19 +24,25 @@ var rwUser = 'rwUser'; var roUser = 'roUser'; var password = 'password'; -adminDB.addUser({user: rwUser, pwd: password, roles: jsTest.basicUserRoles}, st.rs0.numNodes ); +adminDB.createUser({user: rwUser, pwd: password, roles: jsTest.basicUserRoles}, st.rs0.numNodes ); assert( adminDB.auth( rwUser, password ) ); -adminDB.addUser( roUser, password, true ); -testDB.addUser({user: rwUser, pwd: password, roles: jsTest.basicUserRoles}, st.rs0.numNodes ); -testDB.addUser({user: roUser, pwd: password, roles: jsTest.basicUserRoles}, st.rs0.numNodes ); +adminDB.createUser( roUser, password, true ); +testDB.createUser({user: rwUser, pwd: password, roles: jsTest.basicUserRoles}, st.rs0.numNodes ); +testDB.createUser({user: roUser, pwd: password, roles: jsTest.basicUserRoles}, st.rs0.numNodes ); authenticatedConn = new Mongo( mongos.host ); authenticatedConn.getDB( 'admin' ).auth( rwUser, password ); // Add user to shards to prevent localhost connections from having automatic full access -st.rs0.getPrimary().getDB( 'admin' ).addUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles}, 3 ); -st.rs1.getPrimary().getDB( 'admin' ).addUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles}, 3 ); +st.rs0.getPrimary().getDB( 'admin' ).createUser({user: 'user', + pwd: 'password', + roles: jsTest.basicUserRoles}, + {w: 3, wtimeout: 30000}); +st.rs1.getPrimary().getDB( 'admin' ).createUser({user: 'user', + pwd: 'password', + roles: jsTest.basicUserRoles}, + {w: 3, wtimeout: 30000} ); diff --git a/jstests/sharding/authConnectionHook.js b/jstests/sharding/authConnectionHook.js index e5b7c7c9bd7..52a2b25b050 100644 --- a/jstests/sharding/authConnectionHook.js +++ b/jstests/sharding/authConnectionHook.js @@ -7,7 +7,7 @@ var mongos = st.s; var adminDB = mongos.getDB('admin'); var db = mongos.getDB('test') -adminDB.addUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles}); +adminDB.createUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles}); adminDB.auth('admin', 'password'); diff --git a/jstests/sharding/auth_add_shard.js b/jstests/sharding/auth_add_shard.js index ce770e65f10..5d8edee49ec 100644 --- a/jstests/sharding/auth_add_shard.js +++ b/jstests/sharding/auth_add_shard.js @@ -33,7 +33,7 @@ if (user) { } else { print("adding user"); - mongos.getDB(adminUser.db).addUser({user: adminUser.username, pwd: adminUser.password, roles: jsTest.adminUserRoles}); + mongos.getDB(adminUser.db).createUser({user: adminUser.username, pwd: adminUser.password, roles: jsTest.adminUserRoles}); } //login as admin user diff --git a/jstests/sharding/auth_copydb.js b/jstests/sharding/auth_copydb.js index bba901967e4..c971065b35e 100644 --- a/jstests/sharding/auth_copydb.js +++ b/jstests/sharding/auth_copydb.js @@ -14,7 +14,7 @@ var sourceTestDB = sourceMongodConn.getDB('test'); sourceTestDB.foo.insert({a:1}); -destAdminDB.addUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles}); // Turns on access control enforcement +destAdminDB.createUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles}); // Turns on access control enforcement jsTestLog("Running copydb that should fail"); var res = destAdminDB.runCommand({copydb:1, diff --git a/jstests/sharding/auth_repl.js b/jstests/sharding/auth_repl.js index 6aa126b3c23..3c0a5d14be2 100644 --- a/jstests/sharding/auth_repl.js +++ b/jstests/sharding/auth_repl.js @@ -26,11 +26,13 @@ assert(doc != null); // Add admin user using direct connection to primary to simulate connection from remote host var adminDB = primary.getDB('admin'); -adminDB.addUser({user: 'user', pwd: 'user', roles: jsTest.adminUserRoles}, nodeCount); +adminDB.createUser({user: 'user', pwd: 'user', roles: jsTest.adminUserRoles}, + {w: nodeCount, wtimeout: 30000}); adminDB.auth('user', 'user'); var priTestDB = primary.getDB('test'); -priTestDB.addUser({user: 'a', pwd: 'a', roles: jsTest.basicUserRoles}, nodeCount); +priTestDB.createUser({user: 'a', pwd: 'a', roles: jsTest.basicUserRoles}, + {w: nodeCount, wtimeout: 30000}); // Authenticate the replSet connection assert.eq(1, testDB.auth('a', 'a')); diff --git a/jstests/sharding/auth_slaveok_routing.js b/jstests/sharding/auth_slaveok_routing.js index 1c599f208ca..2ba8bec2b79 100644 --- a/jstests/sharding/auth_slaveok_routing.js +++ b/jstests/sharding/auth_slaveok_routing.js @@ -38,10 +38,11 @@ var nodeCount = replTest.nodes.length; * is no admin user. */ var adminDB = mongos.getDB( 'admin' ) -adminDB.addUser({user: 'user', pwd: 'password', roles: jsTest.adminUserRoles}); +adminDB.createUser({user: 'user', pwd: 'password', roles: jsTest.adminUserRoles}); adminDB.auth( 'user', 'password' ); var priAdminDB = replTest.getPrimary().getDB( 'admin' ); -priAdminDB.addUser({user: 'user', pwd: 'password', roles: jsTest.adminUserRoles}, 3); +priAdminDB.createUser({user: 'user', pwd: 'password', roles: jsTest.adminUserRoles}, + {w: 3, wtimeout: 30000}); coll.drop(); coll.setSlaveOk( true ); diff --git a/jstests/sharding/authmr.js b/jstests/sharding/authmr.js index 2847977e006..52e69e88848 100644 --- a/jstests/sharding/authmr.js +++ b/jstests/sharding/authmr.js @@ -45,11 +45,11 @@ var cluster = new ShardingTest("authwhere", 1, 0, 1, var test2DB = adminDB.getSiblingDB('test2'); var ex; try { - adminDB.addUser(adminUser) + adminDB.createUser(adminUser) assert(adminDB.auth(adminUser.user, adminUser.pwd)); adminDB.dropUser(test1User.user); - adminDB.addUser(test1User); + adminDB.createUser(test1User); assertInsert(test1DB.foo, { a: 1 }); assertInsert(test1DB.foo, { a: 2 }); diff --git a/jstests/sharding/authwhere.js b/jstests/sharding/authwhere.js index 0c8d12306ca..3cba1aee4e4 100644 --- a/jstests/sharding/authwhere.js +++ b/jstests/sharding/authwhere.js @@ -45,11 +45,11 @@ var cluster = new ShardingTest("authwhere", 1, 0, 1, var test2DB = adminDB.getSiblingDB('test2'); var ex; try { - adminDB.addUser(adminUser) + adminDB.createUser(adminUser) assert(adminDB.auth(adminUser.user, adminUser.pwd)); adminDB.dropUser(test1Reader.user); - adminDB.addUser(test1Reader); + adminDB.createUser(test1Reader); assertInsert(test1DB.foo, { a: 1 }); assertInsert(test2DB.foo, { x: 1 }); diff --git a/jstests/sharding/localhostAuthBypass.js b/jstests/sharding/localhostAuthBypass.js index c53442ebf25..82d8b43a474 100644 --- a/jstests/sharding/localhostAuthBypass.js +++ b/jstests/sharding/localhostAuthBypass.js @@ -10,16 +10,16 @@ var numConfigs = 3; var username = "foo"; var password = "bar"; -var addUser = function(mongo) { +var createUser = function(mongo) { print("============ adding a user."); - mongo.getDB("admin").addUser({user: username, pwd: password, roles: jsTest.adminUserRoles}); + mongo.getDB("admin").createUser({user: username, pwd: password, roles: jsTest.adminUserRoles}); }; var addUsersToEachShard = function(st) { for(i = 0; i < numShards; i++) { print("============ adding a user to shard " + i); var d = st["shard" + i]; - d.getDB("admin").addUser({user: username, pwd: password, roles: jsTest.adminUserRoles}); + d.getDB("admin").createUser({user: username, pwd: password, roles: jsTest.adminUserRoles}); } }; @@ -200,7 +200,7 @@ var runTest = function(useHostName) { assertCanRunCommands(mongo, st); - addUser(mongo); + createUser(mongo); // now that we have a user, we need to make sure // helper functions on st work for the rest of the script. diff --git a/jstests/sharding/mrShardedOutputAuth.js b/jstests/sharding/mrShardedOutputAuth.js index 590b4270aec..4bafa04fa95 100644 --- a/jstests/sharding/mrShardedOutputAuth.js +++ b/jstests/sharding/mrShardedOutputAuth.js @@ -53,7 +53,7 @@ var st = new ShardingTest( testName = "mrShardedOutputAuth", // setup the users to the input, output and admin databases var mongos = st.s; var adminDb = mongos.getDB("admin"); -adminDb.addUser({user: "user", pwd: "pass", roles: jsTest.adminUserRoles}); +adminDb.createUser({user: "user", pwd: "pass", roles: jsTest.adminUserRoles}); var authenticatedConn = new Mongo(mongos.host); authenticatedConn.getDB('admin').auth("user", "pass"); @@ -62,10 +62,10 @@ adminDb = authenticatedConn.getDB("admin"); var configDb = authenticatedConn.getDB("config"); var inputDb = authenticatedConn.getDB("input") -inputDb.addUser({user: "user", pwd: "pass", roles: jsTest.basicUserRoles}); +inputDb.createUser({user: "user", pwd: "pass", roles: jsTest.basicUserRoles}); var outputDb = authenticatedConn.getDB("output"); -outputDb.addUser({user: "user", pwd: "pass", roles: jsTest.basicUserRoles}); +outputDb.createUser({user: "user", pwd: "pass", roles: jsTest.basicUserRoles}); // setup the input db inputDb.numbers.drop(); diff --git a/jstests/slowNightly/server7428.js b/jstests/slowNightly/server7428.js index 77043c9bc03..ed62e7adbf6 100644 --- a/jstests/slowNightly/server7428.js +++ b/jstests/slowNightly/server7428.js @@ -13,7 +13,7 @@ var fromDb = MongoRunner.runMongod({ port: 29000 }); // Setup toDb with auth var toDb = MongoRunner.runMongod({auth : "", port : 31001}); var admin = toDb.getDB("admin"); -admin.addUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}); +admin.createUser({user: "foo", pwd: "bar", roles: jsTest.adminUserRoles}); admin.auth("foo","bar"); admin.copyDatabase('test', 'test', fromDb.host) diff --git a/jstests/ssl/disable_x509.js b/jstests/ssl/disable_x509.js index 0b65bb9e2dd..93218556688 100644 --- a/jstests/ssl/disable_x509.js +++ b/jstests/ssl/disable_x509.js @@ -15,7 +15,7 @@ if (cmdOut.ok) { external = conn.getDB("$external") // Add user using localhost exception - external.addUser({user: CLIENT_USER, roles:[ + external.createUser({user: CLIENT_USER, roles:[ {'role':'userAdminAnyDatabase', 'db':'admin'}, {'role':'readWriteAnyDatabase', 'db':'admin'}]}) diff --git a/jstests/ssl/x509_client.js b/jstests/ssl/x509_client.js index 526f907b8ce..0392a7baaa4 100644 --- a/jstests/ssl/x509_client.js +++ b/jstests/ssl/x509_client.js @@ -24,7 +24,7 @@ function authAndTest(mongo) { test = mongo.getDB("test"); // Add user using localhost exception - external.addUser({user: CLIENT_USER, roles:[ + external.createUser({user: CLIENT_USER, roles:[ {'role':'userAdminAnyDatabase', 'db':'admin'}, {'role':'readWriteAnyDatabase', 'db':'admin'}]}) @@ -37,7 +37,7 @@ function authAndTest(mongo) { "authentication with valid user failed" ) // Check that we can add a user and read data - test.addUser({user: "test", pwd: "test", roles:[ + test.createUser({user: "test", pwd: "test", roles:[ {'role': 'readWriteAnyDatabase', 'db': 'admin'}]}) test.foo.findOne() diff --git a/jstests/tool/dumpauth.js b/jstests/tool/dumpauth.js index c5767015815..2fcd32a9157 100644 --- a/jstests/tool/dumpauth.js +++ b/jstests/tool/dumpauth.js @@ -13,7 +13,7 @@ for(var i = 0; i < 100; i++) { t["testcol"].save({ "x": i }); } -db.addUser({user: "testuser" , pwd: "testuser", roles: jsTest.adminUserRoles}); +db.createUser({user: "testuser" , pwd: "testuser", roles: jsTest.adminUserRoles}); assert( db.auth( "testuser" , "testuser" ) , "auth failed" ); diff --git a/jstests/tool/dumprestore_auth.js b/jstests/tool/dumprestore_auth.js index 7ea6d803635..9349681129e 100644 --- a/jstests/tool/dumprestore_auth.js +++ b/jstests/tool/dumprestore_auth.js @@ -5,10 +5,10 @@ t = new ToolTest("dumprestore_auth", { auth : "" }); c = t.startDB("foo"); adminDB = c.getDB().getSiblingDB('admin'); -adminDB.addUser({user: 'admin', pwd: 'password', roles: ['root']}); +adminDB.createUser({user: 'admin', pwd: 'password', roles: ['root']}); adminDB.auth('admin','password'); -adminDB.addUser({user: 'backup', pwd: 'password', roles: ['backup']}); -adminDB.addUser({user: 'restore', pwd: 'password', roles: ['restore']}); +adminDB.createUser({user: 'backup', pwd: 'password', roles: ['backup']}); +adminDB.createUser({user: 'restore', pwd: 'password', roles: ['restore']}); assert.eq(0 , c.count() , "setup1"); c.save({ a : 22 }); diff --git a/jstests/tool/restorewithauth.js b/jstests/tool/restorewithauth.js index 9c7ca96d427..ac9e7bc756b 100644 --- a/jstests/tool/restorewithauth.js +++ b/jstests/tool/restorewithauth.js @@ -52,7 +52,7 @@ conn = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + // admin user var admin = conn.getDB( "admin" ) -admin.addUser({user: "admin" , pwd: "admin", roles: jsTest.adminUserRoles}); +admin.createUser({user: "admin" , pwd: "admin", roles: jsTest.adminUserRoles}); admin.auth( "admin" , "admin" ); var foo = conn.getDB( "foo" ) @@ -92,7 +92,7 @@ foo.dropDatabase(); assert.eq(foo.system.namespaces.count({name: "foo.bar"}), 0); assert.eq(foo.system.namespaces.count({name: "foo.baz"}), 0); -foo.addUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles}); +foo.createUser({user: 'user', pwd: 'password', roles: jsTest.basicUserRoles}); // now try to restore dump with foo database credentials x = runMongoProgram("mongorestore", diff --git a/jstests/tool/stat1.js b/jstests/tool/stat1.js index 0f894d7e4a9..96211f7d3f2 100644 --- a/jstests/tool/stat1.js +++ b/jstests/tool/stat1.js @@ -11,7 +11,7 @@ t.drop(); db.dropAllUsers(); -db.addUser({user: "eliot" , pwd: "eliot", roles: jsTest.adminUserRoles}); +db.createUser({user: "eliot" , pwd: "eliot", roles: jsTest.adminUserRoles}); assert( db.auth( "eliot" , "eliot" ) , "auth failed" ); diff --git a/jstests/user_management_helpers.js b/jstests/user_management_helpers.js index 551edfa2412..50707f584ab 100644 --- a/jstests/user_management_helpers.js +++ b/jstests/user_management_helpers.js @@ -16,8 +16,8 @@ function assertHasRole(rolesArray, roleName, roleDB) { db.dropDatabase(); db.dropAllUsers(); - db.addUser({user: "spencer", pwd: "password", roles: ['readWrite']}); - db.addUser({user: "andy", pwd: "password", roles: ['readWrite']}); + db.createUser({user: "spencer", pwd: "password", roles: ['readWrite']}); + db.createUser({user: "andy", pwd: "password", roles: ['readWrite']}); // Test getUser var userObj = db.getUser('spencer'); @@ -73,13 +73,13 @@ function assertHasRole(rolesArray, roleName, roleDB) { // Test password digestion assert.throws(function() { - db.addUser({user:'user1', pwd:'x', roles:[], digestPassword: true});}); + db.createUser({user:'user1', pwd:'x', roles:[], digestPassword: true});}); assert.throws(function() { - db.addUser({user:'user1', pwd:'x', roles:[], digestPassword: false});}); + db.createUser({user:'user1', pwd:'x', roles:[], digestPassword: false});}); assert.throws(function() { - db.addUser({user:'user1', pwd:'x', roles:[], passwordDigestor: 'foo'});}); - db.addUser({user:'user1', pwd:'x', roles:[], passwordDigestor:"server"}); - db.addUser({user:'user2', pwd:'x', roles:[], passwordDigestor:"client"}); + db.createUser({user:'user1', pwd:'x', roles:[], passwordDigestor: 'foo'});}); + db.createUser({user:'user1', pwd:'x', roles:[], passwordDigestor:"server"}); + db.createUser({user:'user2', pwd:'x', roles:[], passwordDigestor:"client"}); assert(db.auth('user1', 'x')); assert(db.auth('user2', 'x')); |