summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2022-10-21 19:54:27 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-21 20:51:28 +0000
commit7ce351c5e56d6a33a08a3c336463ab2c8ec2ce21 (patch)
tree9e31b8031f7b7460fef3464c808560a551c6b065 /jstests
parent496b24a6e2a1a488501e2eaeefac8af39670e173 (diff)
downloadmongo-7ce351c5e56d6a33a08a3c336463ab2c8ec2ce21.tar.gz
SERVER-69721 Serialize and deserialize namespace in cursor reply objects correctly in multitenant environment
Diffstat (limited to 'jstests')
-rw-r--r--jstests/serverless/native_tenant_data_isolation_basic_security_token.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/jstests/serverless/native_tenant_data_isolation_basic_security_token.js b/jstests/serverless/native_tenant_data_isolation_basic_security_token.js
index 3df1d65f8c9..b58194a0523 100644
--- a/jstests/serverless/native_tenant_data_isolation_basic_security_token.js
+++ b/jstests/serverless/native_tenant_data_isolation_basic_security_token.js
@@ -69,6 +69,9 @@ function runTest(featureFlagRequireTenantId) {
tokenConn._setSecurityToken(securityToken);
+ // Logout the root user to avoid multiple authentication.
+ tokenConn.getDB("admin").logout();
+
// Create a collection for the tenant kTenant and then insert into it.
assert.commandWorked(tokenDB.createCollection(kCollName));
assert.commandWorked(
@@ -83,9 +86,13 @@ function runTest(featureFlagRequireTenantId) {
const findRes = assert.commandWorked(
tokenDB.runCommand({find: kCollName, filter: {a: 1}, batchSize: 1}));
assert(arrayEq([{_id: 0, a: 1, b: 1}], findRes.cursor.firstBatch), tojson(findRes));
+ checkNsSerializedCorrectly(
+ featureFlagRequireTenantId, kTenant, kDbName, kCollName, findRes.cursor.ns);
- assert.commandWorked(
+ const getMoreRes = assert.commandWorked(
tokenDB.runCommand({getMore: findRes.cursor.id, collection: kCollName}));
+ checkNsSerializedCorrectly(
+ featureFlagRequireTenantId, kTenant, kDbName, kCollName, getMoreRes.cursor.ns);
}
// Test the aggregate command.
@@ -93,6 +100,8 @@ function runTest(featureFlagRequireTenantId) {
const aggRes = assert.commandWorked(tokenDB.runCommand(
{aggregate: kCollName, pipeline: [{$match: {a: 1}}], cursor: {}}));
assert(arrayEq([{_id: 0, a: 1, b: 1}], aggRes.cursor.firstBatch), tojson(aggRes));
+ checkNsSerializedCorrectly(
+ featureFlagRequireTenantId, kTenant, kDbName, kCollName, aggRes.cursor.ns);
}
// Find and modify the document.
@@ -311,7 +320,8 @@ function runTest(featureFlagRequireTenantId) {
const fromName = kDbName + '.' + kCollName;
const toName = fromName + "_renamed";
assert.commandFailedWithCode(
- adminDb.runCommand({renameCollection: fromName, to: toName, dropTarget: true}),
+ tokenConn.getDB("admin").runCommand(
+ {renameCollection: fromName, to: toName, dropTarget: true}),
ErrorCodes.NamespaceNotFound);
assert.commandFailedWithCode(tokenDB2.runCommand({listIndexes: kCollName}),