Skip to content

Commit d26ad61

Browse files
feat(NODE-5272): do not create or drop ecc collections (#3678)
1 parent 536e6a1 commit d26ad61

File tree

129 files changed

+1837
-2269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1837
-2269
lines changed

src/cmap/wire_protocol/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ export const MIN_SUPPORTED_SERVER_VERSION = '3.6';
22
export const MAX_SUPPORTED_SERVER_VERSION = '6.0';
33
export const MIN_SUPPORTED_WIRE_VERSION = 6;
44
export const MAX_SUPPORTED_WIRE_VERSION = 17;
5+
export const MIN_SUPPORTED_QE_WIRE_VERSION = 21;
6+
export const MIN_SUPPORTED_QE_SERVER_VERSION = '7.0';
57
export const OP_REPLY = 1;
68
export const OP_UPDATE = 2001;
79
export const OP_INSERT = 2002;

src/operations/create_collection.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import type { Document } from '../bson';
2+
import {
3+
MIN_SUPPORTED_QE_SERVER_VERSION,
4+
MIN_SUPPORTED_QE_WIRE_VERSION
5+
} from '../cmap/wire_protocol/constants';
26
import { Collection } from '../collection';
37
import type { Db } from '../db';
8+
import { MongoCompatibilityError } from '../error';
49
import type { PkFactory } from '../mongo_client';
510
import type { Server } from '../sdam/server';
611
import type { ClientSession } from '../sessions';
@@ -97,6 +102,10 @@ export interface CreateCollectionOptions extends CommandOperationOptions {
97102
changeStreamPreAndPostImages?: { enabled: boolean };
98103
}
99104

105+
/* @internal */
106+
const INVALID_QE_VERSION =
107+
'Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption.';
108+
100109
/** @internal */
101110
export class CreateCollectionOperation extends CommandOperation<Collection> {
102111
override options: CreateCollectionOptions;
@@ -126,12 +135,17 @@ export class CreateCollectionOperation extends CommandOperation<Collection> {
126135
db.s.client.options.autoEncryption?.encryptedFieldsMap?.[`${db.databaseName}.${name}`];
127136

128137
if (encryptedFields) {
138+
// Creating a QE collection required min server of 7.0.0
139+
if (server.description.maxWireVersion < MIN_SUPPORTED_QE_WIRE_VERSION) {
140+
throw new MongoCompatibilityError(
141+
`${INVALID_QE_VERSION} The minimum server version required is ${MIN_SUPPORTED_QE_SERVER_VERSION}`
142+
);
143+
}
129144
// Create auxilliary collections for queryable encryption support.
130145
const escCollection = encryptedFields.escCollection ?? `enxcol_.${name}.esc`;
131-
const eccCollection = encryptedFields.eccCollection ?? `enxcol_.${name}.ecc`;
132146
const ecocCollection = encryptedFields.ecocCollection ?? `enxcol_.${name}.ecoc`;
133147

134-
for (const collectionName of [escCollection, eccCollection, ecocCollection]) {
148+
for (const collectionName of [escCollection, ecocCollection]) {
135149
const createOp = new CreateCollectionOperation(db, collectionName, {
136150
clusteredIndex: {
137151
key: { _id: 1 },

src/operations/drop.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ export class DropCollectionOperation extends CommandOperation<boolean> {
5353

5454
if (encryptedFields) {
5555
const escCollection = encryptedFields.escCollection || `enxcol_.${name}.esc`;
56-
const eccCollection = encryptedFields.eccCollection || `enxcol_.${name}.ecc`;
5756
const ecocCollection = encryptedFields.ecocCollection || `enxcol_.${name}.ecoc`;
5857

59-
for (const collectionName of [escCollection, eccCollection, ecocCollection]) {
58+
for (const collectionName of [escCollection, ecocCollection]) {
6059
// Drop auxilliary collections, ignoring potential NamespaceNotFound errors.
6160
const dropOp = new DropCollectionOperation(db, collectionName);
6261
try {

test/integration/client-side-encryption/client_side_encryption.prose.21.automatic_data_encryption_keys.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { installNodeDNSWorkaroundHooks } from '../../tools/runner/hooks/configur
66
const metadata = {
77
requires: {
88
clientSideEncryption: true,
9-
mongodb: '>=6.0.0',
9+
mongodb: '>=7.0.0',
1010
topology: '!single'
1111
}
1212
} as const;

test/spec/client-side-encryption/etc/data/encryptedFields.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
{
2-
"escCollection": "enxcol_.default.esc",
3-
"eccCollection": "enxcol_.default.ecc",
4-
"ecocCollection": "enxcol_.default.ecoc",
52
"fields": [
63
{
74
"keyId": {
@@ -30,4 +27,4 @@
3027
"bsonType": "string"
3128
}
3229
]
33-
}
30+
}
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
{
2-
"fields": [
3-
{
4-
"keyId": {
5-
"$binary": {
6-
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7-
"subType": "04"
8-
}
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedDate",
11+
"bsonType": "date",
12+
"queries": {
13+
"queryType": "rangePreview",
14+
"contention": {
15+
"$numberLong": "0"
916
},
10-
"path": "encryptedDate",
11-
"bsonType": "date",
12-
"queries": {
13-
"queryType": "rangePreview",
14-
"sparsity": {
15-
"$numberLong": "1"
16-
},
17-
"min": {
18-
"$date": {
19-
"$numberLong": "0"
20-
}
21-
},
22-
"max": {
23-
"$date": {
24-
"$numberLong": "200"
17+
"sparsity": {
18+
"$numberLong": "1"
19+
},
20+
"min": {
21+
"$date": {
22+
"$numberLong": "0"
2523
}
24+
},
25+
"max": {
26+
"$date": {
27+
"$numberLong": "200"
2628
}
2729
}
2830
}
29-
]
31+
}
32+
]
3033
}
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
2-
"fields": [
3-
{
4-
"keyId": {
5-
"$binary": {
6-
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7-
"subType": "04"
8-
}
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedDecimalNoPrecision",
11+
"bsonType": "decimal",
12+
"queries": {
13+
"queryType": "rangePreview",
14+
"contention": {
15+
"$numberLong": "0"
916
},
10-
"path": "encryptedDecimalNoPrecision",
11-
"bsonType": "decimal",
12-
"queries": {
13-
"queryType": "rangePreview",
14-
"sparsity": {
15-
"$numberInt": "1"
16-
}
17+
"sparsity": {
18+
"$numberLong": "1"
1719
}
1820
}
19-
]
20-
}
21-
21+
}
22+
]
23+
}

test/spec/client-side-encryption/etc/data/range-encryptedFields-DecimalPrecision.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
"bsonType": "decimal",
1212
"queries": {
1313
"queryType": "rangePreview",
14+
"contention": {
15+
"$numberLong": "0"
16+
},
1417
"sparsity": {
15-
"$numberInt": "1"
18+
"$numberLong": "1"
1619
},
1720
"min": {
1821
"$numberDecimal": "0.0"
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
{
2-
"fields": [
3-
{
4-
"keyId": {
5-
"$binary": {
6-
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7-
"subType": "04"
8-
}
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedDoubleNoPrecision",
11+
"bsonType": "double",
12+
"queries": {
13+
"queryType": "rangePreview",
14+
"contention": {
15+
"$numberLong": "0"
916
},
10-
"path": "encryptedDoubleNoPrecision",
11-
"bsonType": "double",
12-
"queries": {
13-
"queryType": "rangePreview",
14-
"sparsity": {
15-
"$numberLong": "1"
16-
}
17+
"sparsity": {
18+
"$numberLong": "1"
1719
}
1820
}
19-
]
20-
}
21-
21+
}
22+
]
23+
}
Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
{
2-
"fields": [
3-
{
4-
"keyId": {
5-
"$binary": {
6-
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7-
"subType": "04"
8-
}
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedDoublePrecision",
11+
"bsonType": "double",
12+
"queries": {
13+
"queryType": "rangePreview",
14+
"contention": {
15+
"$numberLong": "0"
16+
},
17+
"sparsity": {
18+
"$numberLong": "1"
19+
},
20+
"min": {
21+
"$numberDouble": "0.0"
22+
},
23+
"max": {
24+
"$numberDouble": "200.0"
925
},
10-
"path": "encryptedDoublePrecision",
11-
"bsonType": "double",
12-
"queries": {
13-
"queryType": "rangePreview",
14-
"sparsity": {
15-
"$numberLong": "1"
16-
},
17-
"min": {
18-
"$numberDouble": "0.0"
19-
},
20-
"max": {
21-
"$numberDouble": "200.0"
22-
},
23-
"precision": {
24-
"$numberInt": "2"
25-
}
26+
"precision": {
27+
"$numberInt": "2"
2628
}
2729
}
28-
]
29-
}
30-
30+
}
31+
]
32+
}
Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
{
2-
"fields": [
3-
{
4-
"keyId": {
5-
"$binary": {
6-
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7-
"subType": "04"
8-
}
2+
"fields": [
3+
{
4+
"keyId": {
5+
"$binary": {
6+
"base64": "EjRWeBI0mHYSNBI0VniQEg==",
7+
"subType": "04"
8+
}
9+
},
10+
"path": "encryptedInt",
11+
"bsonType": "int",
12+
"queries": {
13+
"queryType": "rangePreview",
14+
"contention": {
15+
"$numberLong": "0"
16+
},
17+
"sparsity": {
18+
"$numberLong": "1"
19+
},
20+
"min": {
21+
"$numberInt": "0"
922
},
10-
"path": "encryptedInt",
11-
"bsonType": "int",
12-
"queries": {
13-
"queryType": "rangePreview",
14-
"sparsity": {
15-
"$numberLong": "1"
16-
},
17-
"min": {
18-
"$numberInt": "0"
19-
},
20-
"max": {
21-
"$numberInt": "200"
22-
}
23+
"max": {
24+
"$numberInt": "200"
2325
}
2426
}
25-
]
26-
}
27-
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)