summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/fle2_shardsvr_cleanup.js
blob: ac9a1b57751c96140941fe39df28a4faea55034a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
 * Cannot run cleanup against a shard server
 *
 * @tags: [
 * requires_fcv_70,
 * requires_sharding,
 * featureFlagFLE2CleanupCommand
 * ]
 */
load("jstests/fle2/libs/encrypted_client_util.js");

(function() {
'use strict';

function runTest(mongosConn, shardConn) {
    let dbName = 'testdb';

    let clientMongoS = new EncryptedClient(mongosConn, dbName);

    assert.commandWorked(clientMongoS.createEncryptionCollection("basic", {
        encryptedFields: {
            "fields":
                [{"path": "first", "bsonType": "string", "queries": {"queryType": "equality"}}]
        }
    }));

    let clientShard = new EncryptedClient(shardConn, dbName);

    assert.commandFailedWithCode(clientShard.getDB().basic.cleanup(), 7618804);
}

jsTestLog("Sharding: Testing fle2 cleanup not allowed against a shard server");
{
    const st = new ShardingTest({shards: 1, mongos: 1, config: 1});

    runTest(st.s, st.shard0);

    st.stop();
}
}());