Skip to content

Commit ced586e

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 a29020d commit ced586e

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
@@ -3,7 +3,7 @@ import ResultObserver from './result-observer.js'
33
import { cypherToNative, nativeToCypher } from './cypher-native-binders.js'
44
import { shouldRunTest } from './skipped-tests'
55

6-
export function NewDriver (context, data, { writeResponse }) {
6+
export function NewDriver (context, data, wire) {
77
const {
88
uri,
99
authorizationToken: { data: authToken },
@@ -37,17 +37,39 @@ export function NewDriver (context, data, { writeResponse }) {
3737
? address =>
3838
new Promise((resolve, reject) => {
3939
const id = context.addResolverRequest(resolve, reject)
40-
writeResponse('ResolverResolutionRequired', { id, address })
40+
wire.writeResponse('ResolverResolutionRequired', { id, address })
4141
})
4242
: undefined
43-
const driver = neo4j.driver(uri, parsedAuthToken, {
43+
const config = {
4444
userAgent,
4545
resolver,
4646
useBigInt: true,
4747
logging: neo4j.logging.console(process.env.LOG_LEVEL)
48-
})
48+
}
49+
if ('encrypted' in data) {
50+
config.encrypted = data.encrypted ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF'
51+
}
52+
if ('trustedCertificates' in data) {
53+
if (data.trustedCertificates === null) {
54+
config.trust = 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'
55+
} else if (data.trustedCertificates.length === 0) {
56+
config.trust = 'TRUST_ALL_CERTIFICATES'
57+
} else {
58+
config.trust = 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'
59+
config.trustedCertificates = data.trustedCertificates.map(
60+
e => '/usr/local/share/custom-ca-certificates/' + e
61+
)
62+
}
63+
}
64+
let driver
65+
try {
66+
driver = neo4j.driver(uri, parsedAuthToken, config)
67+
} catch (err) {
68+
wire.writeError(err)
69+
return
70+
}
4971
const id = context.addDriver(driver)
50-
writeResponse('Driver', { id })
72+
wire.writeResponse('Driver', { id })
5173
}
5274

5375
export function DriverClose (context, data, wire) {
@@ -265,6 +287,8 @@ export function GetFeatures (_context, _params, wire) {
265287
'Feature:Auth:Custom',
266288
'Feature:Auth:Kerberos',
267289
'Feature:Auth:Bearer',
290+
'Feature:API:SSLConfig',
291+
'Feature:API:SSLSchemes',
268292
'AuthorizationExpiredTreatment',
269293
'ConfHint:connection.recv_timeout_seconds',
270294
'Feature:Bolt:4.4',

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)