Files
mongo/jstests/multiVersion/libs/auth_helpers.js
Andreas Nilsson d9a98b8517 SERVER-19721 Restore the authSchemaUpgrade command
Fixed mongos rebase error for catalogManager(txn)
2015-09-08 10:47:48 -04:00

28 lines
1.1 KiB
JavaScript

// Helpers for auth upgrade tests.
// Get a user document for username in db.
var getUserDoc = function(db, username){
return db.runCommand({'usersInfo': {user: username, db: db._name},
showCredentials: true}).users[0]
}
// Verify that the user document for username in db
// has MONGODB-CR credentials (or not) and SCRAM-SHA-1
// credentials (or not).
var verifyUserDoc = function(db, username, hasCR, hasSCRAM, hasExternal = false){
var userDoc = getUserDoc(db, username);
assert.eq(hasCR, 'MONGODB-CR' in userDoc.credentials);
assert.eq(hasSCRAM, 'SCRAM-SHA-1' in userDoc.credentials);
assert.eq(hasExternal, 'external' in userDoc.credentials);
}
// Verify that that we can authenticate (or not) using MONGODB-CR
// and SCRAM-SHA-1 to db using username and password.
var verifyAuth = function(db, username, password, passCR, passSCRAM){
assert.eq(passCR, db.auth({mechanism: 'MONGODB-CR',
user: username, pwd: password}));
assert.eq(passSCRAM, db.auth({mechanism: 'SCRAM-SHA-1',
user: username, pwd: password}));
db.logout();
}