Skip to content

Commit 84ab2fa

Browse files
test(NODE-7561): Skip QE "prefixPreview" and "suffixPreview" tests on server 9.0.0+ (#4934)
1 parent 5cc96e7 commit 84ab2fa

11 files changed

Lines changed: 53 additions & 23 deletions

test/integration/client-side-encryption/client_side_encryption.prose.27.text_queries.test.ts

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { join } from 'node:path';
33

44
import { type Binary, type Document, EJSON } from 'bson';
55
import { expect } from 'chai';
6+
import * as semver from 'semver';
67

78
import { getCSFLEKMSProviders } from '../../csfle-kms-providers';
89
import { ClientEncryption, type MongoClient, MongoDBCollectionNamespace } from '../../mongodb';
@@ -14,6 +15,15 @@ const metadata: MongoDBMetadataUI = {
1415
libmongocrypt: '>=1.15.1'
1516
}
1617
};
18+
// # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416
19+
const metadataWithoutPreview: MongoDBMetadataUI = {
20+
requires: {
21+
clientSideEncryption: '>=6.4.0',
22+
mongodb: '>=8.2.0 <9.0.0',
23+
topology: '!single',
24+
libmongocrypt: '>=1.15.1'
25+
}
26+
};
1727

1828
const loadFLEDataFile = async (filename: string) =>
1929
EJSON.parse(
@@ -33,9 +43,12 @@ describe('27. Text Explicit Encryption', function () {
3343

3444
beforeEach(async function () {
3545
utilClient = this.configuration.newClient();
46+
const isServer9OrAbove = semver.satisfies(this.configuration.version, '>=9.0.0');
47+
const shouldRunPrefixSuffixTests = !isServer9OrAbove;
3648

3749
// Using QE CreateCollection() and Collection.Drop(), drop and create the following collections with majority write concern:
3850
// - db.prefix-suffix using the encryptedFields option set to the contents of encryptedFields-prefix-suffix.json
51+
// Skip this step if testing server 9.0.0+.
3952
// - db.substring using the encryptedFields option set to the contents of encryptedFields-substring.json
4053
async function dropAndCreateCollection(ns: string, encryptedFields?: Document) {
4154
const { db, collection } = MongoDBCollectionNamespace.fromString(ns);
@@ -49,10 +62,12 @@ describe('27. Text Explicit Encryption', function () {
4962
});
5063
}
5164

52-
await dropAndCreateCollection(
53-
'db.prefix-suffix',
54-
await loadFLEDataFile('encryptedFields-prefix-suffix.json')
55-
);
65+
if (shouldRunPrefixSuffixTests) {
66+
await dropAndCreateCollection(
67+
'db.prefix-suffix',
68+
await loadFLEDataFile('encryptedFields-prefix-suffix.json')
69+
);
70+
}
5671
await dropAndCreateCollection(
5772
'db.substring',
5873
await loadFLEDataFile('encryptedFields-substring.json')
@@ -144,18 +159,20 @@ describe('27. Text Explicit Encryption', function () {
144159
}
145160
});
146161

147-
// Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern:
148-
// { "_id": 0, "encryptedText": <encrypted 'foobarbaz'> }
149-
await encryptedClient
150-
.db('db')
151-
.collection<{ _id: number; encryptedText: Binary }>('prefix-suffix')
152-
.insertOne(
153-
{
154-
_id: 0,
155-
encryptedText
156-
},
157-
{ writeConcern: { w: 'majority' } }
158-
);
162+
if (shouldRunPrefixSuffixTests) {
163+
// Use `encryptedClient` to insert the following document into `db.prefix-suffix` with majority write concern:
164+
// { "_id": 0, "encryptedText": <encrypted 'foobarbaz'> }
165+
await encryptedClient
166+
.db('db')
167+
.collection<{ _id: number; encryptedText: Binary }>('prefix-suffix')
168+
.insertOne(
169+
{
170+
_id: 0,
171+
encryptedText
172+
},
173+
{ writeConcern: { w: 'majority' } }
174+
);
175+
}
159176
}
160177

161178
{
@@ -208,7 +225,8 @@ describe('27. Text Explicit Encryption', function () {
208225
await Promise.allSettled([utilClient.close(), encryptedClient.close(), keyVaultClient.close()]);
209226
});
210227

211-
it('Case 1: can find a document by prefix', metadata, async function () {
228+
it('Case 1: can find a document by prefix', metadataWithoutPreview, async function () {
229+
// Skip this test case if testing MongoDB server 9.0.0+.
212230
// Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts:
213231
// class EncryptOpts {
214232
// keyId : <key1ID>,
@@ -260,7 +278,8 @@ describe('27. Text Explicit Encryption', function () {
260278
expect(result).to.deep.equal({ _id: 0, encryptedText: 'foobarbaz' });
261279
});
262280

263-
it('Case 2: can find a document by suffix', metadata, async function () {
281+
it('Case 2: can find a document by suffix', metadataWithoutPreview, async function () {
282+
// Skip this test case if testing MongoDB server 9.0.0+.
264283
// Use clientEncryption.encrypt() to encrypt the string "baz" with the following EncryptOpts:
265284
// class EncryptOpts {
266285
// keyId : <key1ID>,
@@ -311,7 +330,8 @@ describe('27. Text Explicit Encryption', function () {
311330
expect(result).to.deep.equal({ _id: 0, encryptedText: 'foobarbaz' });
312331
});
313332

314-
it('Case 3: assert no document found by prefix', metadata, async function () {
333+
it('Case 3: assert no document found by prefix', metadataWithoutPreview, async function () {
334+
// Skip this test case if testing MongoDB server 9.0.0+.
315335
// Use clientEncryption.encrypt() to encrypt the string "baz" with the following EncryptOpts:
316336
// class EncryptOpts {
317337
// keyId : <key1ID>,
@@ -351,7 +371,8 @@ describe('27. Text Explicit Encryption', function () {
351371
expect(await encryptedClient.db('db').collection('prefix-suffix').findOne(filter)).to.be.null;
352372
});
353373

354-
it('Case 4: assert no document found by suffix', metadata, async function () {
374+
it('Case 4: assert no document found by suffix', metadataWithoutPreview, async function () {
375+
// Skip this test case if testing MongoDB server 9.0.0+.
355376
// Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts:
356377
// class EncryptOpts {
357378
// keyId : <key1ID>,
@@ -497,7 +518,8 @@ describe('27. Text Explicit Encryption', function () {
497518
expect(result).to.be.null;
498519
});
499520

500-
it('Case 7: assert contentionFactor is required', metadata, async function () {
521+
it('Case 7: assert contentionFactor is required', metadataWithoutPreview, async function () {
522+
// Skip this test case if testing MongoDB server 9.0.0+.
501523
// Use clientEncryption.encrypt() to encrypt the string "foo" with the following EncryptOpts:
502524
// class EncryptOpts {
503525
// keyId : <key1ID>,

test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"runOnRequirements": [
55
{
66
"minServerVersion": "8.2.0",
7+
"maxServerVersion": "8.99.99",
78
"topologies": [
89
"replicaset",
910
"sharded",

test/spec/client-side-encryption/tests/unified/QE-Text-cleanupStructuredEncryptionData.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ description: QE-Text-cleanupStructuredEncryptionData
22
schemaVersion: "1.25"
33
runOnRequirements:
44
- minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries.
5+
maxServerVersion: "8.99.99" # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416
56
topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone.
67
csfle:
78
minLibmongocryptVersion: 1.15.0 # For SPM-4158.

test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"runOnRequirements": [
55
{
66
"minServerVersion": "8.2.0",
7+
"maxServerVersion": "8.99.99",
78
"topologies": [
89
"replicaset",
910
"sharded",

test/spec/client-side-encryption/tests/unified/QE-Text-compactStructuredEncryptionData.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ description: QE-Text-compactStructuredEncryptionData
22
schemaVersion: "1.25"
33
runOnRequirements:
44
- minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries.
5+
maxServerVersion: "8.99.99" # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416
56
topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone.
67
csfle:
78
minLibmongocryptVersion: 1.15.0 # For SPM-4158.

test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"runOnRequirements": [
55
{
66
"minServerVersion": "8.2.0",
7+
"maxServerVersion": "8.99.99",
78
"topologies": [
89
"replicaset",
910
"sharded",

test/spec/client-side-encryption/tests/unified/QE-Text-prefixPreview.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ description: QE-Text-prefixPreview
22
schemaVersion: "1.25"
33
runOnRequirements:
44
- minServerVersion: "8.2.0" # Server 8.2.0 adds preview support for QE text queries.
5+
maxServerVersion: "8.99.99" # Server 9.0.0-rc0 removes support for "prefixPreview" and "suffixPreview": SERVER-123416
56
topologies: ["replicaset", "sharded", "load-balanced"] # QE does not support standalone.
67
csfle:
78
minLibmongocryptVersion: 1.15.0 # For SPM-4158.

test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
],
127127
"tests": [
128128
{
129-
"description": "Insert QE suffixPreview",
129+
"description": "Insert QE substringPreview",
130130
"operations": [
131131
{
132132
"name": "insertOne",

test/spec/client-side-encryption/tests/unified/QE-Text-substringPreview.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ initialData:
7474
],
7575
}
7676
tests:
77-
- description: "Insert QE suffixPreview"
77+
- description: "Insert QE substringPreview"
7878
operations:
7979
- name: insertOne
8080
arguments:

test/spec/client-side-encryption/tests/unified/QE-Text-suffixPreview.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"runOnRequirements": [
55
{
66
"minServerVersion": "8.2.0",
7+
"maxServerVersion": "8.99.99",
78
"topologies": [
89
"replicaset",
910
"sharded",

0 commit comments

Comments
 (0)