0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-25 09:19:32 +01:00
mongodb/jstests/auth/commands_builtin_roles_sharded.js
Chi-I Huang 4f6c92f6e8 SERVER-95919 Ensure full auth test coverage of aggregation stages in commands_lib (#28452)
GitOrigin-RevId: 1a213cf8a367d9cb05fb8eccf97907288c65124c
2024-10-24 23:17:05 +00:00

54 lines
1.6 KiB
JavaScript

/**
* Exhaustive test for authorization of commands with builtin roles.
*
* Runs tests on a sharded cluster.
*
* The test logic implemented here operates on the test cases defined
* in jstests/auth/lib/commands_lib.js
*
* @tags: [requires_sharding, requires_scripting]
*/
import {runAllCommandsBuiltinRoles} from "jstests/auth/lib/commands_builtin_roles.js";
import {ShardingTest} from "jstests/libs/shardingtest.js";
import {MongotMock} from "jstests/with_mongot/mongotmock/lib/mongotmock.js";
let mongotmock;
let mongotHost = "localhost:27017";
if (!_isWindows()) {
mongotmock = new MongotMock();
mongotmock.start();
mongotHost = mongotmock.getConnection().host;
}
const dbPath = MongoRunner.toRealDir("$dataDir/commands_built_in_roles_sharded/");
mkdir(dbPath);
const opts = {
auth: "",
setParameter: {
trafficRecordingDirectory: dbPath,
mongotHost, // We have to set the mongotHost parameter for the
// $search-related tests to pass configuration checks.
syncdelay: 0 // Disable checkpoints as this can cause some commands to fail transiently.
}
};
// run all tests sharded
const conn = new ShardingTest({
shards: 1,
mongos: 1,
config: 1,
keyFile: "jstests/libs/key1",
other: {
rsOptions: opts,
// We have to set the mongotHost parameter for the $search-related tests to pass
// configuration checks.
mongosOptions: {setParameter: {trafficRecordingDirectory: dbPath, mongotHost}}
}
});
runAllCommandsBuiltinRoles(conn);
conn.stop();
if (mongotmock) {
mongotmock.stop();
}