From 3de56119481d33c2623c6b577a17a9fd250b21f1 Mon Sep 17 00:00:00 2001 From: gagik Date: Thu, 13 Nov 2025 16:19:33 +0100 Subject: [PATCH 01/11] chore: turn the testing folder into a package --- package-lock.json | 38 +++++++++++++++++ packages/cli-repl/package.json | 3 +- packages/cli-repl/src/cli-repl.spec.ts | 6 +-- packages/cli-repl/src/smoke-tests.spec.ts | 2 +- .../scripts}/disable-dns-srv.js | 0 packages/connectivity-tests/test/atlas.sh | 2 +- packages/e2e-tests/package.json | 3 +- packages/e2e-tests/test/e2e-analytics.spec.ts | 3 +- packages/e2e-tests/test/e2e-auth.spec.ts | 6 +-- packages/e2e-tests/test/e2e-banners.spec.ts | 5 +-- packages/e2e-tests/test/e2e-bson.spec.ts | 2 +- packages/e2e-tests/test/e2e-direct.spec.ts | 4 +- packages/e2e-tests/test/e2e-editor.spec.ts | 2 +- packages/e2e-tests/test/e2e-fle.spec.ts | 7 ++-- packages/e2e-tests/test/e2e-oidc.spec.ts | 2 +- packages/e2e-tests/test/e2e-proxy.spec.ts | 2 +- packages/e2e-tests/test/e2e-snapshot.spec.ts | 5 +-- packages/e2e-tests/test/e2e-snippet.spec.ts | 2 +- packages/e2e-tests/test/e2e-streams.spec.ts | 2 +- packages/e2e-tests/test/e2e-tls.spec.ts | 2 +- packages/e2e-tests/test/e2e.spec.ts | 8 ++-- packages/e2e-tests/test/repl-helpers.ts | 2 +- packages/e2e-tests/test/test-shell.ts | 2 +- packages/java-shell/src/test/js/run-tests.ts | 2 +- .../node-runtime-worker-thread/package.json | 1 + .../src/index.spec.ts | 2 +- .../src/worker-runtime.spec.ts | 2 +- .../service-provider-node-driver/package.json | 3 +- .../node-driver-provider.integration.spec.ts | 5 +-- packages/shell-api/package.json | 1 + .../src/change-stream-cursor.spec.ts | 2 +- .../src/field-level-encryption.spec.ts | 5 +-- packages/shell-api/src/helpers.spec.ts | 2 +- packages/shell-api/src/integration.spec.ts | 2 +- packages/shell-api/src/mongo.spec.ts | 5 +-- packages/shell-api/src/replica-set.spec.ts | 6 +-- packages/shell-api/src/session.spec.ts | 2 +- packages/shell-api/src/shard.spec.ts | 2 +- packages/snippet-manager/package.json | 3 +- .../src/snippet-manager.spec.ts | 2 +- testing/.eslintrc.json | 9 ++++ testing/.gitignore | 2 + testing/.prettierrc | 1 + testing/README.md | 24 +++++++++++ testing/package.json | 41 ++++++++++++++++++- testing/{ => src}/eventually.ts | 0 testing/{ => src}/fake-kms.ts | 0 testing/src/index.ts | 3 ++ .../{ => src}/integration-testing-hooks.ts | 2 +- testing/tsconfig-lint.json | 4 ++ testing/tsconfig.json | 8 ++-- 51 files changed, 182 insertions(+), 69 deletions(-) rename {testing => packages/connectivity-tests/scripts}/disable-dns-srv.js (100%) create mode 100644 testing/.eslintrc.json create mode 100644 testing/.gitignore create mode 100644 testing/.prettierrc create mode 100644 testing/README.md rename testing/{ => src}/eventually.ts (100%) rename testing/{ => src}/fake-kms.ts (100%) create mode 100644 testing/src/index.ts rename testing/{ => src}/integration-testing-hooks.ts (99%) create mode 100644 testing/tsconfig-lint.json diff --git a/package-lock.json b/package-lock.json index c1a943708c..197f0fee94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7633,6 +7633,10 @@ "resolved": "packages/snippet-manager", "link": true }, + "node_modules/@mongosh/testing": { + "resolved": "testing", + "link": true + }, "node_modules/@mongosh/types": { "resolved": "packages/types", "link": true @@ -35771,6 +35775,7 @@ "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/sbom-tools": "^0.8.1", "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@mongosh/testing": "0.0.0-dev.0", "@types/ansi-escape-sequences": "^4.0.0", "@types/chai-as-promised": "^7.1.3", "@types/js-yaml": "^4.0.5", @@ -35838,6 +35843,7 @@ "@mongodb-js/oidc-mock-provider": "^0.11.3", "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@mongosh/testing": "0.0.0-dev.0", "@types/chai-as-promised": "^7.1.3", "@types/node": "^22.15.30", "@types/rimraf": "^3.0.0", @@ -36238,6 +36244,7 @@ "@mongosh/browser-runtime-electron": "^3.26.2", "@mongosh/service-provider-core": "3.6.3", "@mongosh/service-provider-node-driver": "^3.17.5", + "@mongosh/testing": "0.0.0-dev.0", "@mongosh/types": "^3.14.0", "bson": "^6.10.4", "depcheck": "^1.4.7", @@ -36295,6 +36302,7 @@ "@mongodb-js/eslint-config-mongosh": "^1.0.0", "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@mongosh/testing": "0.0.0-dev.0", "@types/sinon-chai": "^3.2.4", "depcheck": "^1.4.7", "eslint": "^7.25.0", @@ -36330,6 +36338,7 @@ "@mongodb-js/mongodb-ts-autocomplete": "^0.4.7", "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@mongosh/testing": "0.0.0-dev.0", "@mongosh/types": "^3.14.0", "bson": "^6.10.4", "depcheck": "^1.4.7", @@ -36413,6 +36422,7 @@ "@mongodb-js/eslint-config-mongosh": "^1.0.0", "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@mongosh/testing": "0.0.0-dev.0", "@types/cross-spawn": "^6.0.6", "@types/tar": "^4.0.4", "depcheck": "^1.4.7", @@ -36464,6 +36474,34 @@ "engines": { "node": ">=12.4.0" } + }, + "testing": { + "name": "@mongosh/testing", + "version": "0.0.0-dev.0", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@mongosh/build": "3.7.8", + "duplexpair": "^1.0.2", + "mongodb": "^6.19.0", + "mongodb-connection-string-url": "^3.0.1", + "mongodb-runner": "^6.0.0", + "semver": "^7.3.4", + "which": "^2.0.2" + }, + "devDependencies": { + "@mongodb-js/eslint-config-mongosh": "^1.0.0", + "@mongodb-js/prettier-config-devtools": "^1.0.1", + "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@types/semver": "^7.3.4", + "@types/which": "^1.3.2", + "eslint": "^7.25.0", + "prettier": "^2.8.8", + "typescript": "^5.3.3" + }, + "engines": { + "node": ">=14.15.1" + } } } } diff --git a/packages/cli-repl/package.json b/packages/cli-repl/package.json index 2bad45ae67..55e8b220f4 100644 --- a/packages/cli-repl/package.json +++ b/packages/cli-repl/package.json @@ -113,7 +113,8 @@ "eslint": "^7.25.0", "mongodb-crypt-library-dummy": "^1.0.2", "prettier": "^2.8.8", - "webpack-merge": "^5.8.0" + "webpack-merge": "^5.8.0", + "@mongosh/testing": "0.0.0-dev.0" }, "optionalDependencies": { "get-console-process-list": "^1.0.5", diff --git a/packages/cli-repl/src/cli-repl.spec.ts b/packages/cli-repl/src/cli-repl.spec.ts index 71321df7b9..0076fb0d00 100644 --- a/packages/cli-repl/src/cli-repl.spec.ts +++ b/packages/cli-repl/src/cli-repl.spec.ts @@ -8,13 +8,13 @@ import path from 'path'; import type { Duplex } from 'stream'; import { PassThrough } from 'stream'; import { promisify } from 'util'; -import { eventually } from '../../../testing/eventually'; -import type { MongodSetup } from '../../../testing/integration-testing-hooks'; import { + eventually, + type MongodSetup, skipIfServerVersion, startSharedTestServer, startTestServer, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; import { expect, fakeTTYProps, diff --git a/packages/cli-repl/src/smoke-tests.spec.ts b/packages/cli-repl/src/smoke-tests.spec.ts index 68402b6251..08bc619b30 100644 --- a/packages/cli-repl/src/smoke-tests.spec.ts +++ b/packages/cli-repl/src/smoke-tests.spec.ts @@ -3,7 +3,7 @@ import path from 'path'; import { downloadCurrentCryptSharedLibrary, startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; describe('smoke tests', function () { const testServer = startSharedTestServer(); diff --git a/testing/disable-dns-srv.js b/packages/connectivity-tests/scripts/disable-dns-srv.js similarity index 100% rename from testing/disable-dns-srv.js rename to packages/connectivity-tests/scripts/disable-dns-srv.js diff --git a/packages/connectivity-tests/test/atlas.sh b/packages/connectivity-tests/test/atlas.sh index 9a5387cfcc..d4f33ca1c4 100755 --- a/packages/connectivity-tests/test/atlas.sh +++ b/packages/connectivity-tests/test/atlas.sh @@ -136,7 +136,7 @@ function test_srv_without_nodejs_dns() { CONNECTION_STRING="mongodb+srv://${ATLAS_USERNAME}:${ATLAS_PASSWORD}@${ATLAS_HOSTNAME}/admin" - echo "${CONNECTION_STATUS_COMMAND}" | NODE_OPTIONS="-r ${MONGOSH_ROOT_DIR}/testing/disable-dns-srv.js" "${MONGOSH}" "${CONNECTION_STRING}" | + echo "${CONNECTION_STATUS_COMMAND}" | NODE_OPTIONS="-r ${MONGOSH_ROOT_DIR}/packages/connectivity-tests/scripts/disable-dns-srv.js" "${MONGOSH}" "${CONNECTION_STRING}" | grep -Fq "${CONNECTION_STATUS_CHECK_STRING}" || FAILED="Can't connect to Atlas using connection string without Node.js SRV/TXT DNS support" diff --git a/packages/e2e-tests/package.json b/packages/e2e-tests/package.json index 3ed31ae17c..b3b31d8719 100644 --- a/packages/e2e-tests/package.json +++ b/packages/e2e-tests/package.json @@ -50,6 +50,7 @@ "mongodb": "^6.19.0", "node-fetch": "^3.3.2", "prettier": "^2.8.8", - "rimraf": "^3.0.2" + "rimraf": "^3.0.2", + "@mongosh/testing": "0.0.0-dev.0" } } diff --git a/packages/e2e-tests/test/e2e-analytics.spec.ts b/packages/e2e-tests/test/e2e-analytics.spec.ts index e32bf15117..9ec901793b 100644 --- a/packages/e2e-tests/test/e2e-analytics.spec.ts +++ b/packages/e2e-tests/test/e2e-analytics.spec.ts @@ -1,6 +1,5 @@ import { expect } from 'chai'; -import { startTestCluster } from '../../../testing/integration-testing-hooks'; -import { eventually } from '../../../testing/eventually'; +import { startTestCluster, eventually } from '@mongosh/testing'; describe('e2e Analytics Node', function () { const replSetName = 'replicaSet'; diff --git a/packages/e2e-tests/test/e2e-auth.spec.ts b/packages/e2e-tests/test/e2e-auth.spec.ts index 12773ed134..1394c1849c 100644 --- a/packages/e2e-tests/test/e2e-auth.spec.ts +++ b/packages/e2e-tests/test/e2e-auth.spec.ts @@ -1,12 +1,12 @@ import { expect } from 'chai'; import type { Db, Document, MongoClientOptions } from 'mongodb'; import { MongoClient } from 'mongodb'; -import { eventually } from '../../../testing/eventually'; -import type { TestShell } from './test-shell'; import { + eventually, skipIfApiStrict, startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; +import type { TestShell } from './test-shell'; type AssertUserExists = (opts?: Document, username?: string) => Promise; function createAssertUserExists(db: Db, dbName: string): AssertUserExists { diff --git a/packages/e2e-tests/test/e2e-banners.spec.ts b/packages/e2e-tests/test/e2e-banners.spec.ts index 14929f1bff..c9f6412e7c 100644 --- a/packages/e2e-tests/test/e2e-banners.spec.ts +++ b/packages/e2e-tests/test/e2e-banners.spec.ts @@ -1,7 +1,4 @@ -import { - skipIfApiStrict, - startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +import { skipIfApiStrict, startSharedTestServer } from '@mongosh/testing'; import type { TestShell } from './test-shell'; describe('e2e startup banners', function () { diff --git a/packages/e2e-tests/test/e2e-bson.spec.ts b/packages/e2e-tests/test/e2e-bson.spec.ts index 2299bc4683..822b638c98 100644 --- a/packages/e2e-tests/test/e2e-bson.spec.ts +++ b/packages/e2e-tests/test/e2e-bson.spec.ts @@ -3,7 +3,7 @@ import type { Db } from 'mongodb'; import { MongoClient } from 'mongodb'; import * as bson from 'bson'; import type { TestShell } from './test-shell'; -import { startSharedTestServer } from '../../../testing/integration-testing-hooks'; +import { startSharedTestServer } from '@mongosh/testing'; describe('BSON e2e', function () { const testServer = startSharedTestServer(); diff --git a/packages/e2e-tests/test/e2e-direct.spec.ts b/packages/e2e-tests/test/e2e-direct.spec.ts index 46a0306607..c7d652dbf3 100644 --- a/packages/e2e-tests/test/e2e-direct.spec.ts +++ b/packages/e2e-tests/test/e2e-direct.spec.ts @@ -2,8 +2,8 @@ import { startTestCluster, skipIfServerVersion, skipIfApiStrict, -} from '../../../testing/integration-testing-hooks'; -import { eventually } from '../../../testing/eventually'; + eventually, +} from '@mongosh/testing'; import { expect } from 'chai'; import type { TestShell } from './test-shell'; diff --git a/packages/e2e-tests/test/e2e-editor.spec.ts b/packages/e2e-tests/test/e2e-editor.spec.ts index ac6abb2fb9..a11239bb7f 100644 --- a/packages/e2e-tests/test/e2e-editor.spec.ts +++ b/packages/e2e-tests/test/e2e-editor.spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import path from 'path'; import { promises as fs } from 'fs'; -import { eventually } from '../../../testing/eventually'; +import { eventually } from '@mongosh/testing'; import { TestShell } from './test-shell'; import { ensureTestShellAfterHook } from './test-shell-context'; import { diff --git a/packages/e2e-tests/test/e2e-fle.spec.ts b/packages/e2e-tests/test/e2e-fle.spec.ts index ae86e55d3f..6666b7014d 100644 --- a/packages/e2e-tests/test/e2e-fle.spec.ts +++ b/packages/e2e-tests/test/e2e-fle.spec.ts @@ -1,16 +1,17 @@ import { expect } from 'chai'; import { MongoClient } from 'mongodb'; import type { TestShell } from './test-shell'; -import { eventually } from '../../../testing/eventually'; import { + eventually, startTestServer, skipIfApiStrict, skipIfServerVersion, skipIfCommunityServer, downloadCurrentCryptSharedLibrary, sortObjectArray, -} from '../../../testing/integration-testing-hooks'; -import { makeFakeHTTPServer, fakeAWSHandlers } from '../../../testing/fake-kms'; + makeFakeHTTPServer, + fakeAWSHandlers, +} from '@mongosh/testing'; import { once } from 'events'; import { serialize } from 'v8'; import { inspect } from 'util'; diff --git a/packages/e2e-tests/test/e2e-oidc.spec.ts b/packages/e2e-tests/test/e2e-oidc.spec.ts index 08935926ca..673f6955eb 100644 --- a/packages/e2e-tests/test/e2e-oidc.spec.ts +++ b/packages/e2e-tests/test/e2e-oidc.spec.ts @@ -2,7 +2,7 @@ import { MongoRunnerSetup, skipIfApiStrict, skipIfEnvServerVersion, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; import { promises as fs } from 'fs'; import type { OIDCMockProviderConfig } from '@mongodb-js/oidc-mock-provider'; import { OIDCMockProvider } from '@mongodb-js/oidc-mock-provider'; diff --git a/packages/e2e-tests/test/e2e-proxy.spec.ts b/packages/e2e-tests/test/e2e-proxy.spec.ts index b9afc836d7..f827307984 100644 --- a/packages/e2e-tests/test/e2e-proxy.spec.ts +++ b/packages/e2e-tests/test/e2e-proxy.spec.ts @@ -10,7 +10,7 @@ import { skipIfEnvServerVersion, startSharedTestServer, startTestServer, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; import type { Server as HTTPSServer } from 'https'; import { createServer as createHTTPSServer } from 'https'; import { diff --git a/packages/e2e-tests/test/e2e-snapshot.spec.ts b/packages/e2e-tests/test/e2e-snapshot.spec.ts index fb57cc798c..201fa26a97 100644 --- a/packages/e2e-tests/test/e2e-snapshot.spec.ts +++ b/packages/e2e-tests/test/e2e-snapshot.spec.ts @@ -1,7 +1,4 @@ -import { - skipIfApiStrict, - startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +import { skipIfApiStrict, startSharedTestServer } from '@mongosh/testing'; import { expect } from 'chai'; const setDifference = (a: T[], b: T[]) => a.filter((e) => !b.includes(e)); diff --git a/packages/e2e-tests/test/e2e-snippet.spec.ts b/packages/e2e-tests/test/e2e-snippet.spec.ts index bf4a843073..58a7427568 100644 --- a/packages/e2e-tests/test/e2e-snippet.spec.ts +++ b/packages/e2e-tests/test/e2e-snippet.spec.ts @@ -3,7 +3,7 @@ import path from 'path'; import { expect } from 'chai'; import type { TestShell } from './test-shell'; import { useTmpdir } from './repl-helpers'; -import { eventually } from '../../../testing/eventually'; +import { eventually } from '@mongosh/testing'; describe('snippet integration tests', function () { this.timeout(120_000); diff --git a/packages/e2e-tests/test/e2e-streams.spec.ts b/packages/e2e-tests/test/e2e-streams.spec.ts index 9f6efd8dbb..1ec70cb269 100644 --- a/packages/e2e-tests/test/e2e-streams.spec.ts +++ b/packages/e2e-tests/test/e2e-streams.spec.ts @@ -4,7 +4,7 @@ import { MongoClient } from 'mongodb'; import { expect } from 'chai'; import type { TestShell } from './test-shell'; import { sleep } from './util-helpers'; -import { eventually } from '../../../testing/eventually'; +import { eventually } from '@mongosh/testing'; const { STREAMS_E2E_SPI_CONNECTION_STRING = '', diff --git a/packages/e2e-tests/test/e2e-tls.spec.ts b/packages/e2e-tests/test/e2e-tls.spec.ts index da68f80cc0..351fea3ddd 100644 --- a/packages/e2e-tests/test/e2e-tls.spec.ts +++ b/packages/e2e-tests/test/e2e-tls.spec.ts @@ -1,7 +1,7 @@ import { expect } from 'chai'; import { promises as fs } from 'fs'; import path from 'path'; -import { startTestServer } from '../../../testing/integration-testing-hooks'; +import { startTestServer } from '@mongosh/testing'; import { useTmpdir, setTemporaryHomeDirectory, diff --git a/packages/e2e-tests/test/e2e.spec.ts b/packages/e2e-tests/test/e2e.spec.ts index c6029f2480..b83bb0a70b 100644 --- a/packages/e2e-tests/test/e2e.spec.ts +++ b/packages/e2e-tests/test/e2e.spec.ts @@ -3,13 +3,13 @@ import { expect } from 'chai'; import type { Db } from 'mongodb'; import { MongoClient, ObjectId } from 'mongodb'; -import { eventually } from '../../../testing/eventually'; -import { TestShell } from './test-shell'; -import { ensureTestShellAfterHook } from './test-shell-context'; import { + eventually, skipIfServerVersion, startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; +import { TestShell } from './test-shell'; +import { ensureTestShellAfterHook } from './test-shell-context'; import { promises as fs, createReadStream } from 'fs'; import { promisify } from 'util'; import path from 'path'; diff --git a/packages/e2e-tests/test/repl-helpers.ts b/packages/e2e-tests/test/repl-helpers.ts index 46c67371d7..0035465bf7 100644 --- a/packages/e2e-tests/test/repl-helpers.ts +++ b/packages/e2e-tests/test/repl-helpers.ts @@ -5,7 +5,7 @@ import rimraf from 'rimraf'; import chai from 'chai'; import sinonChai from 'sinon-chai'; import chaiAsPromised from 'chai-as-promised'; -import type { MongodSetup } from '../../../testing/integration-testing-hooks'; +import type { MongodSetup } from '@mongosh/testing'; import type { MongoLogEntry } from 'mongodb-log-writer'; chai.use(sinonChai); diff --git a/packages/e2e-tests/test/test-shell.ts b/packages/e2e-tests/test/test-shell.ts index f3a310ae2e..7613c5d713 100644 --- a/packages/e2e-tests/test/test-shell.ts +++ b/packages/e2e-tests/test/test-shell.ts @@ -9,7 +9,7 @@ import { inspect } from 'util'; import path from 'path'; import stripAnsi from 'strip-ansi'; import { EJSON } from 'bson'; -import { eventually } from '../../../testing/eventually'; +import { eventually } from '@mongosh/testing'; /* eslint-disable mocha/no-exports -- This file export hooks wrapping Mocha's Hooks APIs */ diff --git a/packages/java-shell/src/test/js/run-tests.ts b/packages/java-shell/src/test/js/run-tests.ts index ccbfa02a03..6de0f39278 100644 --- a/packages/java-shell/src/test/js/run-tests.ts +++ b/packages/java-shell/src/test/js/run-tests.ts @@ -1,7 +1,7 @@ import { spawn } from 'child_process'; import path from 'path'; import { once } from 'events'; -import { startSharedTestServer } from '../../../../../testing/integration-testing-hooks'; +import { startSharedTestServer } from '@mongosh/testing'; describe('java-shell tests', function() { this.timeout(1_000_000); diff --git a/packages/node-runtime-worker-thread/package.json b/packages/node-runtime-worker-thread/package.json index 35991756f5..8533f051e6 100644 --- a/packages/node-runtime-worker-thread/package.json +++ b/packages/node-runtime-worker-thread/package.json @@ -39,6 +39,7 @@ "@mongodb-js/eslint-config-mongosh": "^1.0.0", "@mongodb-js/prettier-config-devtools": "^1.0.1", "@mongodb-js/sbom-tools": "^0.8.1", + "@mongosh/testing": "0.0.0-dev.0", "@mongodb-js/tsconfig-mongosh": "^1.0.0", "@mongosh/browser-runtime-core": "^3.26.2", "@mongosh/browser-runtime-electron": "^3.26.2", diff --git a/packages/node-runtime-worker-thread/src/index.spec.ts b/packages/node-runtime-worker-thread/src/index.spec.ts index 88b626c03f..d4593f3e7f 100644 --- a/packages/node-runtime-worker-thread/src/index.spec.ts +++ b/packages/node-runtime-worker-thread/src/index.spec.ts @@ -2,7 +2,7 @@ import chai, { expect } from 'chai'; import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import type { MongoshBus } from '@mongosh/types'; -import { startSharedTestServer } from '../../../testing/integration-testing-hooks'; +import { startSharedTestServer } from '@mongosh/testing'; import { WorkerRuntime } from '../dist/index'; import type { DevtoolsConnectOptions } from '@mongosh/service-provider-node-driver'; diff --git a/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts b/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts index 261a4fcff1..24df3a596e 100644 --- a/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts +++ b/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts @@ -5,7 +5,7 @@ import chai, { expect } from 'chai'; import sinonChai from 'sinon-chai'; import sinon from 'sinon'; import { EJSON, ObjectId } from 'bson'; -import { startSharedTestServer } from '../../../testing/integration-testing-hooks'; +import { startSharedTestServer } from '@mongosh/testing'; import type { Caller, Exposed } from './rpc'; import { cancel, close, createCaller, exposeAll } from './rpc'; import { deserializeEvaluationResult } from './serializer'; diff --git a/packages/service-provider-node-driver/package.json b/packages/service-provider-node-driver/package.json index 04d16118fd..63c3f29947 100644 --- a/packages/service-provider-node-driver/package.json +++ b/packages/service-provider-node-driver/package.json @@ -71,6 +71,7 @@ "@types/sinon-chai": "^3.2.4", "depcheck": "^1.4.7", "eslint": "^7.25.0", - "prettier": "^2.8.8" + "prettier": "^2.8.8", + "@mongosh/testing": "0.0.0-dev.0" } } diff --git a/packages/service-provider-node-driver/src/node-driver-provider.integration.spec.ts b/packages/service-provider-node-driver/src/node-driver-provider.integration.spec.ts index 327f776ef7..27925ec4b8 100644 --- a/packages/service-provider-node-driver/src/node-driver-provider.integration.spec.ts +++ b/packages/service-provider-node-driver/src/node-driver-provider.integration.spec.ts @@ -15,10 +15,7 @@ import type { InsertOneResult, UpdateResult, } from 'mongodb'; -import { - skipIfServerVersion, - startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +import { skipIfServerVersion, startSharedTestServer } from '@mongosh/testing'; import type { DbOptions, MongoClientOptions, diff --git a/packages/shell-api/package.json b/packages/shell-api/package.json index 87c787e028..56c2830a55 100644 --- a/packages/shell-api/package.json +++ b/packages/shell-api/package.json @@ -64,6 +64,7 @@ }, "devDependencies": { "@microsoft/api-extractor": "^7.39.3", + "@mongosh/testing": "0.0.0-dev.0", "@mongodb-js/eslint-config-mongosh": "^1.0.0", "@mongodb-js/mongodb-ts-autocomplete": "^0.4.7", "@mongodb-js/prettier-config-devtools": "^1.0.1", diff --git a/packages/shell-api/src/change-stream-cursor.spec.ts b/packages/shell-api/src/change-stream-cursor.spec.ts index 329ff9ec78..0a992da1eb 100644 --- a/packages/shell-api/src/change-stream-cursor.spec.ts +++ b/packages/shell-api/src/change-stream-cursor.spec.ts @@ -12,7 +12,7 @@ import { ALL_API_VERSIONS, } from './enums'; import type { ChangeStream, Document } from '@mongosh/service-provider-core'; -import { startTestCluster } from '../../../testing/integration-testing-hooks'; +import { startTestCluster } from '@mongosh/testing'; import { NodeDriverServiceProvider } from '../../service-provider-node-driver'; import ShellInstanceState from './shell-instance-state'; import Mongo from './mongo'; diff --git a/packages/shell-api/src/field-level-encryption.spec.ts b/packages/shell-api/src/field-level-encryption.spec.ts index f892dee6fd..f47073a7db 100644 --- a/packages/shell-api/src/field-level-encryption.spec.ts +++ b/packages/shell-api/src/field-level-encryption.spec.ts @@ -29,11 +29,11 @@ import { ClientEncryption, KeyVault } from './field-level-encryption'; import Mongo from './mongo'; import ShellInstanceState from './shell-instance-state'; import { NodeDriverServiceProvider } from '../../service-provider-node-driver'; -import { startSharedTestServer } from '../../../testing/integration-testing-hooks'; import { + startSharedTestServer, makeFakeHTTPConnection, fakeAWSHandlers, -} from '../../../testing/fake-kms'; +} from '@mongosh/testing'; import { Collection } from './collection'; import { dummyOptions } from './helpers.spec'; import type { IncomingMessage } from 'http'; @@ -962,7 +962,6 @@ srDVjIT3LsvTqw==`, return; } expect.fail('missed exception'); - break; default: throw new Error(`unreachable ${kmsName}`); } diff --git a/packages/shell-api/src/helpers.spec.ts b/packages/shell-api/src/helpers.spec.ts index 533056e125..eecb36b76c 100644 --- a/packages/shell-api/src/helpers.spec.ts +++ b/packages/shell-api/src/helpers.spec.ts @@ -14,7 +14,7 @@ import type { ServiceProvider } from '@mongosh/service-provider-core'; import * as bson from 'bson'; import type { DevtoolsConnectOptions } from '../../service-provider-node-driver'; import { NodeDriverServiceProvider } from '../../service-provider-node-driver'; // avoid cyclic dep just for test -import { startSharedTestServer } from '../../../testing/integration-testing-hooks'; +import { startSharedTestServer } from '@mongosh/testing'; import { makeFakeConfigDatabase } from '../test/shard-test-fake-data'; import sinon from 'ts-sinon'; import chai, { expect } from 'chai'; diff --git a/packages/shell-api/src/integration.spec.ts b/packages/shell-api/src/integration.spec.ts index 2b6e50a1bf..6ef995c8e7 100644 --- a/packages/shell-api/src/integration.spec.ts +++ b/packages/shell-api/src/integration.spec.ts @@ -9,7 +9,7 @@ import { skipIfServerVersion, skipIfApiStrict, startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; import type { ShellApi, Mongo } from './index'; import { toShellResult, Topologies } from './index'; import type { diff --git a/packages/shell-api/src/mongo.spec.ts b/packages/shell-api/src/mongo.spec.ts index 01cbb9fd8e..26bfa75e8b 100644 --- a/packages/shell-api/src/mongo.spec.ts +++ b/packages/shell-api/src/mongo.spec.ts @@ -30,10 +30,7 @@ import { MongoshUnimplementedError, } from '@mongosh/errors'; import { NodeDriverServiceProvider } from '../../service-provider-node-driver'; -import { - skipIfServerVersion, - startSharedTestServer, -} from '../../../testing/integration-testing-hooks'; +import { skipIfServerVersion, startSharedTestServer } from '@mongosh/testing'; import { dummyOptions } from './helpers.spec'; import { ClientBulkWriteResult } from './result'; diff --git a/packages/shell-api/src/replica-set.spec.ts b/packages/shell-api/src/replica-set.spec.ts index c50a98f462..99603add48 100644 --- a/packages/shell-api/src/replica-set.spec.ts +++ b/packages/shell-api/src/replica-set.spec.ts @@ -16,12 +16,13 @@ import sinonChai from 'sinon-chai'; import type { StubbedInstance } from 'ts-sinon'; import { stubInterface } from 'ts-sinon'; import { createRetriableMethod, ensureMaster } from '../test/helpers'; -import type { MongodSetup } from '../../../testing/integration-testing-hooks'; import { + type MongodSetup, skipIfServerVersion, startTestCluster, skipIfApiStrict, -} from '../../../testing/integration-testing-hooks'; + eventually, +} from '@mongosh/testing'; import { NodeDriverServiceProvider } from '../../service-provider-node-driver'; import { Database } from './database'; import { @@ -38,7 +39,6 @@ import type { ReplSetConfig, ReplSetMemberConfig } from './replica-set'; import ReplicaSet from './replica-set'; import type { EvaluationListener } from './shell-instance-state'; import ShellInstanceState from './shell-instance-state'; -import { eventually } from '../../../testing/eventually'; chai.use(sinonChai); function deepClone(value: T): T { diff --git a/packages/shell-api/src/session.spec.ts b/packages/shell-api/src/session.spec.ts index d1846dc237..68c4478c8f 100644 --- a/packages/shell-api/src/session.spec.ts +++ b/packages/shell-api/src/session.spec.ts @@ -23,7 +23,7 @@ import { startTestCluster, skipIfServerVersion, skipIfApiStrict, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; import { ensureMaster, ensureSessionExists } from '../test/helpers'; import { Database } from './database'; import { CommonErrors, MongoshInvalidInputError } from '@mongosh/errors'; diff --git a/packages/shell-api/src/shard.spec.ts b/packages/shell-api/src/shard.spec.ts index c52edc91df..b63a03797d 100644 --- a/packages/shell-api/src/shard.spec.ts +++ b/packages/shell-api/src/shard.spec.ts @@ -28,7 +28,7 @@ import { startTestCluster, skipIfServerVersion, skipIfApiStrict, -} from '../../../testing/integration-testing-hooks'; +} from '@mongosh/testing'; import type { DatabaseWithSchema } from './database'; import { Database } from './database'; import { inspect } from 'util'; diff --git a/packages/snippet-manager/package.json b/packages/snippet-manager/package.json index 616438af34..bc57e60ed5 100644 --- a/packages/snippet-manager/package.json +++ b/packages/snippet-manager/package.json @@ -54,6 +54,7 @@ "depcheck": "^1.4.7", "eslint": "^7.25.0", "nanobus": "^4.5.0", - "prettier": "^2.8.8" + "prettier": "^2.8.8", + "@mongosh/testing": "0.0.0-dev.0" } } diff --git a/packages/snippet-manager/src/snippet-manager.spec.ts b/packages/snippet-manager/src/snippet-manager.spec.ts index 03a8d85a42..53e69b518c 100644 --- a/packages/snippet-manager/src/snippet-manager.spec.ts +++ b/packages/snippet-manager/src/snippet-manager.spec.ts @@ -13,7 +13,7 @@ import bson from 'bson'; import path from 'path'; import { promises as fs, createReadStream } from 'fs'; import Nanobus from 'nanobus'; -import { eventually } from '../../../testing/eventually'; +import { eventually } from '@mongosh/testing'; chai.use(sinonChai); describe('SnippetManager', function () { diff --git a/testing/.eslintrc.json b/testing/.eslintrc.json new file mode 100644 index 0000000000..e548c12df1 --- /dev/null +++ b/testing/.eslintrc.json @@ -0,0 +1,9 @@ +{ + "extends": "@mongodb-js/eslint-config-mongosh", + "parserOptions": { + "project": ["./tsconfig-lint.json"] + }, + "rules": { + "mocha/no-exports": "off" + } +} diff --git a/testing/.gitignore b/testing/.gitignore new file mode 100644 index 0000000000..59a1892526 --- /dev/null +++ b/testing/.gitignore @@ -0,0 +1,2 @@ +lib/ + diff --git a/testing/.prettierrc b/testing/.prettierrc new file mode 100644 index 0000000000..dfae21d047 --- /dev/null +++ b/testing/.prettierrc @@ -0,0 +1 @@ +"@mongodb-js/prettier-config-devtools" diff --git a/testing/README.md b/testing/README.md new file mode 100644 index 0000000000..164e1bc172 --- /dev/null +++ b/testing/README.md @@ -0,0 +1,24 @@ +# @mongosh/testing + +Internal testing utilities for mongosh packages. This package is only used for testing purposes within the mongosh monorepo. + +## Contents + +- **integration-testing-hooks.ts** - Test server setup and helpers for integration tests +- **eventually.ts** - Retry helper for asynchronous tests +- **fake-kms.ts** - Mock KMS server for field-level encryption tests + +## Usage + +```typescript +import { + startSharedTestServer, + startTestServer, + eventually, + makeFakeHTTPServer, +} from '@mongosh/testing'; +``` + +## Note + +This package is marked as private and will not be published to npm. diff --git a/testing/package.json b/testing/package.json index bf20e826b5..2450280cf1 100644 --- a/testing/package.json +++ b/testing/package.json @@ -1,6 +1,43 @@ { + "name": "@mongosh/testing", + "version": "0.0.0-dev.0", + "description": "MongoDB Shell Testing Utilities (internal use only)", + "homepage": "https://github.com/mongodb-js/mongosh", + "license": "Apache-2.0", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "private": true, + "repository": { + "type": "git", + "url": "https://github.com/mongodb-js/mongosh" + }, + "engines": { + "node": ">=14.15.1" + }, "scripts": { - "lint": "prettier --check .", - "reformat": "prettier --write ." + "compile": "tsc -p tsconfig.json", + "eslint": "eslint", + "lint": "npm run eslint . && npm run prettier -- --check .", + "prettier": "prettier", + "reformat": "npm run prettier -- --write . && npm run eslint -- --fix" + }, + "dependencies": { + "@mongosh/build": "3.7.8", + "duplexpair": "^1.0.2", + "mongodb": "^6.19.0", + "mongodb-connection-string-url": "^3.0.1", + "mongodb-runner": "^6.0.0", + "semver": "^7.3.4", + "which": "^2.0.2" + }, + "devDependencies": { + "@mongodb-js/eslint-config-mongosh": "^1.0.0", + "@mongodb-js/prettier-config-devtools": "^1.0.1", + "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@types/semver": "^7.3.4", + "@types/which": "^1.3.2", + "eslint": "^7.25.0", + "prettier": "^2.8.8", + "typescript": "^5.3.3" } } diff --git a/testing/eventually.ts b/testing/src/eventually.ts similarity index 100% rename from testing/eventually.ts rename to testing/src/eventually.ts diff --git a/testing/fake-kms.ts b/testing/src/fake-kms.ts similarity index 100% rename from testing/fake-kms.ts rename to testing/src/fake-kms.ts diff --git a/testing/src/index.ts b/testing/src/index.ts new file mode 100644 index 0000000000..012b9fe339 --- /dev/null +++ b/testing/src/index.ts @@ -0,0 +1,3 @@ +export * from './integration-testing-hooks'; +export * from './eventually'; +export * from './fake-kms'; diff --git a/testing/integration-testing-hooks.ts b/testing/src/integration-testing-hooks.ts similarity index 99% rename from testing/integration-testing-hooks.ts rename to testing/src/integration-testing-hooks.ts index 7f229cdf18..ad6186fc21 100644 --- a/testing/integration-testing-hooks.ts +++ b/testing/src/integration-testing-hooks.ts @@ -14,7 +14,7 @@ const execFile = promisify(child_process.execFile); // Return the path to the temporary directory and ensure that it exists. async function getTmpdir(): Promise { - const tmpdir = path.resolve(__dirname, '..', 'tmp'); + const tmpdir = path.resolve(__dirname, '..', '..', 'tmp'); await fs.mkdir(tmpdir, { recursive: true }); return tmpdir; } diff --git a/testing/tsconfig-lint.json b/testing/tsconfig-lint.json new file mode 100644 index 0000000000..49467c9152 --- /dev/null +++ b/testing/tsconfig-lint.json @@ -0,0 +1,4 @@ +{ + "extends": "@mongodb-js/tsconfig-mongosh/tsconfig.lint.json", + "include": ["src/**/*"] +} diff --git a/testing/tsconfig.json b/testing/tsconfig.json index c76dbd55aa..53bf421d6c 100644 --- a/testing/tsconfig.json +++ b/testing/tsconfig.json @@ -2,8 +2,10 @@ "extends": "@mongodb-js/tsconfig-mongosh/tsconfig.common.json", "compilerOptions": { "allowJs": true, - "outDir": "./dist" + "outDir": "./lib", + "declaration": true, + "declarationMap": true }, - "include": ["**/*"], - "exclude": ["certificates"] + "include": ["src/**/*"], + "exclude": ["certificates", "lib"] } From c22d196b666d85a3e7c612556856203e85ec19ac Mon Sep 17 00:00:00 2001 From: gagik Date: Thu, 13 Nov 2025 20:20:53 +0100 Subject: [PATCH 02/11] chore: move testing folder to packages --- package.json | 1 + {testing => packages/testing}/.eslintrc.js | 0 {testing => packages/testing}/.eslintrc.json | 0 {testing => packages/testing}/.gitignore | 0 {testing => packages/testing}/.prettierrc | 0 {testing => packages/testing}/.prettierrc.json | 0 {testing => packages/testing}/README.md | 0 .../testing}/certificates/README.md | 0 .../testing}/certificates/ca-server.crl | 0 {testing => packages/testing}/certificates/ca.cnf | 0 {testing => packages/testing}/certificates/ca.crt | 0 {testing => packages/testing}/certificates/ca.db | 0 .../testing}/certificates/ca.db.attr | 0 {testing => packages/testing}/certificates/ca.key | 0 .../testing}/certificates/ca.serial | 0 .../certificates/client.bundle.encrypted.pem | 0 .../testing}/certificates/client.bundle.pem | 0 .../testing}/certificates/client.bundle.pfx | Bin .../testing}/certificates/client.encrypted.key | 0 .../testing}/certificates/client.key | 0 .../testing}/certificates/client.pem | 0 .../testing}/certificates/invalid-client.bundle.pem | 0 .../testing}/certificates/invalid-client.key | 0 .../testing}/certificates/non-ca.crt | 0 .../testing}/certificates/non-ca.key | 0 .../certificates/partial-trust-chain/ca.pem | 0 .../certificates/partial-trust-chain/cert.pem | 0 .../partial-trust-chain/key-and-cert.pem | 0 .../certificates/partial-trust-chain/key.pem | 0 .../certificates/server-invalidhost.bundle.pem | 0 .../testing}/certificates/server-invalidhost.key | 0 .../testing}/certificates/server.bundle.pem | 0 .../testing}/certificates/server.key | 0 {testing => packages/testing}/package.json | 0 {testing => packages/testing}/src/eventually.ts | 0 {testing => packages/testing}/src/fake-kms.ts | 0 {testing => packages/testing}/src/index.ts | 0 .../testing}/src/integration-testing-hooks.ts | 0 {testing => packages/testing}/test-vscode.sh | 0 .../testing}/tests-globalconfig.conf | 0 {testing => packages/testing}/tsconfig-lint.json | 0 {testing => packages/testing}/tsconfig.json | 0 42 files changed, 1 insertion(+) rename {testing => packages/testing}/.eslintrc.js (100%) rename {testing => packages/testing}/.eslintrc.json (100%) rename {testing => packages/testing}/.gitignore (100%) rename {testing => packages/testing}/.prettierrc (100%) rename {testing => packages/testing}/.prettierrc.json (100%) rename {testing => packages/testing}/README.md (100%) rename {testing => packages/testing}/certificates/README.md (100%) rename {testing => packages/testing}/certificates/ca-server.crl (100%) rename {testing => packages/testing}/certificates/ca.cnf (100%) rename {testing => packages/testing}/certificates/ca.crt (100%) rename {testing => packages/testing}/certificates/ca.db (100%) rename {testing => packages/testing}/certificates/ca.db.attr (100%) rename {testing => packages/testing}/certificates/ca.key (100%) rename {testing => packages/testing}/certificates/ca.serial (100%) rename {testing => packages/testing}/certificates/client.bundle.encrypted.pem (100%) rename {testing => packages/testing}/certificates/client.bundle.pem (100%) rename {testing => packages/testing}/certificates/client.bundle.pfx (100%) rename {testing => packages/testing}/certificates/client.encrypted.key (100%) rename {testing => packages/testing}/certificates/client.key (100%) rename {testing => packages/testing}/certificates/client.pem (100%) rename {testing => packages/testing}/certificates/invalid-client.bundle.pem (100%) rename {testing => packages/testing}/certificates/invalid-client.key (100%) rename {testing => packages/testing}/certificates/non-ca.crt (100%) rename {testing => packages/testing}/certificates/non-ca.key (100%) rename {testing => packages/testing}/certificates/partial-trust-chain/ca.pem (100%) rename {testing => packages/testing}/certificates/partial-trust-chain/cert.pem (100%) rename {testing => packages/testing}/certificates/partial-trust-chain/key-and-cert.pem (100%) rename {testing => packages/testing}/certificates/partial-trust-chain/key.pem (100%) rename {testing => packages/testing}/certificates/server-invalidhost.bundle.pem (100%) rename {testing => packages/testing}/certificates/server-invalidhost.key (100%) rename {testing => packages/testing}/certificates/server.bundle.pem (100%) rename {testing => packages/testing}/certificates/server.key (100%) rename {testing => packages/testing}/package.json (100%) rename {testing => packages/testing}/src/eventually.ts (100%) rename {testing => packages/testing}/src/fake-kms.ts (100%) rename {testing => packages/testing}/src/index.ts (100%) rename {testing => packages/testing}/src/integration-testing-hooks.ts (100%) rename {testing => packages/testing}/test-vscode.sh (100%) rename {testing => packages/testing}/tests-globalconfig.conf (100%) rename {testing => packages/testing}/tsconfig-lint.json (100%) rename {testing => packages/testing}/tsconfig.json (100%) diff --git a/package.json b/package.json index a7b666ea7d..9df364227d 100644 --- a/package.json +++ b/package.json @@ -153,6 +153,7 @@ "packages/i18n", "packages/logging", "packages/shell-bson", + "packages/testing", "packages/arg-parser", "packages/service-provider-core", "packages/service-provider-node-driver", diff --git a/testing/.eslintrc.js b/packages/testing/.eslintrc.js similarity index 100% rename from testing/.eslintrc.js rename to packages/testing/.eslintrc.js diff --git a/testing/.eslintrc.json b/packages/testing/.eslintrc.json similarity index 100% rename from testing/.eslintrc.json rename to packages/testing/.eslintrc.json diff --git a/testing/.gitignore b/packages/testing/.gitignore similarity index 100% rename from testing/.gitignore rename to packages/testing/.gitignore diff --git a/testing/.prettierrc b/packages/testing/.prettierrc similarity index 100% rename from testing/.prettierrc rename to packages/testing/.prettierrc diff --git a/testing/.prettierrc.json b/packages/testing/.prettierrc.json similarity index 100% rename from testing/.prettierrc.json rename to packages/testing/.prettierrc.json diff --git a/testing/README.md b/packages/testing/README.md similarity index 100% rename from testing/README.md rename to packages/testing/README.md diff --git a/testing/certificates/README.md b/packages/testing/certificates/README.md similarity index 100% rename from testing/certificates/README.md rename to packages/testing/certificates/README.md diff --git a/testing/certificates/ca-server.crl b/packages/testing/certificates/ca-server.crl similarity index 100% rename from testing/certificates/ca-server.crl rename to packages/testing/certificates/ca-server.crl diff --git a/testing/certificates/ca.cnf b/packages/testing/certificates/ca.cnf similarity index 100% rename from testing/certificates/ca.cnf rename to packages/testing/certificates/ca.cnf diff --git a/testing/certificates/ca.crt b/packages/testing/certificates/ca.crt similarity index 100% rename from testing/certificates/ca.crt rename to packages/testing/certificates/ca.crt diff --git a/testing/certificates/ca.db b/packages/testing/certificates/ca.db similarity index 100% rename from testing/certificates/ca.db rename to packages/testing/certificates/ca.db diff --git a/testing/certificates/ca.db.attr b/packages/testing/certificates/ca.db.attr similarity index 100% rename from testing/certificates/ca.db.attr rename to packages/testing/certificates/ca.db.attr diff --git a/testing/certificates/ca.key b/packages/testing/certificates/ca.key similarity index 100% rename from testing/certificates/ca.key rename to packages/testing/certificates/ca.key diff --git a/testing/certificates/ca.serial b/packages/testing/certificates/ca.serial similarity index 100% rename from testing/certificates/ca.serial rename to packages/testing/certificates/ca.serial diff --git a/testing/certificates/client.bundle.encrypted.pem b/packages/testing/certificates/client.bundle.encrypted.pem similarity index 100% rename from testing/certificates/client.bundle.encrypted.pem rename to packages/testing/certificates/client.bundle.encrypted.pem diff --git a/testing/certificates/client.bundle.pem b/packages/testing/certificates/client.bundle.pem similarity index 100% rename from testing/certificates/client.bundle.pem rename to packages/testing/certificates/client.bundle.pem diff --git a/testing/certificates/client.bundle.pfx b/packages/testing/certificates/client.bundle.pfx similarity index 100% rename from testing/certificates/client.bundle.pfx rename to packages/testing/certificates/client.bundle.pfx diff --git a/testing/certificates/client.encrypted.key b/packages/testing/certificates/client.encrypted.key similarity index 100% rename from testing/certificates/client.encrypted.key rename to packages/testing/certificates/client.encrypted.key diff --git a/testing/certificates/client.key b/packages/testing/certificates/client.key similarity index 100% rename from testing/certificates/client.key rename to packages/testing/certificates/client.key diff --git a/testing/certificates/client.pem b/packages/testing/certificates/client.pem similarity index 100% rename from testing/certificates/client.pem rename to packages/testing/certificates/client.pem diff --git a/testing/certificates/invalid-client.bundle.pem b/packages/testing/certificates/invalid-client.bundle.pem similarity index 100% rename from testing/certificates/invalid-client.bundle.pem rename to packages/testing/certificates/invalid-client.bundle.pem diff --git a/testing/certificates/invalid-client.key b/packages/testing/certificates/invalid-client.key similarity index 100% rename from testing/certificates/invalid-client.key rename to packages/testing/certificates/invalid-client.key diff --git a/testing/certificates/non-ca.crt b/packages/testing/certificates/non-ca.crt similarity index 100% rename from testing/certificates/non-ca.crt rename to packages/testing/certificates/non-ca.crt diff --git a/testing/certificates/non-ca.key b/packages/testing/certificates/non-ca.key similarity index 100% rename from testing/certificates/non-ca.key rename to packages/testing/certificates/non-ca.key diff --git a/testing/certificates/partial-trust-chain/ca.pem b/packages/testing/certificates/partial-trust-chain/ca.pem similarity index 100% rename from testing/certificates/partial-trust-chain/ca.pem rename to packages/testing/certificates/partial-trust-chain/ca.pem diff --git a/testing/certificates/partial-trust-chain/cert.pem b/packages/testing/certificates/partial-trust-chain/cert.pem similarity index 100% rename from testing/certificates/partial-trust-chain/cert.pem rename to packages/testing/certificates/partial-trust-chain/cert.pem diff --git a/testing/certificates/partial-trust-chain/key-and-cert.pem b/packages/testing/certificates/partial-trust-chain/key-and-cert.pem similarity index 100% rename from testing/certificates/partial-trust-chain/key-and-cert.pem rename to packages/testing/certificates/partial-trust-chain/key-and-cert.pem diff --git a/testing/certificates/partial-trust-chain/key.pem b/packages/testing/certificates/partial-trust-chain/key.pem similarity index 100% rename from testing/certificates/partial-trust-chain/key.pem rename to packages/testing/certificates/partial-trust-chain/key.pem diff --git a/testing/certificates/server-invalidhost.bundle.pem b/packages/testing/certificates/server-invalidhost.bundle.pem similarity index 100% rename from testing/certificates/server-invalidhost.bundle.pem rename to packages/testing/certificates/server-invalidhost.bundle.pem diff --git a/testing/certificates/server-invalidhost.key b/packages/testing/certificates/server-invalidhost.key similarity index 100% rename from testing/certificates/server-invalidhost.key rename to packages/testing/certificates/server-invalidhost.key diff --git a/testing/certificates/server.bundle.pem b/packages/testing/certificates/server.bundle.pem similarity index 100% rename from testing/certificates/server.bundle.pem rename to packages/testing/certificates/server.bundle.pem diff --git a/testing/certificates/server.key b/packages/testing/certificates/server.key similarity index 100% rename from testing/certificates/server.key rename to packages/testing/certificates/server.key diff --git a/testing/package.json b/packages/testing/package.json similarity index 100% rename from testing/package.json rename to packages/testing/package.json diff --git a/testing/src/eventually.ts b/packages/testing/src/eventually.ts similarity index 100% rename from testing/src/eventually.ts rename to packages/testing/src/eventually.ts diff --git a/testing/src/fake-kms.ts b/packages/testing/src/fake-kms.ts similarity index 100% rename from testing/src/fake-kms.ts rename to packages/testing/src/fake-kms.ts diff --git a/testing/src/index.ts b/packages/testing/src/index.ts similarity index 100% rename from testing/src/index.ts rename to packages/testing/src/index.ts diff --git a/testing/src/integration-testing-hooks.ts b/packages/testing/src/integration-testing-hooks.ts similarity index 100% rename from testing/src/integration-testing-hooks.ts rename to packages/testing/src/integration-testing-hooks.ts diff --git a/testing/test-vscode.sh b/packages/testing/test-vscode.sh similarity index 100% rename from testing/test-vscode.sh rename to packages/testing/test-vscode.sh diff --git a/testing/tests-globalconfig.conf b/packages/testing/tests-globalconfig.conf similarity index 100% rename from testing/tests-globalconfig.conf rename to packages/testing/tests-globalconfig.conf diff --git a/testing/tsconfig-lint.json b/packages/testing/tsconfig-lint.json similarity index 100% rename from testing/tsconfig-lint.json rename to packages/testing/tsconfig-lint.json diff --git a/testing/tsconfig.json b/packages/testing/tsconfig.json similarity index 100% rename from testing/tsconfig.json rename to packages/testing/tsconfig.json From d5fb0c454448963bd28522a05904b3d598b93509 Mon Sep 17 00:00:00 2001 From: gagik Date: Thu, 13 Nov 2025 20:22:16 +0100 Subject: [PATCH 03/11] chore: package-lock --- package-lock.json | 48 +++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 197f0fee94..33e9d68d44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "packages/i18n", "packages/logging", "packages/shell-bson", + "packages/testing", "packages/arg-parser", "packages/service-provider-core", "packages/service-provider-node-driver", @@ -7634,7 +7635,7 @@ "link": true }, "node_modules/@mongosh/testing": { - "resolved": "testing", + "resolved": "packages/testing", "link": true }, "node_modules/@mongosh/types": { @@ -13162,7 +13163,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "dev": true, "license": "MIT", "dependencies": { "event-target-shim": "^5.0.0" @@ -17517,7 +17517,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/duplexpair/-/duplexpair-1.0.2.tgz", "integrity": "sha512-6DHuWdEGHNcuSqrn926rWJcRsTDrb+ugw0hx/trAxCH48z9WlFqDtwtbiEMq/KGFYQWzLs1VA0I6KUkuIgCoXw==", - "dev": true, "license": "MIT", "dependencies": { "readable-stream": "^4.5.2" @@ -17527,7 +17526,6 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "dev": true, "funding": [ { "type": "github", @@ -17552,7 +17550,6 @@ "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.8.x" @@ -17562,7 +17559,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, "funding": [ { "type": "github", @@ -17583,7 +17579,6 @@ "version": "4.5.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", - "dev": true, "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", @@ -18706,7 +18701,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -26035,7 +26029,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/mongodb-runner/-/mongodb-runner-6.0.0.tgz", "integrity": "sha512-ijhBVCcTWRlauxp4UdIuktfPjEqlt8yOo0u7XyE99HdaITzL0BjS4x/dOyNzddewC6gw5wxH1uYx+Uo7GfeUnw==", - "dev": true, "license": "Apache-2.0", "dependencies": { "@mongodb-js/mongodb-downloader": "^1.0.0", @@ -26053,7 +26046,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/@mongodb-js/mongodb-downloader/-/mongodb-downloader-1.0.0.tgz", "integrity": "sha512-xz4zr/5RWfAaHp9Kf7XPaLNxKaisl2NJGFEDQRNjB/ru79LdpLQbbSjQazTOl6JLcBvAjNNvauTeTwmgEvSUlA==", - "dev": true, "license": "Apache-2.0", "dependencies": { "debug": "^4.4.0", @@ -26068,7 +26060,6 @@ "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, "license": "ISC", "dependencies": { "string-width": "^4.2.0", @@ -26083,7 +26074,6 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -26101,14 +26091,12 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/mongodb-runner/node_modules/yargs": { "version": "17.7.2", "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "dev": true, "license": "MIT", "dependencies": { "cliui": "^8.0.1", @@ -26127,7 +26115,6 @@ "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "dev": true, "license": "ISC", "engines": { "node": ">=12" @@ -29116,7 +29103,6 @@ "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.6.0" @@ -29249,7 +29235,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", - "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", @@ -36444,6 +36429,33 @@ "@types/node": "*" } }, + "packages/testing": { + "name": "@mongosh/testing", + "version": "0.0.0-dev.0", + "license": "Apache-2.0", + "dependencies": { + "@mongosh/build": "3.7.8", + "duplexpair": "^1.0.2", + "mongodb": "^6.19.0", + "mongodb-connection-string-url": "^3.0.1", + "mongodb-runner": "^6.0.0", + "semver": "^7.3.4", + "which": "^2.0.2" + }, + "devDependencies": { + "@mongodb-js/eslint-config-mongosh": "^1.0.0", + "@mongodb-js/prettier-config-devtools": "^1.0.1", + "@mongodb-js/tsconfig-mongosh": "^1.0.0", + "@types/semver": "^7.3.4", + "@types/which": "^1.3.2", + "eslint": "^7.25.0", + "prettier": "^2.8.8", + "typescript": "^5.3.3" + }, + "engines": { + "node": ">=14.15.1" + } + }, "packages/types": { "name": "@mongosh/types", "version": "3.14.0", @@ -36478,7 +36490,7 @@ "testing": { "name": "@mongosh/testing", "version": "0.0.0-dev.0", - "dev": true, + "extraneous": true, "license": "Apache-2.0", "dependencies": { "@mongosh/build": "3.7.8", From fcfa3cc7bcfd8cd58053076381222145e9d1f0d1 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 17 Nov 2025 13:29:38 +0100 Subject: [PATCH 04/11] chore: fix testing src --- packages/e2e-tests/test/repl-helpers.ts | 10 +--------- packages/shell-api/src/field-level-encryption.spec.ts | 10 +--------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/packages/e2e-tests/test/repl-helpers.ts b/packages/e2e-tests/test/repl-helpers.ts index 0035465bf7..02ae993a02 100644 --- a/packages/e2e-tests/test/repl-helpers.ts +++ b/packages/e2e-tests/test/repl-helpers.ts @@ -141,15 +141,7 @@ const setTemporaryHomeDirectory = () => { }; function getCertPath(filename: string): string { - return path.join( - __dirname, - '..', - '..', - '..', - 'testing', - 'certificates', - filename - ); + return path.join(__dirname, '..', '..', 'testing', 'certificates', filename); } // TLS requires matching hostnames, so here we need to explicitly diff --git a/packages/shell-api/src/field-level-encryption.spec.ts b/packages/shell-api/src/field-level-encryption.spec.ts index f47073a7db..dacda2f283 100644 --- a/packages/shell-api/src/field-level-encryption.spec.ts +++ b/packages/shell-api/src/field-level-encryption.spec.ts @@ -85,15 +85,7 @@ const exampleUUID = new bson.Binary( ).toUUID(); function getCertPath(filename: string): string { - return path.join( - __dirname, - '..', - '..', - '..', - 'testing', - 'certificates', - filename - ); + return path.join(__dirname, '..', '..', 'testing', 'certificates', filename); } describe('Field Level Encryption', function () { From c3f1a283cfca5fabbf08bedecd1ca0028f396d53 Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 17 Nov 2025 13:40:33 +0100 Subject: [PATCH 05/11] chore: use scripts for test-vscode --- .evergreen.yml | 2 +- .evergreen/evergreen.yml.in | 2 +- {packages/testing => scripts}/test-vscode.sh | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {packages/testing => scripts}/test-vscode.sh (100%) diff --git a/.evergreen.yml b/.evergreen.yml index 4cfce45453..68dfb79922 100644 --- a/.evergreen.yml +++ b/.evergreen.yml @@ -4117,7 +4117,7 @@ functions: (cd scripts/docker && docker build --build-arg NODE_JS_VERSION="$NODE_VERSION" -t ubuntu24.04-xvfb -f ubuntu24.04-xvfb.Dockerfile .) docker run \ --rm -v $PWD:/tmp/build ubuntu24.04-xvfb \ - -c 'cd /tmp/build && ./testing/test-vscode.sh' + -c 'cd /tmp/build && ./scripts/test-vscode.sh' } test_connectivity: - command: expansions.write diff --git a/.evergreen/evergreen.yml.in b/.evergreen/evergreen.yml.in index 349318a047..dcb2467763 100644 --- a/.evergreen/evergreen.yml.in +++ b/.evergreen/evergreen.yml.in @@ -336,7 +336,7 @@ functions: (cd scripts/docker && docker build --build-arg NODE_JS_VERSION="$NODE_VERSION" -t ubuntu24.04-xvfb -f ubuntu24.04-xvfb.Dockerfile .) docker run \ --rm -v $PWD:/tmp/build ubuntu24.04-xvfb \ - -c 'cd /tmp/build && ./testing/test-vscode.sh' + -c 'cd /tmp/build && ./scripts/test-vscode.sh' } test_connectivity: - command: expansions.write diff --git a/packages/testing/test-vscode.sh b/scripts/test-vscode.sh similarity index 100% rename from packages/testing/test-vscode.sh rename to scripts/test-vscode.sh From 52c04780cc0a3f74e468364967940cfebb9694ca Mon Sep 17 00:00:00 2001 From: gagik Date: Mon, 17 Nov 2025 15:24:57 +0100 Subject: [PATCH 06/11] chore: export getTestCertificatePath --- packages/e2e-tests/test/e2e-oidc.spec.ts | 9 +++--- packages/e2e-tests/test/e2e-proxy.spec.ts | 11 +++---- packages/e2e-tests/test/e2e-tls.spec.ts | 31 +++++++++++-------- packages/e2e-tests/test/repl-helpers.ts | 5 --- .../src/field-level-encryption.spec.ts | 19 ++++++------ packages/testing/README.md | 6 +--- packages/testing/src/index.ts | 12 +++++++ 7 files changed, 49 insertions(+), 44 deletions(-) diff --git a/packages/e2e-tests/test/e2e-oidc.spec.ts b/packages/e2e-tests/test/e2e-oidc.spec.ts index 673f6955eb..69b847abfd 100644 --- a/packages/e2e-tests/test/e2e-oidc.spec.ts +++ b/packages/e2e-tests/test/e2e-oidc.spec.ts @@ -2,6 +2,7 @@ import { MongoRunnerSetup, skipIfApiStrict, skipIfEnvServerVersion, + getTestCertificatePath, } from '@mongosh/testing'; import { promises as fs } from 'fs'; import type { OIDCMockProviderConfig } from '@mongodb-js/oidc-mock-provider'; @@ -10,7 +11,7 @@ import type { TestShell } from './test-shell'; import path from 'path'; import { expect } from 'chai'; import { createServer as createHTTPSServer } from 'https'; -import { getCertPath, readReplLogFile, useTmpdir } from './repl-helpers'; +import { readReplLogFile, useTmpdir } from './repl-helpers'; import { baseOidcServerConfig, commonOidcServerArgs, @@ -67,7 +68,7 @@ describe('OIDC auth e2e', function () { }, }; const httpsServerKeyCertBundle = await fs.readFile( - getCertPath('server.bundle.pem') + getTestCertificatePath('server.bundle.pem') ); [oidcMockProvider, oidcMockProviderHttps] = await Promise.all([ OIDCMockProvider.create(oidcMockProviderConfig), @@ -411,7 +412,7 @@ describe('OIDC auth e2e', function () { it('can specify --tlsUseSystemCA as a no-op', async function () { await fs.mkdir(path.join(tmpdir.path, 'certs'), { recursive: true }); await fs.copyFile( - getCertPath('ca.crt'), + getTestCertificatePath('ca.crt'), path.join(tmpdir.path, 'certs', 'somefilename.crt') ); @@ -441,7 +442,7 @@ describe('OIDC auth e2e', function () { it('uses system ca by default when calling the IdP https endpoint', async function () { await fs.mkdir(path.join(tmpdir.path, 'certs'), { recursive: true }); await fs.copyFile( - getCertPath('ca.crt'), + getTestCertificatePath('ca.crt'), path.join(tmpdir.path, 'certs', 'somefilename.crt') ); diff --git a/packages/e2e-tests/test/e2e-proxy.spec.ts b/packages/e2e-tests/test/e2e-proxy.spec.ts index f827307984..23910ca60f 100644 --- a/packages/e2e-tests/test/e2e-proxy.spec.ts +++ b/packages/e2e-tests/test/e2e-proxy.spec.ts @@ -10,14 +10,11 @@ import { skipIfEnvServerVersion, startSharedTestServer, startTestServer, + getTestCertificatePath, } from '@mongosh/testing'; import type { Server as HTTPSServer } from 'https'; import { createServer as createHTTPSServer } from 'https'; -import { - connectionStringWithLocalhost, - getCertPath, - useTmpdir, -} from './repl-helpers'; +import { connectionStringWithLocalhost, useTmpdir } from './repl-helpers'; import { once } from 'events'; import { connect } from 'net'; import type { AddressInfo, Socket } from 'net'; @@ -32,8 +29,8 @@ import { skipOIDCTestsDueToPlatformOrServerVersion, } from './oidc-helpers'; -const CA_CERT = getCertPath('ca.crt'); -const SERVER_BUNDLE = getCertPath('server.bundle.pem'); +const CA_CERT = getTestCertificatePath('ca.crt'); +const SERVER_BUNDLE = getTestCertificatePath('server.bundle.pem'); describe('e2e proxy support', function () { skipIfApiStrict(); diff --git a/packages/e2e-tests/test/e2e-tls.spec.ts b/packages/e2e-tests/test/e2e-tls.spec.ts index 351fea3ddd..6d763f3b4f 100644 --- a/packages/e2e-tests/test/e2e-tls.spec.ts +++ b/packages/e2e-tests/test/e2e-tls.spec.ts @@ -1,27 +1,32 @@ import { expect } from 'chai'; import { promises as fs } from 'fs'; import path from 'path'; -import { startTestServer } from '@mongosh/testing'; +import { startTestServer, getTestCertificatePath } from '@mongosh/testing'; import { useTmpdir, setTemporaryHomeDirectory, readReplLogFile, - getCertPath, connectionStringWithLocalhost, } from './repl-helpers'; -const CA_CERT = getCertPath('ca.crt'); -const NON_CA_CERT = getCertPath('non-ca.crt'); -const CLIENT_CERT = getCertPath('client.bundle.pem'); -const CLIENT_CERT_PFX = getCertPath('client.bundle.pfx'); -const CLIENT_CERT_ENCRYPTED = getCertPath('client.bundle.encrypted.pem'); +const CA_CERT = getTestCertificatePath('ca.crt'); +const NON_CA_CERT = getTestCertificatePath('non-ca.crt'); +const CLIENT_CERT = getTestCertificatePath('client.bundle.pem'); +const CLIENT_CERT_PFX = getTestCertificatePath('client.bundle.pfx'); +const CLIENT_CERT_ENCRYPTED = getTestCertificatePath( + 'client.bundle.encrypted.pem' +); const CLIENT_CERT_PASSWORD = 'p4ssw0rd'; -const INVALID_CLIENT_CERT = getCertPath('invalid-client.bundle.pem'); -const SERVER_KEY = getCertPath('server.bundle.pem'); -const SERVER_INVALIDHOST_KEY = getCertPath('server-invalidhost.bundle.pem'); -const CRL_INCLUDING_SERVER = getCertPath('ca-server.crl'); -const PARTIAL_TRUST_CHAIN_CA = getCertPath('partial-trust-chain/ca.pem'); -const PARTIAL_TRUST_CHAIN_KEY_AND_CERT = getCertPath( +const INVALID_CLIENT_CERT = getTestCertificatePath('invalid-client.bundle.pem'); +const SERVER_KEY = getTestCertificatePath('server.bundle.pem'); +const SERVER_INVALIDHOST_KEY = getTestCertificatePath( + 'server-invalidhost.bundle.pem' +); +const CRL_INCLUDING_SERVER = getTestCertificatePath('ca-server.crl'); +const PARTIAL_TRUST_CHAIN_CA = getTestCertificatePath( + 'partial-trust-chain/ca.pem' +); +const PARTIAL_TRUST_CHAIN_KEY_AND_CERT = getTestCertificatePath( 'partial-trust-chain/key-and-cert.pem' ); diff --git a/packages/e2e-tests/test/repl-helpers.ts b/packages/e2e-tests/test/repl-helpers.ts index 02ae993a02..8c80cd9970 100644 --- a/packages/e2e-tests/test/repl-helpers.ts +++ b/packages/e2e-tests/test/repl-helpers.ts @@ -140,10 +140,6 @@ const setTemporaryHomeDirectory = () => { return { homedir, env }; }; -function getCertPath(filename: string): string { - return path.join(__dirname, '..', '..', 'testing', 'certificates', filename); -} - // TLS requires matching hostnames, so here we need to explicitly // specify `localhost` + IPv4 instead of `127.0.0.1` async function connectionStringWithLocalhost( @@ -166,7 +162,6 @@ export { readReplLogFile, fakeExternalEditor, setTemporaryHomeDirectory, - getCertPath, connectionStringWithLocalhost, MongoLogEntryFromFile, }; diff --git a/packages/shell-api/src/field-level-encryption.spec.ts b/packages/shell-api/src/field-level-encryption.spec.ts index dacda2f283..33dee8d67b 100644 --- a/packages/shell-api/src/field-level-encryption.spec.ts +++ b/packages/shell-api/src/field-level-encryption.spec.ts @@ -11,7 +11,6 @@ import * as bson from 'bson'; import { expect } from 'chai'; import { EventEmitter } from 'events'; import { promises as fs } from 'fs'; -import path from 'path'; import { Duplex } from 'stream'; import sinon from 'sinon'; import type { StubbedInstance } from 'ts-sinon'; @@ -33,6 +32,7 @@ import { startSharedTestServer, makeFakeHTTPConnection, fakeAWSHandlers, + getTestCertificatePath, } from '@mongosh/testing'; import { Collection } from './collection'; import { dummyOptions } from './helpers.spec'; @@ -84,10 +84,6 @@ const exampleUUID = new bson.Binary( 4 ).toUUID(); -function getCertPath(filename: string): string { - return path.join(__dirname, '..', '..', 'testing', 'certificates', filename); -} - describe('Field Level Encryption', function () { let sp: StubbedInstance; let mongo: Mongo; @@ -871,9 +867,11 @@ srDVjIT3LsvTqw==`, { endpoint: 'kmip.example.com:123', tlsOptions: { - tlsCertificateKeyFile: getCertPath('client.bundle.encrypted.pem'), + tlsCertificateKeyFile: getTestCertificatePath( + 'client.bundle.encrypted.pem' + ), tlsCertificateKeyFilePassword: 'p4ssw0rd', - tlsCAFile: getCertPath('ca.crt'), + tlsCAFile: getTestCertificatePath('ca.crt'), }, }, ], @@ -941,12 +939,12 @@ srDVjIT3LsvTqw==`, servername: 'kmip.example.com', port: 123, passphrase: 'p4ssw0rd', - ca: await fs.readFile(getCertPath('ca.crt')), + ca: await fs.readFile(getTestCertificatePath('ca.crt')), cert: await fs.readFile( - getCertPath('client.bundle.encrypted.pem') + getTestCertificatePath('client.bundle.encrypted.pem') ), key: await fs.readFile( - getCertPath('client.bundle.encrypted.pem') + getTestCertificatePath('client.bundle.encrypted.pem') ), }, }, @@ -954,6 +952,7 @@ srDVjIT3LsvTqw==`, return; } expect.fail('missed exception'); + break; default: throw new Error(`unreachable ${kmsName}`); } diff --git a/packages/testing/README.md b/packages/testing/README.md index 164e1bc172..ff1366bc02 100644 --- a/packages/testing/README.md +++ b/packages/testing/README.md @@ -1,6 +1,6 @@ # @mongosh/testing -Internal testing utilities for mongosh packages. This package is only used for testing purposes within the mongosh monorepo. +Internal testing utilities for mongosh packages. This package is private and only used for testing purposes within the mongosh monorepo. ## Contents @@ -18,7 +18,3 @@ import { makeFakeHTTPServer, } from '@mongosh/testing'; ``` - -## Note - -This package is marked as private and will not be published to npm. diff --git a/packages/testing/src/index.ts b/packages/testing/src/index.ts index 012b9fe339..bc8f9b58a2 100644 --- a/packages/testing/src/index.ts +++ b/packages/testing/src/index.ts @@ -1,3 +1,15 @@ +import path from 'path'; + export * from './integration-testing-hooks'; export * from './eventually'; export * from './fake-kms'; + +/** + * Path to the certificates directory containing test certificates + */ +const TEST_CERTIFICATES_DIR = path.resolve(__dirname, '..', 'certificates'); + +/** Get the path to a test certificate */ +export function getTestCertificatePath(filename: string): string { + return path.join(TEST_CERTIFICATES_DIR, filename); +} From 0d9683607e4320f94cb6da151619aeadf06f6453 Mon Sep 17 00:00:00 2001 From: gagik Date: Tue, 18 Nov 2025 16:55:07 +0100 Subject: [PATCH 07/11] chore: fix setup-env --- .evergreen/setup-env.sh | 2 +- .nycrc | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.evergreen/setup-env.sh b/.evergreen/setup-env.sh index c3c241ba09..1c6cee690a 100755 --- a/.evergreen/setup-env.sh +++ b/.evergreen/setup-env.sh @@ -6,7 +6,7 @@ OS_ARCH="$(uname "-m")" export BASEDIR="$PWD/.evergreen" export PATH="$BASEDIR/npm-10/node_modules/.bin:$BASEDIR/node-v$NODE_JS_VERSION-win-x64:/opt/java/jdk16/bin:$PATH" -export MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING="$BASEDIR/../../testing/tests-globalconfig.conf" +export MONGOSH_GLOBAL_CONFIG_FILE_FOR_TESTING="$BASEDIR/../../packages/testing/tests-globalconfig.conf" export IS_MONGOSH_EVERGREEN_CI=1 export DEBUG="mongodb*,$DEBUG" diff --git a/.nycrc b/.nycrc index 6eeae76686..204b9ee857 100644 --- a/.nycrc +++ b/.nycrc @@ -1,12 +1,8 @@ { - "include": [ - "packages/*/src/**", - "scripts/*/src/**", - "configs/*/src/**" - ], + "include": ["packages/*/src/**", "scripts/*/src/**", "configs/*/src/**"], "exclude": [ "test", - "testing", + "packages/testing", "config", "**/*.d.ts", "**/*.spec.{ts,js,tsx,jsx,cjs,mjs}", From a57a1fcd4766106114db41d158672d2e87f56077 Mon Sep 17 00:00:00 2001 From: Gagik Amaryan Date: Wed, 19 Nov 2025 11:13:06 +0100 Subject: [PATCH 08/11] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/testing/src/integration-testing-hooks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/testing/src/integration-testing-hooks.ts b/packages/testing/src/integration-testing-hooks.ts index ad6186fc21..b28925a47b 100644 --- a/packages/testing/src/integration-testing-hooks.ts +++ b/packages/testing/src/integration-testing-hooks.ts @@ -14,7 +14,7 @@ const execFile = promisify(child_process.execFile); // Return the path to the temporary directory and ensure that it exists. async function getTmpdir(): Promise { - const tmpdir = path.resolve(__dirname, '..', '..', 'tmp'); + const tmpdir = path.resolve(__dirname, '..', '..', '..', 'tmp'); await fs.mkdir(tmpdir, { recursive: true }); return tmpdir; } From 4fcbdd285e769f703c376ed97bee856f1584d708 Mon Sep 17 00:00:00 2001 From: gagik Date: Thu, 20 Nov 2025 12:21:02 +0100 Subject: [PATCH 09/11] chore: move certificates inside --- mongosh.code-workspace | 127 ++++++++++++++++++ package-lock.json | 23 +++- package.json | 2 +- packages/testing/package.json | 4 +- .../testing/{ => src}/certificates/README.md | 0 .../{ => src}/certificates/ca-server.crl | 0 .../testing/{ => src}/certificates/ca.cnf | 0 .../testing/{ => src}/certificates/ca.crt | 0 packages/testing/{ => src}/certificates/ca.db | 0 .../testing/{ => src}/certificates/ca.db.attr | 0 .../testing/{ => src}/certificates/ca.key | 0 .../testing/{ => src}/certificates/ca.serial | 0 .../certificates/client.bundle.encrypted.pem | 0 .../{ => src}/certificates/client.bundle.pem | 0 .../{ => src}/certificates/client.bundle.pfx | Bin .../certificates/client.encrypted.key | 0 .../testing/{ => src}/certificates/client.key | 0 .../testing/{ => src}/certificates/client.pem | 0 .../certificates/invalid-client.bundle.pem | 0 .../{ => src}/certificates/invalid-client.key | 0 .../testing/{ => src}/certificates/non-ca.crt | 0 .../testing/{ => src}/certificates/non-ca.key | 0 .../certificates/partial-trust-chain/ca.pem | 0 .../certificates/partial-trust-chain/cert.pem | 0 .../partial-trust-chain/key-and-cert.pem | 0 .../certificates/partial-trust-chain/key.pem | 0 .../server-invalidhost.bundle.pem | 0 .../certificates/server-invalidhost.key | 0 .../{ => src}/certificates/server.bundle.pem | 0 .../testing/{ => src}/certificates/server.key | 0 packages/testing/src/index.ts | 2 +- 31 files changed, 149 insertions(+), 9 deletions(-) create mode 100644 mongosh.code-workspace rename packages/testing/{ => src}/certificates/README.md (100%) rename packages/testing/{ => src}/certificates/ca-server.crl (100%) rename packages/testing/{ => src}/certificates/ca.cnf (100%) rename packages/testing/{ => src}/certificates/ca.crt (100%) rename packages/testing/{ => src}/certificates/ca.db (100%) rename packages/testing/{ => src}/certificates/ca.db.attr (100%) rename packages/testing/{ => src}/certificates/ca.key (100%) rename packages/testing/{ => src}/certificates/ca.serial (100%) rename packages/testing/{ => src}/certificates/client.bundle.encrypted.pem (100%) rename packages/testing/{ => src}/certificates/client.bundle.pem (100%) rename packages/testing/{ => src}/certificates/client.bundle.pfx (100%) rename packages/testing/{ => src}/certificates/client.encrypted.key (100%) rename packages/testing/{ => src}/certificates/client.key (100%) rename packages/testing/{ => src}/certificates/client.pem (100%) rename packages/testing/{ => src}/certificates/invalid-client.bundle.pem (100%) rename packages/testing/{ => src}/certificates/invalid-client.key (100%) rename packages/testing/{ => src}/certificates/non-ca.crt (100%) rename packages/testing/{ => src}/certificates/non-ca.key (100%) rename packages/testing/{ => src}/certificates/partial-trust-chain/ca.pem (100%) rename packages/testing/{ => src}/certificates/partial-trust-chain/cert.pem (100%) rename packages/testing/{ => src}/certificates/partial-trust-chain/key-and-cert.pem (100%) rename packages/testing/{ => src}/certificates/partial-trust-chain/key.pem (100%) rename packages/testing/{ => src}/certificates/server-invalidhost.bundle.pem (100%) rename packages/testing/{ => src}/certificates/server-invalidhost.key (100%) rename packages/testing/{ => src}/certificates/server.bundle.pem (100%) rename packages/testing/{ => src}/certificates/server.key (100%) diff --git a/mongosh.code-workspace b/mongosh.code-workspace new file mode 100644 index 0000000000..293d695fd8 --- /dev/null +++ b/mongosh.code-workspace @@ -0,0 +1,127 @@ +{ + "folders": [ + { + "name": "mongosh", + "path": "." + }, + { + "name": "📦 @mongosh/arg-parser", + "path": "packages/arg-parser" + }, + { + "name": "📦 @mongosh/async-rewriter2", + "path": "packages/async-rewriter2" + }, + { + "name": "📦 @mongosh/autocomplete", + "path": "packages/autocomplete" + }, + // { + // "name": "📦 @mongosh/browser-repl", + // "path": "packages/browser-repl" + // }, + { + "name": "📦 @mongosh/browser-runtime-core", + "path": "packages/browser-runtime-core" + }, + { + "name": "📦 @mongosh/browser-runtime-electron", + "path": "packages/browser-runtime-electron" + }, + { + "name": "📦 @mongosh/build", + "path": "packages/build" + }, + { + "name": "📦 @mongosh/cli-repl", + "path": "packages/cli-repl" + }, + { + "name": "📦 @mongosh/connectivity-tests", + "path": "packages/connectivity-tests" + }, + { + "name": "📦 @mongosh/e2e-tests", + "path": "packages/e2e-tests" + }, + { + "name": "📦 @mongosh/editor", + "path": "packages/editor" + }, + { + "name": "📦 @mongosh/errors", + "path": "packages/errors" + }, + { + "name": "📦 @mongosh/history", + "path": "packages/history" + }, + { + "name": "📦 @mongosh/i18n", + "path": "packages/i18n" + }, + { + "name": "📦 @mongosh/java-shell", + "path": "packages/java-shell" + }, + { + "name": "📦 @mongosh/js-multiline-to-singleline", + "path": "packages/js-multiline-to-singleline" + }, + { + "name": "📦 @mongosh/logging", + "path": "packages/logging" + }, + { + "name": "📦 @mongosh/node-runtime-worker-thread", + "path": "packages/node-runtime-worker-thread" + }, + { + "name": "📦 @mongosh/service-provider-core", + "path": "packages/service-provider-core" + }, + { + "name": "📦 @mongosh/service-provider-node-driver", + "path": "packages/service-provider-node-driver" + }, + { + "name": "📦 @mongosh/shell-api", + "path": "packages/shell-api" + }, + { + "name": "📦 @mongosh/shell-bson", + "path": "packages/shell-bson" + }, + { + "name": "📦 @mongosh/shell-evaluator", + "path": "packages/shell-evaluator" + }, + { + "name": "📦 @mongosh/snippet-manager", + "path": "packages/snippet-manager" + }, + { + "name": "📦 @mongosh/testing", + "path": "packages/testing" + }, + { + "name": "📦 @mongosh/types", + "path": "packages/types" + } + ], + "settings": { + "typescript.tsdk": "node_modules/typescript/lib", + "mochaExplorer.files": "./{src,lib}/**/*.spec.ts", + "mochaExplorer.require": [ + "../../scripts/import-expansions.js", + "ts-node/register" + ], + "mochaExplorer.timeout": 60000, + "mochaExplorer.ui": "bdd", + "mochaExplorer.esmLoader": false, + "mochaExplorer.monkeyPatch": true, + "mochaExplorer.autoload": true, + "testExplorer.codeLens": true, + "testExplorer.gutterDecoration": true + } +} diff --git a/package-lock.json b/package-lock.json index 33e9d68d44..6854d6527e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,7 +62,7 @@ "husky": "^9.0.11", "mocha": "^10.2.0", "mongodb": "^6.19.0", - "mongodb-runner": "^6.0.0", + "mongodb-runner": "^6.2.0", "node-gyp": "^9.0.0 || ^10.2.0", "nyc": "^15.1.0", "pkg-up": "^3.1.0", @@ -26026,12 +26026,13 @@ "optional": true }, "node_modules/mongodb-runner": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/mongodb-runner/-/mongodb-runner-6.0.0.tgz", - "integrity": "sha512-ijhBVCcTWRlauxp4UdIuktfPjEqlt8yOo0u7XyE99HdaITzL0BjS4x/dOyNzddewC6gw5wxH1uYx+Uo7GfeUnw==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/mongodb-runner/-/mongodb-runner-6.2.0.tgz", + "integrity": "sha512-3RCYNGUJIHkwxmhyfQdY7gp6KqbyqEb2lNw3ZV36XaJFU07bYb9b497ba2YuH3evdNonbqXCUf+yxdAUWNPojg==", "license": "Apache-2.0", "dependencies": { "@mongodb-js/mongodb-downloader": "^1.0.0", + "@mongodb-js/oidc-mock-provider": "^0.12.0", "@mongodb-js/saslprep": "^1.3.2", "debug": "^4.4.0", "mongodb": "^6.9.0", @@ -26056,6 +26057,18 @@ "tar": "^6.1.15" } }, + "node_modules/mongodb-runner/node_modules/@mongodb-js/oidc-mock-provider": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@mongodb-js/oidc-mock-provider/-/oidc-mock-provider-0.12.0.tgz", + "integrity": "sha512-OBGqTQ25CJpNhvSy5gYNcTSi+cOExeGliAcuObXX6AswhpW7gt62go9md0jYAs10MPKTPFOvK+RrXX4WIkr/nA==", + "license": "Apache-2.0", + "dependencies": { + "yargs": "^17.7.2" + }, + "bin": { + "oidc-mock-provider": "bin/oidc-mock-provider.js" + } + }, "node_modules/mongodb-runner/node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -36438,7 +36451,7 @@ "duplexpair": "^1.0.2", "mongodb": "^6.19.0", "mongodb-connection-string-url": "^3.0.1", - "mongodb-runner": "^6.0.0", + "mongodb-runner": "^6.2.0", "semver": "^7.3.4", "which": "^2.0.2" }, diff --git a/package.json b/package.json index 9df364227d..0d9c315e9a 100644 --- a/package.json +++ b/package.json @@ -117,7 +117,7 @@ "husky": "^9.0.11", "mocha": "^10.2.0", "mongodb": "^6.19.0", - "mongodb-runner": "^6.0.0", + "mongodb-runner": "^6.2.0", "node-gyp": "^9.0.0 || ^10.2.0", "nyc": "^15.1.0", "pkg-up": "^3.1.0", diff --git a/packages/testing/package.json b/packages/testing/package.json index 2450280cf1..e98d975a0b 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,7 +1,7 @@ { "name": "@mongosh/testing", "version": "0.0.0-dev.0", - "description": "MongoDB Shell Testing Utilities (internal use only)", + "description": "MongoDB Shell Testing Utilities", "homepage": "https://github.com/mongodb-js/mongosh", "license": "Apache-2.0", "main": "lib/index.js", @@ -26,7 +26,7 @@ "duplexpair": "^1.0.2", "mongodb": "^6.19.0", "mongodb-connection-string-url": "^3.0.1", - "mongodb-runner": "^6.0.0", + "mongodb-runner": "^6.2.0", "semver": "^7.3.4", "which": "^2.0.2" }, diff --git a/packages/testing/certificates/README.md b/packages/testing/src/certificates/README.md similarity index 100% rename from packages/testing/certificates/README.md rename to packages/testing/src/certificates/README.md diff --git a/packages/testing/certificates/ca-server.crl b/packages/testing/src/certificates/ca-server.crl similarity index 100% rename from packages/testing/certificates/ca-server.crl rename to packages/testing/src/certificates/ca-server.crl diff --git a/packages/testing/certificates/ca.cnf b/packages/testing/src/certificates/ca.cnf similarity index 100% rename from packages/testing/certificates/ca.cnf rename to packages/testing/src/certificates/ca.cnf diff --git a/packages/testing/certificates/ca.crt b/packages/testing/src/certificates/ca.crt similarity index 100% rename from packages/testing/certificates/ca.crt rename to packages/testing/src/certificates/ca.crt diff --git a/packages/testing/certificates/ca.db b/packages/testing/src/certificates/ca.db similarity index 100% rename from packages/testing/certificates/ca.db rename to packages/testing/src/certificates/ca.db diff --git a/packages/testing/certificates/ca.db.attr b/packages/testing/src/certificates/ca.db.attr similarity index 100% rename from packages/testing/certificates/ca.db.attr rename to packages/testing/src/certificates/ca.db.attr diff --git a/packages/testing/certificates/ca.key b/packages/testing/src/certificates/ca.key similarity index 100% rename from packages/testing/certificates/ca.key rename to packages/testing/src/certificates/ca.key diff --git a/packages/testing/certificates/ca.serial b/packages/testing/src/certificates/ca.serial similarity index 100% rename from packages/testing/certificates/ca.serial rename to packages/testing/src/certificates/ca.serial diff --git a/packages/testing/certificates/client.bundle.encrypted.pem b/packages/testing/src/certificates/client.bundle.encrypted.pem similarity index 100% rename from packages/testing/certificates/client.bundle.encrypted.pem rename to packages/testing/src/certificates/client.bundle.encrypted.pem diff --git a/packages/testing/certificates/client.bundle.pem b/packages/testing/src/certificates/client.bundle.pem similarity index 100% rename from packages/testing/certificates/client.bundle.pem rename to packages/testing/src/certificates/client.bundle.pem diff --git a/packages/testing/certificates/client.bundle.pfx b/packages/testing/src/certificates/client.bundle.pfx similarity index 100% rename from packages/testing/certificates/client.bundle.pfx rename to packages/testing/src/certificates/client.bundle.pfx diff --git a/packages/testing/certificates/client.encrypted.key b/packages/testing/src/certificates/client.encrypted.key similarity index 100% rename from packages/testing/certificates/client.encrypted.key rename to packages/testing/src/certificates/client.encrypted.key diff --git a/packages/testing/certificates/client.key b/packages/testing/src/certificates/client.key similarity index 100% rename from packages/testing/certificates/client.key rename to packages/testing/src/certificates/client.key diff --git a/packages/testing/certificates/client.pem b/packages/testing/src/certificates/client.pem similarity index 100% rename from packages/testing/certificates/client.pem rename to packages/testing/src/certificates/client.pem diff --git a/packages/testing/certificates/invalid-client.bundle.pem b/packages/testing/src/certificates/invalid-client.bundle.pem similarity index 100% rename from packages/testing/certificates/invalid-client.bundle.pem rename to packages/testing/src/certificates/invalid-client.bundle.pem diff --git a/packages/testing/certificates/invalid-client.key b/packages/testing/src/certificates/invalid-client.key similarity index 100% rename from packages/testing/certificates/invalid-client.key rename to packages/testing/src/certificates/invalid-client.key diff --git a/packages/testing/certificates/non-ca.crt b/packages/testing/src/certificates/non-ca.crt similarity index 100% rename from packages/testing/certificates/non-ca.crt rename to packages/testing/src/certificates/non-ca.crt diff --git a/packages/testing/certificates/non-ca.key b/packages/testing/src/certificates/non-ca.key similarity index 100% rename from packages/testing/certificates/non-ca.key rename to packages/testing/src/certificates/non-ca.key diff --git a/packages/testing/certificates/partial-trust-chain/ca.pem b/packages/testing/src/certificates/partial-trust-chain/ca.pem similarity index 100% rename from packages/testing/certificates/partial-trust-chain/ca.pem rename to packages/testing/src/certificates/partial-trust-chain/ca.pem diff --git a/packages/testing/certificates/partial-trust-chain/cert.pem b/packages/testing/src/certificates/partial-trust-chain/cert.pem similarity index 100% rename from packages/testing/certificates/partial-trust-chain/cert.pem rename to packages/testing/src/certificates/partial-trust-chain/cert.pem diff --git a/packages/testing/certificates/partial-trust-chain/key-and-cert.pem b/packages/testing/src/certificates/partial-trust-chain/key-and-cert.pem similarity index 100% rename from packages/testing/certificates/partial-trust-chain/key-and-cert.pem rename to packages/testing/src/certificates/partial-trust-chain/key-and-cert.pem diff --git a/packages/testing/certificates/partial-trust-chain/key.pem b/packages/testing/src/certificates/partial-trust-chain/key.pem similarity index 100% rename from packages/testing/certificates/partial-trust-chain/key.pem rename to packages/testing/src/certificates/partial-trust-chain/key.pem diff --git a/packages/testing/certificates/server-invalidhost.bundle.pem b/packages/testing/src/certificates/server-invalidhost.bundle.pem similarity index 100% rename from packages/testing/certificates/server-invalidhost.bundle.pem rename to packages/testing/src/certificates/server-invalidhost.bundle.pem diff --git a/packages/testing/certificates/server-invalidhost.key b/packages/testing/src/certificates/server-invalidhost.key similarity index 100% rename from packages/testing/certificates/server-invalidhost.key rename to packages/testing/src/certificates/server-invalidhost.key diff --git a/packages/testing/certificates/server.bundle.pem b/packages/testing/src/certificates/server.bundle.pem similarity index 100% rename from packages/testing/certificates/server.bundle.pem rename to packages/testing/src/certificates/server.bundle.pem diff --git a/packages/testing/certificates/server.key b/packages/testing/src/certificates/server.key similarity index 100% rename from packages/testing/certificates/server.key rename to packages/testing/src/certificates/server.key diff --git a/packages/testing/src/index.ts b/packages/testing/src/index.ts index bc8f9b58a2..bf3a508a27 100644 --- a/packages/testing/src/index.ts +++ b/packages/testing/src/index.ts @@ -7,7 +7,7 @@ export * from './fake-kms'; /** * Path to the certificates directory containing test certificates */ -const TEST_CERTIFICATES_DIR = path.resolve(__dirname, '..', 'certificates'); +const TEST_CERTIFICATES_DIR = path.resolve(__dirname, 'certificates'); /** Get the path to a test certificate */ export function getTestCertificatePath(filename: string): string { From 8b1c26180de22ab3a134634765cb7be3428682eb Mon Sep 17 00:00:00 2001 From: gagik Date: Thu, 20 Nov 2025 12:40:32 +0100 Subject: [PATCH 10/11] chore: remove compilation step --- packages/testing/{src => }/certificates/README.md | 0 .../testing/{src => }/certificates/ca-server.crl | 0 packages/testing/{src => }/certificates/ca.cnf | 0 packages/testing/{src => }/certificates/ca.crt | 0 packages/testing/{src => }/certificates/ca.db | 0 packages/testing/{src => }/certificates/ca.db.attr | 0 packages/testing/{src => }/certificates/ca.key | 0 packages/testing/{src => }/certificates/ca.serial | 0 .../certificates/client.bundle.encrypted.pem | 0 .../{src => }/certificates/client.bundle.pem | 0 .../{src => }/certificates/client.bundle.pfx | Bin .../{src => }/certificates/client.encrypted.key | 0 packages/testing/{src => }/certificates/client.key | 0 packages/testing/{src => }/certificates/client.pem | 0 .../certificates/invalid-client.bundle.pem | 0 .../{src => }/certificates/invalid-client.key | 0 packages/testing/{src => }/certificates/non-ca.crt | 0 packages/testing/{src => }/certificates/non-ca.key | 0 .../certificates/partial-trust-chain/ca.pem | 0 .../certificates/partial-trust-chain/cert.pem | 0 .../partial-trust-chain/key-and-cert.pem | 0 .../certificates/partial-trust-chain/key.pem | 0 .../certificates/server-invalidhost.bundle.pem | 0 .../{src => }/certificates/server-invalidhost.key | 0 .../{src => }/certificates/server.bundle.pem | 0 packages/testing/{src => }/certificates/server.key | 0 packages/testing/package.json | 5 ++--- packages/testing/src/index.ts | 2 +- packages/testing/tsconfig.json | 4 ++-- 29 files changed, 5 insertions(+), 6 deletions(-) rename packages/testing/{src => }/certificates/README.md (100%) rename packages/testing/{src => }/certificates/ca-server.crl (100%) rename packages/testing/{src => }/certificates/ca.cnf (100%) rename packages/testing/{src => }/certificates/ca.crt (100%) rename packages/testing/{src => }/certificates/ca.db (100%) rename packages/testing/{src => }/certificates/ca.db.attr (100%) rename packages/testing/{src => }/certificates/ca.key (100%) rename packages/testing/{src => }/certificates/ca.serial (100%) rename packages/testing/{src => }/certificates/client.bundle.encrypted.pem (100%) rename packages/testing/{src => }/certificates/client.bundle.pem (100%) rename packages/testing/{src => }/certificates/client.bundle.pfx (100%) rename packages/testing/{src => }/certificates/client.encrypted.key (100%) rename packages/testing/{src => }/certificates/client.key (100%) rename packages/testing/{src => }/certificates/client.pem (100%) rename packages/testing/{src => }/certificates/invalid-client.bundle.pem (100%) rename packages/testing/{src => }/certificates/invalid-client.key (100%) rename packages/testing/{src => }/certificates/non-ca.crt (100%) rename packages/testing/{src => }/certificates/non-ca.key (100%) rename packages/testing/{src => }/certificates/partial-trust-chain/ca.pem (100%) rename packages/testing/{src => }/certificates/partial-trust-chain/cert.pem (100%) rename packages/testing/{src => }/certificates/partial-trust-chain/key-and-cert.pem (100%) rename packages/testing/{src => }/certificates/partial-trust-chain/key.pem (100%) rename packages/testing/{src => }/certificates/server-invalidhost.bundle.pem (100%) rename packages/testing/{src => }/certificates/server-invalidhost.key (100%) rename packages/testing/{src => }/certificates/server.bundle.pem (100%) rename packages/testing/{src => }/certificates/server.key (100%) diff --git a/packages/testing/src/certificates/README.md b/packages/testing/certificates/README.md similarity index 100% rename from packages/testing/src/certificates/README.md rename to packages/testing/certificates/README.md diff --git a/packages/testing/src/certificates/ca-server.crl b/packages/testing/certificates/ca-server.crl similarity index 100% rename from packages/testing/src/certificates/ca-server.crl rename to packages/testing/certificates/ca-server.crl diff --git a/packages/testing/src/certificates/ca.cnf b/packages/testing/certificates/ca.cnf similarity index 100% rename from packages/testing/src/certificates/ca.cnf rename to packages/testing/certificates/ca.cnf diff --git a/packages/testing/src/certificates/ca.crt b/packages/testing/certificates/ca.crt similarity index 100% rename from packages/testing/src/certificates/ca.crt rename to packages/testing/certificates/ca.crt diff --git a/packages/testing/src/certificates/ca.db b/packages/testing/certificates/ca.db similarity index 100% rename from packages/testing/src/certificates/ca.db rename to packages/testing/certificates/ca.db diff --git a/packages/testing/src/certificates/ca.db.attr b/packages/testing/certificates/ca.db.attr similarity index 100% rename from packages/testing/src/certificates/ca.db.attr rename to packages/testing/certificates/ca.db.attr diff --git a/packages/testing/src/certificates/ca.key b/packages/testing/certificates/ca.key similarity index 100% rename from packages/testing/src/certificates/ca.key rename to packages/testing/certificates/ca.key diff --git a/packages/testing/src/certificates/ca.serial b/packages/testing/certificates/ca.serial similarity index 100% rename from packages/testing/src/certificates/ca.serial rename to packages/testing/certificates/ca.serial diff --git a/packages/testing/src/certificates/client.bundle.encrypted.pem b/packages/testing/certificates/client.bundle.encrypted.pem similarity index 100% rename from packages/testing/src/certificates/client.bundle.encrypted.pem rename to packages/testing/certificates/client.bundle.encrypted.pem diff --git a/packages/testing/src/certificates/client.bundle.pem b/packages/testing/certificates/client.bundle.pem similarity index 100% rename from packages/testing/src/certificates/client.bundle.pem rename to packages/testing/certificates/client.bundle.pem diff --git a/packages/testing/src/certificates/client.bundle.pfx b/packages/testing/certificates/client.bundle.pfx similarity index 100% rename from packages/testing/src/certificates/client.bundle.pfx rename to packages/testing/certificates/client.bundle.pfx diff --git a/packages/testing/src/certificates/client.encrypted.key b/packages/testing/certificates/client.encrypted.key similarity index 100% rename from packages/testing/src/certificates/client.encrypted.key rename to packages/testing/certificates/client.encrypted.key diff --git a/packages/testing/src/certificates/client.key b/packages/testing/certificates/client.key similarity index 100% rename from packages/testing/src/certificates/client.key rename to packages/testing/certificates/client.key diff --git a/packages/testing/src/certificates/client.pem b/packages/testing/certificates/client.pem similarity index 100% rename from packages/testing/src/certificates/client.pem rename to packages/testing/certificates/client.pem diff --git a/packages/testing/src/certificates/invalid-client.bundle.pem b/packages/testing/certificates/invalid-client.bundle.pem similarity index 100% rename from packages/testing/src/certificates/invalid-client.bundle.pem rename to packages/testing/certificates/invalid-client.bundle.pem diff --git a/packages/testing/src/certificates/invalid-client.key b/packages/testing/certificates/invalid-client.key similarity index 100% rename from packages/testing/src/certificates/invalid-client.key rename to packages/testing/certificates/invalid-client.key diff --git a/packages/testing/src/certificates/non-ca.crt b/packages/testing/certificates/non-ca.crt similarity index 100% rename from packages/testing/src/certificates/non-ca.crt rename to packages/testing/certificates/non-ca.crt diff --git a/packages/testing/src/certificates/non-ca.key b/packages/testing/certificates/non-ca.key similarity index 100% rename from packages/testing/src/certificates/non-ca.key rename to packages/testing/certificates/non-ca.key diff --git a/packages/testing/src/certificates/partial-trust-chain/ca.pem b/packages/testing/certificates/partial-trust-chain/ca.pem similarity index 100% rename from packages/testing/src/certificates/partial-trust-chain/ca.pem rename to packages/testing/certificates/partial-trust-chain/ca.pem diff --git a/packages/testing/src/certificates/partial-trust-chain/cert.pem b/packages/testing/certificates/partial-trust-chain/cert.pem similarity index 100% rename from packages/testing/src/certificates/partial-trust-chain/cert.pem rename to packages/testing/certificates/partial-trust-chain/cert.pem diff --git a/packages/testing/src/certificates/partial-trust-chain/key-and-cert.pem b/packages/testing/certificates/partial-trust-chain/key-and-cert.pem similarity index 100% rename from packages/testing/src/certificates/partial-trust-chain/key-and-cert.pem rename to packages/testing/certificates/partial-trust-chain/key-and-cert.pem diff --git a/packages/testing/src/certificates/partial-trust-chain/key.pem b/packages/testing/certificates/partial-trust-chain/key.pem similarity index 100% rename from packages/testing/src/certificates/partial-trust-chain/key.pem rename to packages/testing/certificates/partial-trust-chain/key.pem diff --git a/packages/testing/src/certificates/server-invalidhost.bundle.pem b/packages/testing/certificates/server-invalidhost.bundle.pem similarity index 100% rename from packages/testing/src/certificates/server-invalidhost.bundle.pem rename to packages/testing/certificates/server-invalidhost.bundle.pem diff --git a/packages/testing/src/certificates/server-invalidhost.key b/packages/testing/certificates/server-invalidhost.key similarity index 100% rename from packages/testing/src/certificates/server-invalidhost.key rename to packages/testing/certificates/server-invalidhost.key diff --git a/packages/testing/src/certificates/server.bundle.pem b/packages/testing/certificates/server.bundle.pem similarity index 100% rename from packages/testing/src/certificates/server.bundle.pem rename to packages/testing/certificates/server.bundle.pem diff --git a/packages/testing/src/certificates/server.key b/packages/testing/certificates/server.key similarity index 100% rename from packages/testing/src/certificates/server.key rename to packages/testing/certificates/server.key diff --git a/packages/testing/package.json b/packages/testing/package.json index e98d975a0b..e8e1baafff 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -4,8 +4,8 @@ "description": "MongoDB Shell Testing Utilities", "homepage": "https://github.com/mongodb-js/mongosh", "license": "Apache-2.0", - "main": "lib/index.js", - "types": "lib/index.d.ts", + "main": "src/index.ts", + "types": "src/index.ts", "private": true, "repository": { "type": "git", @@ -15,7 +15,6 @@ "node": ">=14.15.1" }, "scripts": { - "compile": "tsc -p tsconfig.json", "eslint": "eslint", "lint": "npm run eslint . && npm run prettier -- --check .", "prettier": "prettier", diff --git a/packages/testing/src/index.ts b/packages/testing/src/index.ts index bf3a508a27..bc8f9b58a2 100644 --- a/packages/testing/src/index.ts +++ b/packages/testing/src/index.ts @@ -7,7 +7,7 @@ export * from './fake-kms'; /** * Path to the certificates directory containing test certificates */ -const TEST_CERTIFICATES_DIR = path.resolve(__dirname, 'certificates'); +const TEST_CERTIFICATES_DIR = path.resolve(__dirname, '..', 'certificates'); /** Get the path to a test certificate */ export function getTestCertificatePath(filename: string): string { diff --git a/packages/testing/tsconfig.json b/packages/testing/tsconfig.json index 53bf421d6c..8c8bebecf8 100644 --- a/packages/testing/tsconfig.json +++ b/packages/testing/tsconfig.json @@ -6,6 +6,6 @@ "declaration": true, "declarationMap": true }, - "include": ["src/**/*"], - "exclude": ["certificates", "lib"] + "include": ["src/**/*", "src/certificates/**/*"], + "exclude": ["lib"] } From 8ca19bc29b74fcec86c1592e5605418ef9931dfd Mon Sep 17 00:00:00 2001 From: gagik Date: Thu, 20 Nov 2025 13:02:17 +0100 Subject: [PATCH 11/11] chore: empty commit