diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /jstests/sharding/sharded_data_distribution_auth.js | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'jstests/sharding/sharded_data_distribution_auth.js')
| -rw-r--r-- | jstests/sharding/sharded_data_distribution_auth.js | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/jstests/sharding/sharded_data_distribution_auth.js b/jstests/sharding/sharded_data_distribution_auth.js deleted file mode 100644 index 7e63cf19533..00000000000 --- a/jstests/sharding/sharded_data_distribution_auth.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Test to validate the privileges of using $shardedDataDistribution stage. - * - * @tags: [ - * requires_fcv_60, - * ] - */ - -(function() { -'use strict'; - -if (!TestData.auth) { - jsTestLog("Skipping testing authorization since auth is not enabled"); - return; -} - -// Test privileges -function testPrivileges() { - // Create new role with the exact privileges to execute $shardedDataDistribution - assert.commandWorked(adminDb.runCommand({ - createRole: "role_ok_priv", - roles: [], - privileges: [{resource: {cluster: true}, actions: ["shardedDataDistribution"]}] - })); - - // Creates users with privileges and no privileges - assert.commandWorked(adminDb.runCommand({createUser: "user_no_priv", pwd: "pwd", roles: []})); - - assert.commandWorked(adminDb.runCommand( - {createUser: "user_priv1", pwd: "pwd", roles: [{role: "role_ok_priv", db: 'admin'}]})); - - assert.commandWorked(adminDb.runCommand( - {createUser: "user_priv2", pwd: "pwd", roles: [{role: "clusterMonitor", db: 'admin'}]})); - - assert(adminDb.logout()); - - // User is in a role with privileges to execute the stage - assert(adminDb.auth("user_priv1", "pwd")); - assert.commandWorked( - adminDb.runCommand({aggregate: 1, pipeline: [{$shardedDataDistribution: {}}], cursor: {}})); - assert(adminDb.logout()); - - // User is in a role with privileges to execute the stage - assert(adminDb.auth("user_priv2", "pwd")); - assert.commandWorked( - adminDb.runCommand({aggregate: 1, pipeline: [{$shardedDataDistribution: {}}], cursor: {}})); - assert(adminDb.logout()); - - // User has no privileges to execute the stage - assert(adminDb.auth("user_no_priv", "pwd")); - assert.commandFailedWithCode( - adminDb.runCommand({aggregate: 1, pipeline: [{$shardedDataDistribution: {}}], cursor: {}}), - ErrorCodes.Unauthorized, - "user should no longer have privileges to execute $shardedDataDistribution stage."); - assert(adminDb.logout()); -} - -// Configure initial sharding cluster -const st = new ShardingTest({shards: 1}); -const mongos = st.s; - -const ns1 = "test.foo"; -const adminDb = mongos.getDB("admin"); -const testDb = mongos.getDB("test"); - -// Create a super user with __system role. -assert.commandWorked(adminDb.runCommand({createUser: "super", pwd: "super", roles: ["__system"]})); -assert(adminDb.logout()); -assert(adminDb.auth("super", "super")); - -st.adminCommand({shardcollection: ns1, key: {skey: 1}}); - -// Insert data to validate the aggregation stage -for (let i = 0; i < 6; i++) { - assert.commandWorked(testDb.getCollection("foo").insert({skey: i})); -} - -testPrivileges(); - -st.stop(); -})(); |
