Skip to content

Commit 1a340ad

Browse files
asdf
1 parent 25edf64 commit 1a340ad

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

test/tools/runner/filters/client_encryption_filter.ts

+41-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,43 @@ import * as process from 'process';
44
import { satisfies } from 'semver';
55

66
import { kmsCredentialsPresent } from '../../../csfle-kms-providers';
7-
import { type MongoClient } from '../../../mongodb';
7+
import { AutoEncrypter, MongoClient } from '../../../mongodb';
88
import { Filter } from './filter';
99

10+
function getCryptSharedVersion(): AutoEncrypter['cryptSharedLibVersionInfo'] | null {
11+
try {
12+
const mc = new MongoClient('mongodb://localhost:27017', {
13+
autoEncryption: {
14+
kmsProviders: {
15+
local: {
16+
key: Buffer.alloc(96)
17+
}
18+
},
19+
extraOptions: {
20+
cryptSharedLibPath: process.env.CRYPT_SHARED_LIB_PATH
21+
}
22+
}
23+
});
24+
return mc.autoEncrypter.cryptSharedLibVersionInfo;
25+
} catch (error) {
26+
try {
27+
const mc = new MongoClient('mongodb://localhost:27017', {
28+
autoEncryption: {
29+
kmsProviders: {
30+
local: {
31+
key: Buffer.alloc(96)
32+
}
33+
}
34+
}
35+
});
36+
return mc.autoEncrypter.cryptSharedLibVersionInfo;
37+
} catch {
38+
}
39+
}
40+
41+
return null;
42+
}
43+
1044
/**
1145
* Filter for whether or not a test needs / doesn't need Client Side Encryption
1246
*
@@ -24,15 +58,18 @@ export class ClientSideEncryptionFilter extends Filter {
2458
enabled: boolean;
2559
static version = null;
2660
static libmongocrypt: string | null = null;
61+
static cryptShared: AutoEncrypter['cryptSharedLibVersionInfo'] | null = null;
2762

2863
override async initializeFilter(client: MongoClient, context: Record<string, any>) {
29-
let mongodbClientEncryption;
64+
let mongodbClientEncryption: typeof import('mongodb-client-encryption');
3065
try {
3166
// eslint-disable-next-line @typescript-eslint/no-require-imports
3267
mongodbClientEncryption = require('mongodb-client-encryption');
3368
ClientSideEncryptionFilter.libmongocrypt = (
3469
mongodbClientEncryption as typeof import('mongodb-client-encryption')
3570
).MongoCrypt.libmongocryptVersion;
71+
72+
ClientSideEncryptionFilter.cryptShared = getCryptSharedVersion();
3673
} catch (failedToGetFLELib) {
3774
if (process.env.TEST_CSFLE) {
3875
console.error({ failedToGetFLELib });
@@ -53,7 +90,8 @@ export class ClientSideEncryptionFilter extends Filter {
5390
enabled: this.enabled,
5491
mongodbClientEncryption,
5592
version: ClientSideEncryptionFilter.version,
56-
libmongocrypt: ClientSideEncryptionFilter.libmongocrypt
93+
libmongocrypt: ClientSideEncryptionFilter.libmongocrypt,
94+
cryptShared: ClientSideEncryptionFilter.cryptShared
5795
};
5896
}
5997

test/tools/runner/hooks/configuration.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ const testConfigBeforeHook = async function () {
176176
auth: process.env.AUTH === 'auth',
177177
tls: process.env.SSL === 'ssl',
178178
csfle: {
179-
enabled: this.configuration.clientSideEncryption.enabled,
180-
version: this.configuration.clientSideEncryption.version,
181-
libmongocrypt: this.configuration.clientSideEncryption.libmongocrypt
179+
...this.configuration.clientSideEncryption
182180
},
183181
serverApi: MONGODB_API_VERSION,
184182
atlas: process.env.ATLAS_CONNECTIVITY != null,

0 commit comments

Comments
 (0)