diff options
Diffstat (limited to 'jstests/auth/logout_reconnect.js')
-rw-r--r-- | jstests/auth/logout_reconnect.js | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/jstests/auth/logout_reconnect.js b/jstests/auth/logout_reconnect.js index dc59d408544..fa5d8a8fcdb 100644 --- a/jstests/auth/logout_reconnect.js +++ b/jstests/auth/logout_reconnect.js @@ -4,46 +4,40 @@ * It is a regression test for SERVER-8798. */ -var conn = MongoRunner.runMongod({ - auth : "", - remember : true -}); +var conn = MongoRunner.runMongod({auth: "", remember: true}); // create user with rw permissions and login var testDB = conn.getDB('test'); var adminDB = conn.getDB('admin'); -adminDB.createUser({user:'admin', pwd:'admin', roles:['userAdminAnyDatabase']}); -adminDB.auth('admin','admin'); -testDB.createUser({user:'rwuser', pwd:'rwuser', roles:['readWrite']}); +adminDB.createUser({user: 'admin', pwd: 'admin', roles: ['userAdminAnyDatabase']}); +adminDB.auth('admin', 'admin'); +testDB.createUser({user: 'rwuser', pwd: 'rwuser', roles: ['readWrite']}); adminDB.logout(); testDB.auth('rwuser', 'rwuser'); // verify that the rwuser can read and write -testDB.foo.insert({a:1}); -assert.eq(1, testDB.foo.find({a:1}).count(), "failed to read"); +testDB.foo.insert({a: 1}); +assert.eq(1, testDB.foo.find({a: 1}).count(), "failed to read"); // assert that the user cannot read unauthenticated testDB.logout(); -assert.throws(function(){ testDB.foo.findOne(); }, - [], - "user should not be able to read after logging out"); +assert.throws(function() { + testDB.foo.findOne(); +}, [], "user should not be able to read after logging out"); MongoRunner.stopMongod(conn); -conn = MongoRunner.runMongod({ - restart : conn, - noCleanData : true -}); +conn = MongoRunner.runMongod({restart: conn, noCleanData: true}); // expect to fail on first attempt since the socket is no longer valid -try{ +try { val = testDB.foo.findOne(); +} catch (err) { } -catch(err){} // assert that credentials were not autosubmitted on reconnect -assert.throws(function(){ testDB.foo.findOne(); }, - [], - "user should not be able to read after logging out"); +assert.throws(function() { + testDB.foo.findOne(); +}, [], "user should not be able to read after logging out"); MongoRunner.stopMongod(conn); |