Skip to content

Commit 9b18fdd

Browse files
WIP
1 parent b8bf5c8 commit 9b18fdd

File tree

11 files changed

+127
-37
lines changed

11 files changed

+127
-37
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
lib
3+
.nyc_output
4+
docs
5+
*dylib
6+
*md

.evergreen/docker/Dockerfile.musl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG ARCH=arm64
2+
ARG NODE_VERSION=16.20.1
3+
4+
FROM ${ARCH}/node:${NODE_VERSION}-alpine AS dependencies
5+
6+
RUN apk --no-cache add make g++ libc-dev curl bash python3 py3-pip cmake git vim ranger
7+
8+
RUN python3 --version
9+
RUN git --version
10+
RUN c++ --version
11+
RUN g++ --version
12+
13+
RUN git clone https://github.com/baileympearson/mongodb-client-encryption.git && cd mongodb-client-encryption && git switch alpine && npm run install:libmongocrypt
14+
15+
WORKDIR /node-mongodb-native
16+
COPY . .
17+
RUN npm install ../mongodb-client-encryption
18+
19+
# RUN echo "host.docker.internal localhost" >>/etc/hosts

.evergreen/run-alpine-fle-tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#! /usr/bin/env bash
2+
3+
source secrets-export.sh
4+
5+
npx mocha \
6+
--config test/mocha_mongodb.json \
7+
test/integration/node-specific/client_encryption.test.ts \
8+
test/integration/client-side-encryption/client_side_encryption.prose.22.range_explicit_encryption.test.ts

etc/docker.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /bin/bash
2+
3+
# script to aid in local testing of linux platforms
4+
# requires a running docker instance
5+
6+
# s390x, arm64, amd64 for ubuntu
7+
# amd64 or arm64v8 for alpine
8+
LINUX_ARCH=arm64v8
9+
10+
# 16.20.1+, default 16.20.1
11+
NODE_VERSION=20.0.0
12+
13+
SCRIPT_DIR=$(dirname ${BASH_SOURCE:-$0})
14+
PROJECT_DIR=$SCRIPT_DIR/..
15+
16+
# bash $DRIVERS_TOOLS/.evergreen/secrets_handling/setup-secrets.sh drivers/csfle
17+
18+
BASE_TAG=$LINUX_ARCH-alpine-base-node-$NODE_VERSION
19+
20+
# podman build --load --progress=plain \
21+
# --platform linux/$LINUX_ARCH \
22+
# --build-arg="ARCH=$LINUX_ARCH" \
23+
# --build-arg="NODE_VERSION=$NODE_VERSION" \
24+
# --build-arg="RUN_TEST=true" \
25+
# -f ./.evergreen/docker/Dockerfile.musl -t test-tag-1 \
26+
# .
27+
28+
MONGODB_URI=$(echo $MONGODB_URI | sed 's/127.0.0.1/host.containers.internal/g')
29+
30+
set -o xtrace
31+
# echo "launching process"
32+
33+
# docker --debug run --platform linux/$LINUX_ARCH -e MONGODB_URI=${MONGODB_URI} --entrypoint bash test-tag-1 '.evergreen/run-alpine-fle-tests.sh'
34+
podman run --platform linux/arm64v8/v8 -e MONGODB_URI=$MONGODB_URI --entrypoint bash -i -t localhost/test-tag-1:latest

test/integration/client-side-encryption/client_side_encryption.prose.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const getKmsProviders = (localKey, kmipEndpoint, azureEndpoint, gcpEndpoint) =>
4141
return result;
4242
};
4343

44-
const noop = () => {};
44+
const noop = () => { };
4545
const metadata = {
4646
requires: {
4747
clientSideEncryption: true,
@@ -1348,7 +1348,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
13481348

13491349
// TODO(NODE-3151): Implement kms prose tests
13501350
describe('KMS TLS Tests', () => {
1351-
it.skip('TBD', () => {}).skipReason = 'TODO(NODE-3151): Implement "KMS TLS Tests"';
1351+
it.skip('TBD', () => { }).skipReason = 'TODO(NODE-3151): Implement "KMS TLS Tests"';
13521352
});
13531353

13541354
/**
@@ -1689,7 +1689,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
16891689
context(
16901690
'Case 5: `tlsDisableOCSPEndpointCheck` is permitted',
16911691
metadata,
1692-
function () {}
1692+
function () { }
16931693
).skipReason = 'TODO(NODE-4840): Node does not support any OCSP options';
16941694

16951695
context('Case 6: named KMS providers apply TLS options', function () {
@@ -2421,7 +2421,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
24212421
// keyVaultClient: <new MongoClient>,
24222422
// keyVaultNamespace: "keyvault.datakeys",
24232423
// kmsProviders: <all KMS providers>,
2424-
before(function () {
2424+
beforeEach(function () {
24252425
client = this.configuration.newClient();
24262426
clientEncryption = new ClientEncryption(client, {
24272427
keyVaultNamespace: 'keyvault.datakeys',
@@ -2431,7 +2431,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
24312431
});
24322432
});
24332433

2434-
after(async function () {
2434+
afterEach(async function () {
24352435
await client?.close();
24362436
});
24372437

test/integration/client-side-encryption/client_side_encryption.spec.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const isServerless = !!process.env.SERVERLESS;
6262

6363
const filter = new ClientSideEncryptionFilter();
6464

65-
describe('Client Side Encryption (Legacy)', function () {
65+
describe.only('Client Side Encryption (Legacy)', function () {
6666
const testContext = new TestRunnerContext({ requiresCSFLE: true });
6767
const testSuites = gatherTestSuites(
6868
path.join(__dirname, '../../spec/client-side-encryption/tests/legacy'),

test/integration/node-specific/client_encryption.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ describe('ClientEncryption integration tests', function () {
466466
// Data Key Stuff
467467
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
468468
const AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET_ACCESS_KEY;
469-
const AWS_REGION = process.env.AWS_REGION;
470-
const AWS_CMK_ID = process.env.AWS_CMK_ID;
469+
const AWS_REGION = 'us-east-1';
470+
const AWS_CMK_ID = 'foo-bar-baz';
471471

472472
const kmsProviders = {
473473
aws: { accessKeyId: AWS_ACCESS_KEY_ID, secretAccessKey: AWS_SECRET_ACCESS_KEY }

test/integration/node-specific/resource_clean_up.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Driver Resources', () => {
3333
});
3434

3535
context('on MongoClient.close()', () => {
36-
before('create leak reproduction script', async function () {
36+
beforeEach('create leak reproduction script', async function () {
3737
if (globalThis.AbortController == null || typeof this.configuration.serverApi === 'string') {
3838
return;
3939
}

test/tools/runner/config.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ export class TestConfiguration {
116116
replicaSet: url.searchParams.get('replicaSet'),
117117
proxyURIParams: url.searchParams.get('proxyHost')
118118
? {
119-
proxyHost: url.searchParams.get('proxyHost'),
120-
proxyPort: Number(url.searchParams.get('proxyPort')),
121-
proxyUsername: url.searchParams.get('proxyUsername'),
122-
proxyPassword: url.searchParams.get('proxyPassword')
123-
}
119+
proxyHost: url.searchParams.get('proxyHost'),
120+
proxyPort: Number(url.searchParams.get('proxyPort')),
121+
proxyUsername: url.searchParams.get('proxyUsername'),
122+
proxyPassword: url.searchParams.get('proxyPassword')
123+
}
124124
: undefined
125125
};
126126
if (url.username) {
@@ -204,6 +204,13 @@ export class TestConfiguration {
204204
throw new Error(`Cannot use options to specify host/port, must be in ${urlOrQueryOptions}`);
205205
}
206206

207+
if (serverOptions.autoEncryption) {
208+
serverOptions.autoEncryption.extraOptions = {
209+
mongocryptdBypassSpawn: true,
210+
mongocryptdURI: 'mongodb://host.containers.internal:3000'
211+
}
212+
}
213+
207214
return new MongoClient(urlOrQueryOptions, serverOptions);
208215
}
209216

@@ -280,6 +287,14 @@ export class TestConfiguration {
280287
delete urlOptions.query?.auth;
281288
}
282289

290+
if (serverOptions.autoEncryption) {
291+
serverOptions.autoEncryption.extraOptions = {
292+
mongocryptdBypassSpawn: true,
293+
mongocryptdURI: 'mongodb://localhost:3000'
294+
}
295+
console.error('annotating');
296+
}
297+
283298
const connectionString = url.format(urlOptions);
284299

285300
return new MongoClient(connectionString, serverOptions);

test/tools/spec-runner/context.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ class TestRunnerContext {
9595
? `${extractAuthFromConnectionString(process.env.MONGODB_URI)}@`
9696
: '';
9797
return config.newClient(
98-
`mongodb://${authString}${proxy.host}:${proxy.port}/${
99-
process.env.AUTH === 'auth' ? '?authSource=admin' : ''
98+
`mongodb://${authString}${proxy.host}:${proxy.port}/${process.env.AUTH === 'auth' ? '?authSource=admin' : ''
10099
}`
101100
);
102101
});
@@ -248,8 +247,8 @@ function findMatchingEvents(context, eventName) {
248247
const allEvents = context.sdamEvents.concat(context.cmapEvents);
249248
return eventName === 'ServerMarkedUnknownEvent'
250249
? context.sdamEvents
251-
.filter(event => event.constructor.name === 'ServerDescriptionChangedEvent')
252-
.filter(event => event.newDescription.type === 'Unknown')
250+
.filter(event => event.constructor.name === 'ServerDescriptionChangedEvent')
251+
.filter(event => event.newDescription.type === 'Unknown')
253252
: allEvents.filter(event => event.constructor.name.match(new RegExp(eventName)));
254253
}
255254

0 commit comments

Comments
 (0)