Skip to content

Commit 94e356e

Browse files
robsdedudebigmontz
authored andcommitted
Add support for TestKit's new SSL tests
* Enable feature flags `Feature:API:SSLConfig` and `Feature:API:SSLSchemes` * Map TestKit's ssl config options to driver's native options * Adjust TestKit image Docker file to copy customCA certificates
1 parent 28532f4 commit 94e356e

File tree

4 files changed

+38
-21
lines changed

4 files changed

+38
-21
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ docs/build
1717
coverage
1818
.vscode
1919
*.code-workspace
20-
/testkit/CAs
20+
/testkit/CAs
21+
/testkit/CustomCAs

packages/testkit-backend/src/request-handlers.js

+29-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const SUPPORTED_TLS = (() => {
1414
return result;
1515
})();
1616

17-
export function NewDriver (context, data, { writeResponse }) {
17+
export function NewDriver (context, data, wire) {
1818
const {
1919
uri,
2020
authorizationToken: { data: authToken },
@@ -48,17 +48,39 @@ export function NewDriver (context, data, { writeResponse }) {
4848
? address =>
4949
new Promise((resolve, reject) => {
5050
const id = context.addResolverRequest(resolve, reject)
51-
writeResponse('ResolverResolutionRequired', { id, address })
51+
wire.writeResponse('ResolverResolutionRequired', { id, address })
5252
})
5353
: undefined
54-
const driver = neo4j.driver(uri, parsedAuthToken, {
54+
const config = {
5555
userAgent,
5656
resolver,
5757
useBigInt: true,
5858
logging: neo4j.logging.console(process.env.LOG_LEVEL)
59-
})
59+
}
60+
if ('encrypted' in data) {
61+
config.encrypted = data.encrypted ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF'
62+
}
63+
if ('trustedCertificates' in data) {
64+
if (data.trustedCertificates === null) {
65+
config.trust = 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'
66+
} else if (data.trustedCertificates.length === 0) {
67+
config.trust = 'TRUST_ALL_CERTIFICATES'
68+
} else {
69+
config.trust = 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'
70+
config.trustedCertificates = data.trustedCertificates.map(
71+
e => '/usr/local/share/custom-ca-certificates/' + e
72+
)
73+
}
74+
}
75+
let driver
76+
try {
77+
driver = neo4j.driver(uri, parsedAuthToken, config)
78+
} catch (err) {
79+
wire.writeError(err)
80+
return
81+
}
6082
const id = context.addDriver(driver)
61-
writeResponse('Driver', { id })
83+
wire.writeResponse('Driver', { id })
6284
}
6385

6486
export function DriverClose (context, data, wire) {
@@ -276,6 +298,8 @@ export function GetFeatures (_context, _params, wire) {
276298
'Feature:Auth:Custom',
277299
'Feature:Auth:Kerberos',
278300
'Feature:Auth:Bearer',
301+
'Feature:API:SSLConfig',
302+
'Feature:API:SSLSchemes',
279303
'AuthorizationExpiredTreatment',
280304
'ConfHint:connection.recv_timeout_seconds',
281305
'Feature:Impersonation',

testkit/CAs/trustedRoot.crt

-10
This file was deleted.

testkit/Dockerfile

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN apt-get update && \
99
curl \
1010
python3 \
1111
nodejs \
12-
npm \
12+
npm \
1313
firefox \
1414
&& rm -rf /var/lib/apt/lists/*
1515

@@ -18,18 +18,20 @@ RUN npm install -g npm \
1818
RUN npm install -g gulp
1919

2020
# Enable tls v1.0
21-
RUN echo "openssl_conf = openssl_configuration\n"|cat - /etc/ssl/openssl.cnf > /tmp/openssl_conf.cnf \
22-
&& mv /tmp/openssl_conf.cnf /etc/ssl/openssl.cnf
21+
RUN echo "openssl_conf = openssl_configuration\n"|cat - /etc/ssl/openssl.cnf > /tmp/openssl_conf.cnf \
22+
&& mv /tmp/openssl_conf.cnf /etc/ssl/openssl.cnf
2323
RUN echo "[openssl_configuration]\n\
2424
ssl_conf = ssl_configuration\n\
2525
[ssl_configuration]\n\
2626
system_default = tls_system_default\n\
2727
[tls_system_default]\n\
28-
CipherString = DEFAULT:@SECLEVEL=1" >> /etc/ssl/openssl.cnf
28+
CipherString = DEFAULT:@SECLEVEL=1" >> /etc/ssl/openssl.cnf
2929

3030
# Install our own CAs on the image.
3131
# Assumes Linux Debian based image.
3232
COPY CAs/* /usr/local/share/ca-certificates/
33+
# Store custom CAs somewhere where the backend can find them later.
34+
COPY CustomCAs/* /usr/local/share/custom-ca-certificates/
3335
RUN update-ca-certificates
3436

3537
# Creating an user for building the driver and running the tests
@@ -40,4 +42,4 @@ USER driver
4042
WORKDIR /home/driver
4143
CMD /bin/bash
4244
RUN mkdir /home/driver/.npm_global
43-
RUN npm config set prefix /home/driver/.npm_global
45+
RUN npm config set prefix /home/driver/.npm_global

0 commit comments

Comments
 (0)