Skip to content

Commit

Permalink
chore: use new mongodb-client-encryption and update filter to support…
Browse files Browse the repository at this point in the history
… versions (#4132)
  • Loading branch information
baileympearson authored Jun 5, 2024
1 parent f790cc1 commit 65c9267
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
9 changes: 8 additions & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ declare global {
mongodb?: string;
os?: NodeJS.Platform | `!${NodeJS.Platform}`;
apiVersion?: '1' | boolean;
clientSideEncryption?: boolean;

/**
* require FLE to be set up to run the test
*
* A semver range may be provided as well to enforce a particular version range
* of mongodb-client-encryption. Ex: `clientSideEncryption: '>=6.0.1'`
*/
clientSideEncryption?: string | true;
serverless?: 'forbid' | 'allow' | 'require';
auth?: 'enabled' | 'disabled';
idmsMockServer?: true;
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"js-yaml": "^4.1.0",
"mocha": "^10.4.0",
"mocha-sinon": "^2.1.2",
"mongodb-client-encryption": "^6.0.0",
"mongodb-client-encryption": "^6.0.1",
"mongodb-legacy": "^6.0.1",
"nyc": "^15.1.0",
"prettier": "^2.8.8",
Expand Down
10 changes: 7 additions & 3 deletions test/tools/runner/filters/client_encryption_filter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readFile } from 'fs/promises';
import { dirname, resolve } from 'path';
import * as process from 'process';
import { satisfies } from 'semver';

import { type MongoClient } from '../../../mongodb';
import { Filter } from './filter';
Expand Down Expand Up @@ -59,15 +60,18 @@ export class ClientSideEncryptionFilter extends Filter {
return true;
}

if (clientSideEncryption !== true) {
throw new Error('ClientSideEncryptionFilter can only be set to true');
if (clientSideEncryption === false) {
throw new Error(
'ClientSideEncryptionFilter can only be set to true or a semver version range.'
);
}

// TODO(NODE-3401): unskip csfle tests on windows
if (process.env.TEST_CSFLE && !this.enabled && process.platform !== 'win32') {
throw new Error('Expected CSFLE to be enabled in the CI');
}
const validRange = typeof clientSideEncryption === 'string' ? clientSideEncryption : '>=0.0.0';

return this.enabled;
return this.enabled && satisfies(ClientSideEncryptionFilter.version, validRange);
}
}

0 comments on commit 65c9267

Please sign in to comment.