Skip to content

chore: use new mongodb-client-encryption and update filter to support versions #4132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}