/
uri_options.spec.test.ts
72 lines (61 loc) · 2.86 KB
/
uri_options.spec.test.ts
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
66
67
68
69
70
71
72
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 = [
// TODO(NODE-3917): Fix directConnection and loadBalanced option validation
'directConnection=true with multiple seeds',
'loadBalanced=true with directConnection=false causes an error',
// Skipped because this does not apply to Node
'Valid options specific to single-threaded drivers are parsed correctly',
// TODO(NODE-3921): fix tls option validation
'tlsInsecure and tlsAllowInvalidCertificates both present (and true) raises an error',
'tlsInsecure and tlsAllowInvalidCertificates both present (and false) raises an error',
'tlsAllowInvalidCertificates and tlsInsecure both present (and true) raises an error',
'tlsAllowInvalidCertificates and tlsInsecure both present (and false) raises an error',
'tlsAllowInvalidHostnames and tlsInsecure both present (and true) raises an error',
'tlsAllowInvalidHostnames and tlsInsecure both present (and false) raises an error',
'tlsInsecure and tlsAllowInvalidHostnames both present (and true) raises an error',
'tlsInsecure and tlsAllowInvalidHostnames both present (and false) raises an error',
// TODO(NODE-3922): have not implemented option support
'tlsDisableCertificateRevocationCheck can be set to true',
'tlsDisableCertificateRevocationCheck can be set to false',
'tlsDisableOCSPEndpointCheck can be set to true',
'tlsDisableOCSPEndpointCheck can be set to false'
];
const testsThatDoNotThrowOnWarn = [
// TODO(NODE-3923): compression option validation
'Too high zlibCompressionLevel causes a warning',
'Too low zlibCompressionLevel causes a warning',
// TODO(NODE-3917): Fix directConnection and loadBalanced option validation
'Invalid loadBalanced value'
];
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)
);
});
}
});
}
});