-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathuri_options.spec.test.ts
More file actions
65 lines (55 loc) · 2.36 KB
/
uri_options.spec.test.ts
File metadata and controls
65 lines (55 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { unlinkSync, writeFileSync } from 'fs';
import { loadSpecTests } from '../../spec';
import { executeUriValidationTest } from '../../tools/uri_spec_runner';
describe('URI option spec tests', function () {
const suites = loadSpecTests('uri-options');
const skipTests = [
// Skipped because this does not apply to Node
'Valid options specific to single-threaded drivers are parsed correctly',
// These options are specific to OCSP which the driver does not implement
// and will not be implemented in the future. Note that the other URI
// option tests that are testing these options are passing, simply because
// they are testing error conditions and the driver is throwing a MongoParseError
// when either of these options are provided.
'tlsDisableCertificateRevocationCheck can be set to true',
'tlsDisableCertificateRevocationCheck can be set to false',
'tlsDisableOCSPEndpointCheck can be set to true',
'tlsDisableOCSPEndpointCheck can be set to false',
// NOTE(NODE-3989): Skipped because we now only accept true/false for boolean options. The spec expects us to
// warn on other accepted but deprecated values, but as of NODE-3989, we now throw on these
// values
'Invalid loadBalanced value'
];
const testsThatDoNotThrowOnWarn = [
// TODO(NODE-3923): compression option validation
'Too high zlibCompressionLevel causes a warning',
'Too low zlibCompressionLevel causes a warning'
];
for (const suite of suites) {
describe(suite.name, function () {
// set up files for tlsCAfile and tlsCertificateKeyFile
// until we implement NODE-3924, the contents of the files is what is stored
// in the corresponding properties, so we make the contents equal the file names
// for the sake of the test expectations
before(() => {
writeFileSync('ca.pem', 'ca.pem');
writeFileSync('cert.pem', 'cert.pem');
});
after(() => {
unlinkSync('ca.pem');
unlinkSync('cert.pem');
});
for (const test of suite.tests) {
it(`${test.description}`, function () {
if (skipTests.includes(test.description)) {
return this.skip();
}
executeUriValidationTest(
test,
testsThatDoNotThrowOnWarn.some(t => t === test.description)
);
});
}
});
}
});