Skip to content

Commit

Permalink
fixup: make csfle integration work
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed Dec 2, 2021
1 parent a2722ab commit a42f990
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .evergreen/run-custom-csfle-tests.sh
Expand Up @@ -36,10 +36,12 @@ pushd ../csfle-deps-tmp

rm -rf libmongocrypt mongo-c-driver

git clone https://github.com/mongodb/libmongocrypt.git
#git clone https://github.com/mongodb/libmongocrypt.git
git clone https://github.com/mongodb-js/libmongocrypt.git
pushd libmongocrypt
git fetch --tags
git checkout "$CSFLE_GIT_REF" -b csfle-custom
#git checkout "$CSFLE_GIT_REF" -b csfle-custom
git checkout "ea3f6252b55cf235e8adf3a04930479d6e5ed11f" -b csfle-custom
popd # libmongocrypt

git clone https://github.com/mongodb/mongo-c-driver.git
Expand Down
26 changes: 24 additions & 2 deletions test/tools/runner/config.js
Expand Up @@ -53,7 +53,13 @@ class TestConfiguration {
host: hostAddresses[0].host,
port: typeof hostAddresses[0].host === 'string' ? hostAddresses[0].port : undefined,
db: url.pathname.slice(1) ? url.pathname.slice(1) : 'integration_tests',
replicaSet: url.searchParams.get('replicaSet')
replicaSet: url.searchParams.get('replicaSet'),
proxyURIParams: url.searchParams.get('proxyHost') ? {
proxyHost: url.searchParams.get('proxyHost'),
proxyPort: url.searchParams.get('proxyPort'),
proxyUsername: url.searchParams.get('proxyUsername'),
proxyPassword: url.searchParams.get('proxyPassword')
} : undefined
};
if (url.username) {
this.options.auth = {
Expand Down Expand Up @@ -144,6 +150,14 @@ class TestConfiguration {
Object.assign(dbOptions, { replicaSet: this.options.replicaSet });
}

if (this.options.proxyURIParams) {
for (const [ name, value ] of Object.entries(this.options.proxyURIParams)) {
if (value) {
dbOptions[name] = value;
}
}
}

// Flatten any options nested under `writeConcern` before we make the connection string
if (dbOptions.writeConcern) {
Object.assign(dbOptions, dbOptions.writeConcern);
Expand Down Expand Up @@ -206,7 +220,7 @@ class TestConfiguration {
* @param {UrlOptions} [options] - overrides and settings for URI generation
*/
url(options) {
options = { db: this.options.db, replicaSet: this.options.replicaSet, ...options };
options = { db: this.options.db, replicaSet: this.options.replicaSet, proxyURIParams: this.options.proxyURIParams, ...options };

const FILLER_HOST = 'fillerHost';

Expand All @@ -216,6 +230,14 @@ class TestConfiguration {
url.searchParams.append('replicaSet', options.replicaSet);
}

if (options.proxyURIParams) {
for (const [ name, value ] of Object.entries(options.proxyURIParams)) {
if (value) {
url.searchParams.append(name, value);
}
}
}

url.pathname = `/${options.db}`;

if (options.username) url.username = options.username;
Expand Down

0 comments on commit a42f990

Please sign in to comment.