Skip to content

Commit 6b117b0

Browse files
Fix crypt shared issues - not sure why this fixes the problems, but it seems to.
1 parent 90e61db commit 6b117b0

File tree

7 files changed

+40
-59
lines changed

7 files changed

+40
-59
lines changed

.evergreen/prepare-crypt-shared-lib.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

.evergreen/setup-fle.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ bash ${DRIVERS_TOOLS}/.evergreen/csfle/setup-secrets.sh
44
source secrets-export.sh
55

66
if [ -z "${RUN_WITH_MONGOCRYPTD}" ]; then
7-
# Set up crypt shared lib if we don't want to use mongocryptd
8-
bash .evergreen/prepare-crypt-shared-lib.sh
9-
source crypt_shared.sh
10-
echo "CRYPT_SHARED_LIB_PATH: $CRYPT_SHARED_LIB_PATH"
7+
echo "crypt shared: $CRYPT_SHARED_LIB_PATH"
118
else
9+
rm $CRYPT_SHARED_LIB_PATH
10+
unset CRYPT_SHARED_LIB_PATH
1211
echo "CRYPT_SHARED_LIB_PATH not set; using mongocryptd"
1312
fi

src/client-side-encryption/auto_encrypter.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { MongoCryptInvalidArgumentError } from './errors';
1919
import { MongocryptdManager } from './mongocryptd_manager';
2020
import { type KMSProviders, refreshKMSCredentials } from './providers';
2121
import { type CSFLEKMSTlsOptions, StateMachine } from './state_machine';
22+
import { createWriteStream } from 'fs';
2223

2324
/** @public */
2425
export interface AutoEncryptionOptions {
@@ -123,6 +124,8 @@ export const AutoEncryptionLoggerLevel = Object.freeze({
123124
Trace: 4
124125
} as const);
125126

127+
const searchPaths = new Set<string>();
128+
const logs = createWriteStream('./logs');
126129
/**
127130
* @public
128131
* The level of severity of the log message
@@ -262,6 +265,12 @@ export class AutoEncrypter {
262265
}
263266

264267
if (options.extraOptions && options.extraOptions.cryptSharedLibPath) {
268+
if (!searchPaths.has(options.extraOptions.cryptSharedLibPath)) {
269+
console.error("********* ", options.extraOptions.cryptSharedLibPath);
270+
logs.write(options.extraOptions.cryptSharedLibPath);
271+
logs.write('\n');
272+
}
273+
searchPaths.add(options.extraOptions.cryptSharedLibPath);
265274
mongoCryptOptions.cryptSharedLibPath = options.extraOptions.cryptSharedLibPath;
266275
}
267276

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const path = require('path');
77
const { dropCollection, APMEventCollector } = require('../shared');
88

99
const { EJSON } = BSON;
10-
const { LEGACY_HELLO_COMMAND, MongoCryptError } = require('../../mongodb');
10+
const { LEGACY_HELLO_COMMAND, MongoCryptError, AutoEncrypter } = require('../../mongodb');
1111
const { MongoServerError, MongoServerSelectionError, MongoClient } = require('../../mongodb');
1212
const { getEncryptExtraOptions } = require('../../tools/utils');
1313

@@ -42,7 +42,7 @@ const getKmsProviders = (localKey, kmipEndpoint, azureEndpoint, gcpEndpoint) =>
4242
return result;
4343
};
4444

45-
const noop = () => {};
45+
const noop = () => { };
4646
const metadata = {
4747
requires: {
4848
clientSideEncryption: true,
@@ -1105,6 +1105,14 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
11051105
describe('Bypass spawning mongocryptd', function () {
11061106
describe('via mongocryptdBypassSpawn', function () {
11071107
let clientEncrypted;
1108+
1109+
beforeEach(`cannot run on Alpine linux.`, function () {
1110+
if (this.configuration instanceof AlpineTestConfiguration) {
1111+
this.currentTest.skipReason =
1112+
'alpine tests cannot spawn mongocryptds or use the crypt_shared.';
1113+
this.skip();
1114+
}
1115+
})
11081116
// Create a MongoClient configured with auto encryption
11091117
// Configure the required options. use the `local` KMS provider as follows:
11101118
// ```javascript
@@ -1114,12 +1122,6 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
11141122
// configure with `client_encrypted` to use the schema `external/external-schema.json` for
11151123
// `db.coll` by setting a schema map like `{"db.coll": <contents of external-schema.json }`
11161124
beforeEach(async function () {
1117-
if (this.configuration instanceof AlpineTestConfiguration) {
1118-
this.currentTest.skipReason =
1119-
'alpine tests cannot spawn mongocryptds or use the crypt_shared.';
1120-
this.skip();
1121-
}
1122-
11231125
clientEncrypted = this.configuration.newClient(
11241126
{},
11251127
{
@@ -1146,7 +1148,8 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
11461148
mongocryptdSpawnArgs: [
11471149
'--pidfilepath=bypass-spawning-mongocryptd.pid',
11481150
'--port=27021'
1149-
]
1151+
],
1152+
cryptSharedLibSearchPaths: []
11501153
}
11511154
}
11521155
}
@@ -1355,7 +1358,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
13551358

13561359
// TODO(NODE-3151): Implement kms prose tests
13571360
describe('KMS TLS Tests', () => {
1358-
it.skip('TBD', () => {}).skipReason = 'TODO(NODE-3151): Implement "KMS TLS Tests"';
1361+
it.skip('TBD', () => { }).skipReason = 'TODO(NODE-3151): Implement "KMS TLS Tests"';
13591362
});
13601363

13611364
/**
@@ -1696,7 +1699,7 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
16961699
context(
16971700
'Case 5: `tlsDisableOCSPEndpointCheck` is permitted',
16981701
metadata,
1699-
function () {}
1702+
function () { }
17001703
).skipReason = 'TODO(NODE-4840): Node does not support any OCSP options';
17011704

17021705
context('Case 6: named KMS providers apply TLS options', function () {

test/integration/client-side-encryption/driver.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,14 +771,15 @@ describe('CSOT', function () {
771771
autoEncryption: {
772772
keyVaultClient,
773773
keyVaultNamespace: 'admin.datakeys',
774-
kmsProviders: getLocalKmsProvider()
774+
kmsProviders: getLocalKmsProvider(),
775+
extraOptions: getEncryptExtraOptions()
775776
}
776777
}
777778
);
778779
});
779780

780781
afterEach(async function () {
781-
await encryptedClient.close();
782+
await encryptedClient?.close();
782783
});
783784

784785
it('the command succeeds', metadata, async function () {

test/integration/client-side-operations-timeout/client_side_operations_timeout.unit.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,20 @@ describe('CSOT spec unit tests', function () {
9191
/* eslint-disable @typescript-eslint/no-empty-function */
9292
context.skip(
9393
'If a new connection is required to execute an operation, min(remaining computedServerSelectionTimeout, connectTimeoutMS) should apply to socket establishment.',
94-
() => {}
94+
() => { }
9595
).skipReason =
9696
'TODO(DRIVERS-2347): Requires this ticket to be implemented before we can assert on connection CSOT behaviour';
9797

9898
context(
9999
'For drivers that have control over OCSP behavior, min(remaining computedServerSelectionTimeout, 5 seconds) should apply to HTTP requests against OCSP responders.',
100-
() => {}
100+
() => { }
101101
);
102102
});
103103

104104
context.skip('Socket timeouts', function () {
105105
context(
106106
'If timeoutMS is unset, operations fail after two non-consecutive socket timeouts.',
107-
() => {}
107+
() => { }
108108
);
109109
}).skipReason =
110110
'TODO(NODE-6518): Add CSOT support for socket read/write at the connection layer for CRUD APIs';
@@ -113,7 +113,7 @@ describe('CSOT spec unit tests', function () {
113113
describe('KMS requests', function () {
114114
const stateMachine = new StateMachine({} as any);
115115
const request = {
116-
addResponse: _response => {},
116+
addResponse: _response => { },
117117
status: {
118118
type: 1,
119119
code: 1,
@@ -127,7 +127,7 @@ describe('CSOT spec unit tests', function () {
127127

128128
context('when StateMachine.kmsRequest() is passed a `CSOTimeoutContext`', function () {
129129
beforeEach(async function () {
130-
sinon.stub(TLSSocket.prototype, 'connect').callsFake(function (..._args) {});
130+
sinon.stub(TLSSocket.prototype, 'connect').callsFake(function (..._args) { });
131131
});
132132

133133
afterEach(async function () {
@@ -200,7 +200,8 @@ describe('CSOT spec unit tests', function () {
200200
mongocryptdSpawnArgs: [
201201
`--pidfilepath=${new ObjectId().toHexString()}.pid`,
202202
'--port=27020'
203-
]
203+
],
204+
cryptSharedLibSearchPaths: []
204205
},
205206
keyVaultNamespace: 'admin.datakeys',
206207
kmsProviders: {
@@ -250,7 +251,7 @@ describe('CSOT spec unit tests', function () {
250251
context.skip('Background Connection Pooling', function () {
251252
context(
252253
'When doing minPoolSize maintenance, connectTimeoutMS is used as the timeout for socket establishment.',
253-
() => {}
254+
() => { }
254255
);
255256
}).skipReason = 'TODO(NODE-6091): Implement CSOT logic for Background Connection Pooling';
256257
/* eslint-enable @typescript-eslint/no-empty-function */

test/integration/crud/crud.prose.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
MongoServerError
1515
} from '../../mongodb';
1616
import { filterForCommands } from '../shared';
17+
import { getEncryptExtraOptions } from '../../tools/utils';
1718

1819
describe('CRUD Prose Spec Tests', () => {
1920
let client: MongoClient;
@@ -1023,7 +1024,8 @@ describe('CRUD Prose Spec Tests', () => {
10231024
accessKeyId: 'foo',
10241025
secretAccessKey: 'bar'
10251026
}
1026-
}
1027+
},
1028+
extraOptions: getEncryptExtraOptions()
10271029
}
10281030
}
10291031
);

0 commit comments

Comments
 (0)