Skip to content

Commit 35dc1a6

Browse files
committed
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 e3da4a3 commit 35dc1a6

File tree

5 files changed

+39
-21
lines changed

5 files changed

+39
-21
lines changed

.gitignore

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

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 },
@@ -14,17 +14,39 @@ export function NewDriver (context, data, { writeResponse }) {
1414
? address =>
1515
new Promise((resolve, reject) => {
1616
const id = context.addResolverRequest(resolve, reject)
17-
writeResponse('ResolverResolutionRequired', { id, address })
17+
wire.writeResponse('ResolverResolutionRequired', { id, address })
1818
})
1919
: undefined
20-
const driver = neo4j.driver(uri, authToken, {
20+
const config = {
2121
userAgent,
2222
resolver,
2323
useBigInt: true,
2424
logging: neo4j.logging.console(process.env.LOG_LEVEL)
25-
})
25+
}
26+
if ('encrypted' in data) {
27+
config.encrypted = data.encrypted ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF'
28+
}
29+
if ('trustedCertificates' in data) {
30+
if (data.trustedCertificates === null) {
31+
config.trust = 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'
32+
} else if (data.trustedCertificates.length === 0) {
33+
config.trust = 'TRUST_ALL_CERTIFICATES'
34+
} else {
35+
config.trust = 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'
36+
config.trustedCertificates = data.trustedCertificates.map(
37+
e => '/usr/local/share/custom-ca-certificates/' + e
38+
)
39+
}
40+
}
41+
let driver
42+
try {
43+
driver = neo4j.driver(uri, authToken, config)
44+
} catch (err) {
45+
wire.writeError(err)
46+
return
47+
}
2648
const id = context.addDriver(driver)
27-
writeResponse('Driver', { id })
49+
wire.writeResponse('Driver', { id })
2850
}
2951

3052
export function DriverClose (context, data, wire) {
@@ -238,6 +260,8 @@ export function StartTest (_, { testName }, wire) {
238260
export function GetFeatures (_context, _params, wire) {
239261
wire.writeResponse('FeatureList', {
240262
features: [
263+
'Feature:API:SSLConfig',
264+
'Feature:API:SSLSchemes',
241265
'AuthorizationExpiredTreatment',
242266
'ConfHint:connection.recv_timeout_seconds'
243267
]

testkit/CAs/trustedRoot.crt

-10
This file was deleted.

testkit/Dockerfile

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN apt-get update && \
1010
curl \
1111
python3 \
1212
nodejs \
13-
npm \
13+
npm \
1414
firefox \
1515
&& rm -rf /var/lib/apt/lists/*
1616

@@ -19,16 +19,19 @@ RUN npm install -g npm \
1919
RUN npm install -g gulp
2020

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

3131
# Install our own CAs on the image.
3232
# Assumes Linux Debian based image.
3333
COPY CAs/* /usr/local/share/ca-certificates/
3434
RUN update-ca-certificates
35+
36+
# Store custom CAs somewhere where the backend can find them later.
37+
COPY CustomCAs/* /usr/local/share/custom-ca-certificates/

testkit/build.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def build_testkit_backend(isLite):
4444
run(['rm', '-fr', 'testkit-backend/node_modules'])
4545
run([*npm, "install"])
4646
neo4jdriverPath = "neo4j@./"
47-
if isLite:
47+
if isLite:
4848
neo4jdriverPath = "neo4j@./neo4j-driver-lite"
4949
run([*npm, "install", neo4jdriverPath])
5050

0 commit comments

Comments
 (0)