mongo/jstests/auth/system_auth_scram_mechs.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

23 lines
724 B
JavaScript

/**
* Tests that the __system user can auth using SCRAM-SHA-256
* @tags: [requires_replication]
*/
import {ReplSetTest} from "jstests/libs/replsettest.js";
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();
// Test that SCRAM-SHA-1 fails explicitly
jsTestLog("Testing scram-sha-1");
assert.eq(db.auth({mechanism: "SCRAM-SHA-1", user: "__system", pwd: keyfileContents}), 0);
rs.stopSet();