2009-01-27 05:28:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
users = db.getCollection( "system.users" );
|
|
|
|
users.remove( {} );
|
|
|
|
|
|
|
|
pass = "a" + Math.random();
|
2009-02-01 00:06:10 +01:00
|
|
|
//print( "password [" + pass + "]" );
|
2009-01-27 05:28:26 +01:00
|
|
|
|
|
|
|
db.addUser( "eliot" , pass );
|
|
|
|
|
|
|
|
assert( db.auth( "eliot" , pass ) , "auth failed" );
|
|
|
|
assert( ! db.auth( "eliot" , pass + "a" ) , "auth should have failed" );
|
|
|
|
|
|
|
|
pass2 = "b" + Math.random();
|
|
|
|
db.addUser( "eliot" , pass2 );
|
|
|
|
|
|
|
|
assert( ! db.auth( "eliot" , pass ) , "failed to change password failed" );
|
|
|
|
assert( db.auth( "eliot" , pass2 ) , "new password didn't take" );
|
2009-02-06 20:26:56 +01:00
|
|
|
|
2009-02-07 16:27:22 +01:00
|
|
|
assert( db.auth( "eliot" , pass2 ) , "what?" );
|
|
|
|
db.removeUser( "eliot" );
|
|
|
|
assert( ! db.auth( "eliot" , pass2 ) , "didn't remove user" );
|
|
|
|
|
2009-02-06 20:26:56 +01:00
|
|
|
|
|
|
|
var a = db.getMongo().getDB( "admin" );
|
|
|
|
users = a.getCollection( "system.users" );
|
|
|
|
users.remove( {} );
|
|
|
|
pass = "c" + Math.random();
|
|
|
|
a.addUser( "super", pass );
|
|
|
|
assert( a.auth( "super" , pass ) , "auth failed" );
|
2009-02-07 16:27:22 +01:00
|
|
|
assert( !a.auth( "super" , pass + "a" ) , "auth should have failed" );
|
|
|
|
|