diff options
Diffstat (limited to 'jstests/auth/auth2.js')
-rw-r--r-- | jstests/auth/auth2.js | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/jstests/auth/auth2.js b/jstests/auth/auth2.js index 84b7a0c7fd2..3cb9838682a 100644 --- a/jstests/auth/auth2.js +++ b/jstests/auth/auth2.js @@ -3,21 +3,25 @@ port = allocatePorts( 1 )[ 0 ]; baseName = "jstests_auth_auth2"; -m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" , "--nojournal" , "--smallfiles" ); +m = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1", "--nojournal", "--smallfiles" ); db = m.getDB( "admin" ); -t = db[ baseName ]; -t.drop(); +// These statements throw because the localhost exception does not allow +// these operations: it only allows the creation of the first admin user +// and necessary setup operations. +assert.throws( function(){ db.users.count(); } ); +assert.throws( function() { db.shutdownServer(); } ); -users = db.getCollection( "system.users" ); -assert.eq( 0 , users.count() ); - -db.createUser({user: "eliot" , pwd: "eliot", roles: jsTest.adminUserRoles}); +db.createUser( { user: "eliot", pwd: "eliot", roles: [ "root" ] } ); -assert.throws( function(){ db.users.count(); } ) +// These statements throw because we have a user but have not authenticated +// as that user. +assert.throws( function(){ db.users.count(); } ); +assert.throws( function() { db.shutdownServer(); } ); -assert.throws( function() { db.shutdownServer(); } ) +db.auth( "eliot", "eliot" ); -db.auth( "eliot" , "eliot" ) +users = db.getCollection( "system.users" ); +assert.eq( 1, users.count() ); db.shutdownServer(); |