0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/jstests/auth/system_auth_scram_mechs.js
2019-07-27 11:02:23 -04:00

25 lines
683 B
JavaScript

/**
* Tests that the __system user can auth using both SCRAM-SHA-1 and SCRAM-SHA-256
*
* @tags: [requires_replication]
*/
(function() {
'use strict';
const keyfile = 'jstests/libs/key1';
const keyfileContents = cat(keyfile).replace(/[\011-\015\040]/g, '');
const rs = new ReplSetTest({nodes: 3, keyFile: keyfile});
rs.startSet();
rs.initiate();
const db = rs.getPrimary().getDB("admin");
jsTestLog("Testing scram-sha-256");
assert.eq(db.auth({mechanism: 'SCRAM-SHA-256', user: '__system', pwd: keyfileContents}), 1);
db.logout();
jsTestLog("Testing scram-sha-1");
assert.eq(db.auth({mechanism: 'SCRAM-SHA-1', user: '__system', pwd: keyfileContents}), 1);
rs.stopSet();
})();