Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions packages/e2e-tests/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"require": [
"ts-node/register",
"../../scripts/import-expansions.js",
"./test/test-shell-context.ts"
],
"require": ["ts-node/register", "../../scripts/import-expansions.js"],
"timeout": 15000,
"reporter": "../../configs/mocha-config-mongosh/reporter.ts",
"spec": ["./test/*.spec.ts"],
Expand Down
1 change: 1 addition & 0 deletions packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"@mongosh/cli-repl": "2.5.10",
"@mongosh/service-provider-core": "3.7.0",
"@mongosh/testing": "0.0.0-dev.0",
"@mongodb-js/oidc-plugin": "^2.0.5",
"strip-ansi": "^6.0.0"
},
Expand Down
12 changes: 6 additions & 6 deletions packages/e2e-tests/test/e2e-analytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { startTestCluster } from '../../testing/src/integration-testing-hooks';
import { eventually } from '../../testing/src/eventually';
import { startTestCluster, eventually } from '@mongosh/testing';
import { startTestShell } from './test-shell-context';

describe('e2e Analytics Node', function () {
const replSetName = 'replicaSet';
Expand Down Expand Up @@ -33,7 +33,7 @@ describe('e2e Analytics Node', function () {
],
};

const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [await rs0.connectionString()],
});
await shell.waitForPrompt();
Expand All @@ -52,7 +52,7 @@ describe('e2e Analytics Node', function () {

context('without readPreference', function () {
it('a direct connection ends up at primary', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [await rs0.connectionString()],
});
await shell.waitForPrompt();
Expand All @@ -65,13 +65,13 @@ describe('e2e Analytics Node', function () {

context('specifying readPreference and tags', function () {
it('ends up at the ANALYTICS node', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [
`${await rs0.connectionString()}?replicaSet=${replSetName}&readPreference=secondary&readPreferenceTags=nodeType:ANALYTICS`,
],
});

const directConnectionToAnalyticsShell = this.startTestShell({
const directConnectionToAnalyticsShell = startTestShell(this, {
args: [`${await rs3.connectionString()}?directConnection=true`],
});
await Promise.all([
Expand Down
27 changes: 14 additions & 13 deletions packages/e2e-tests/test/e2e-auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { expect } from 'chai';
import type { Db, Document, MongoClientOptions } from 'mongodb';
import { MongoClient } from 'mongodb';
import { eventually } from '../../testing/src/eventually';
import type { TestShell } from './test-shell';
import {
eventually,
skipIfApiStrict,
startSharedTestServer,
} from '../../testing/src/integration-testing-hooks';
} from '@mongosh/testing';
import { startTestShell } from './test-shell-context';

type AssertUserExists = (opts?: Document, username?: string) => Promise<void>;
function createAssertUserExists(db: Db, dbName: string): AssertUserExists {
Expand Down Expand Up @@ -110,7 +111,7 @@ describe('Auth e2e', function () {
beforeEach(async function () {
const connectionString = await testServer.connectionString();
dbName = `test-${Date.now()}`;
shell = this.startTestShell({ args: [connectionString] });
shell = startTestShell(this, { args: [connectionString] });

client = await MongoClient.connect(connectionString, {});

Expand Down Expand Up @@ -878,7 +879,7 @@ describe('Auth e2e', function () {
pathname: `/${dbName}`,
}
);
shell = this.startTestShell({ args: [authConnectionString] });
shell = startTestShell(this, { args: [authConnectionString] });
await shell.waitForPrompt();
shell.assertNoErrors();
await shell.executeLine(`use ${dbName}`);
Expand All @@ -902,7 +903,7 @@ describe('Auth e2e', function () {
pathname: `/${dbName}`,
}
);
shell = this.startTestShell({ args: [authConnectionString] });
shell = startTestShell(this, { args: [authConnectionString] });
await shell.waitForPrompt();
shell.assertNoErrors();
await shell.executeLine(`use ${dbName}`);
Expand All @@ -929,7 +930,7 @@ describe('Auth e2e', function () {
});
it('can auth when there is -u and -p', async function () {
const connectionString = await testServer.connectionString();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
connectionString,
'-u',
Expand Down Expand Up @@ -964,7 +965,7 @@ describe('Auth e2e', function () {
return this.skip(); // No SCRAM-SHA-1 in FIPS mode
}
const connectionString = await testServer.connectionString();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
connectionString,
'-u',
Expand All @@ -988,7 +989,7 @@ describe('Auth e2e', function () {
// This test is not particularly meaningful if we're using the system OpenSSL installation
// and it is not properly configured for FIPS to begin with. This is the case on e.g.
// Ubuntu 22.04 in evergreen CI.
const preTestShell = this.startTestShell({
const preTestShell = startTestShell(this, {
args: [
'--quiet',
'--nodb',
Expand All @@ -1008,7 +1009,7 @@ describe('Auth e2e', function () {
}

const connectionString = await testServer.connectionString();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
connectionString,
'--tlsFIPSMode',
Expand All @@ -1033,7 +1034,7 @@ describe('Auth e2e', function () {
});
it('can auth with SCRAM-SHA-256', async function () {
const connectionString = await testServer.connectionString();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
connectionString,
'-u',
Expand All @@ -1054,7 +1055,7 @@ describe('Auth e2e', function () {
});
it('cannot auth when authenticationMechanism mismatches (sha256 -> sha1)', async function () {
const connectionString = await testServer.connectionString();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
connectionString,
'-u',
Expand All @@ -1075,7 +1076,7 @@ describe('Auth e2e', function () {
});
it('cannot auth when authenticationMechanism mismatches (sha1 -> sha256)', async function () {
const connectionString = await testServer.connectionString();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
connectionString,
'-u',
Expand All @@ -1096,7 +1097,7 @@ describe('Auth e2e', function () {
});
it('does not fail with kerberos not found for GSSAPI', async function () {
const connectionString = await testServer.connectionString();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
connectionString,
'-u',
Expand Down
17 changes: 9 additions & 8 deletions packages/e2e-tests/test/e2e-aws.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from 'chai';
import { spawnSync } from 'child_process';
import { startTestShell } from './test-shell-context';

function assertEnvVariable(variableName: string): string {
if (process.env.MONGOSH_TEST_FORCE_API_STRICT) {
Expand Down Expand Up @@ -123,7 +124,7 @@ describe('e2e AWS AUTH', function () {
context('without environment variables being present', function () {
context('specifying explicit parameters', function () {
it('connects with access key and secret', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [
getConnectionString(),
'--username',
Expand All @@ -145,7 +146,7 @@ describe('e2e AWS AUTH', function () {

it('connects with access key, secret, and session token for IAM role', async function () {
const tokenDetails = generateIamSessionToken();
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [
getConnectionString(),
'--username',
Expand All @@ -170,7 +171,7 @@ describe('e2e AWS AUTH', function () {

context('specifying connection string parameters', function () {
it('connects with access key and secret', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [getConnectionString(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)],
});
const result = await shell.waitForPromptOrExit(
Expand All @@ -186,7 +187,7 @@ describe('e2e AWS AUTH', function () {

it('connects with access key, secret, and session token for IAM role', async function () {
const tokenDetails = generateIamSessionToken();
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [
`${getConnectionString(
tokenDetails.key,
Expand All @@ -212,7 +213,7 @@ describe('e2e AWS AUTH', function () {
context('with AWS environment variables', function () {
context('without any other parameters', function () {
it('connects for the IAM user', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [getConnectionString()],
env: {
...process.env,
Expand All @@ -233,7 +234,7 @@ describe('e2e AWS AUTH', function () {

it('connects for the IAM role session', async function () {
const tokenDetails = generateIamSessionToken();
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [getConnectionString()],
env: {
...process.env,
Expand All @@ -256,7 +257,7 @@ describe('e2e AWS AUTH', function () {

context('with invalid environment but valid parameters', function () {
it('connects for the IAM user', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [
getConnectionString(),
'--username',
Expand All @@ -283,7 +284,7 @@ describe('e2e AWS AUTH', function () {

it('connects for the IAM role session', async function () {
const tokenDetails = generateIamSessionToken();
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [
getConnectionString(),
'--username',
Expand Down
12 changes: 5 additions & 7 deletions packages/e2e-tests/test/e2e-banners.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
skipIfApiStrict,
startSharedTestServer,
} from '../../testing/src/integration-testing-hooks';
import { skipIfApiStrict, startSharedTestServer } from '@mongosh/testing';
import type { TestShell } from './test-shell';
import { startTestShell } from './test-shell-context';

describe('e2e startup banners', function () {
skipIfApiStrict();
Expand All @@ -11,7 +9,7 @@ describe('e2e startup banners', function () {

context('without special configuration', function () {
it('shows startup warnings', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [await testServer.connectionString()],
});
await shell.waitForPrompt();
Expand All @@ -29,7 +27,7 @@ describe('e2e startup banners', function () {
let helperShell: TestShell;

beforeEach(async function () {
helperShell = this.startTestShell({
helperShell = startTestShell(this, {
args: [await testServer.connectionString()],
});
await helperShell.waitForPrompt();
Expand All @@ -46,7 +44,7 @@ describe('e2e startup banners', function () {
});

it('shows automation notices', async function () {
const shell = this.startTestShell({
const shell = startTestShell(this, {
args: [await testServer.connectionString()],
});
await shell.waitForPrompt();
Expand Down
19 changes: 10 additions & 9 deletions packages/e2e-tests/test/e2e-bson.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { Db } from 'mongodb';
import { MongoClient } from 'mongodb';
import * as bson from 'bson';
import type { TestShell } from './test-shell';
import { startSharedTestServer } from '../../testing/src/integration-testing-hooks';
import { startSharedTestServer } from '@mongosh/testing';
import { startTestShell } from './test-shell-context';

describe('BSON e2e', function () {
const testServer = startSharedTestServer();
Expand All @@ -15,7 +16,7 @@ describe('BSON e2e', function () {
beforeEach(async function () {
const connectionString = await testServer.connectionString();
dbName = `test-${Date.now()}`;
shell = this.startTestShell({ args: [connectionString] });
shell = startTestShell(this, { args: [connectionString] });

client = await MongoClient.connect(connectionString, {});

Expand Down Expand Up @@ -674,7 +675,7 @@ describe('BSON e2e', function () {

it('can explicitly disable full-depth nesting (interactive mode)', async function () {
shell.kill();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [await testServer.connectionString(), '--deepInspect=false'],
});
await shell.waitForPrompt();
Expand All @@ -686,15 +687,15 @@ describe('BSON e2e', function () {

it('does not deeply inspect objects in non-interactive mode for intermediate output', async function () {
shell.kill();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
await testServer.connectionString(),
'--eval',
`use(${JSON.stringify(dbName)}); print(db.coll.findOne()); 0`,
],
});
checkForDeepOutput(await shell.waitForCleanOutput(), false);
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
await testServer.connectionString(),
'--eval',
Expand All @@ -706,15 +707,15 @@ describe('BSON e2e', function () {

it('inspect full objects in non-interactive mode for final output', async function () {
shell.kill();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
await testServer.connectionString(),
'--eval',
`use(${JSON.stringify(dbName)}); db.coll.findOne();`,
],
});
checkForDeepOutput(await shell.waitForCleanOutput(), true);
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
await testServer.connectionString(),
'--eval',
Expand All @@ -726,7 +727,7 @@ describe('BSON e2e', function () {

it('can explicitly disable full-depth nesting (non-interactive mode)', async function () {
shell.kill();
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
await testServer.connectionString(),
'--deepInspect=false',
Expand All @@ -735,7 +736,7 @@ describe('BSON e2e', function () {
],
});
checkForDeepOutput(await shell.waitForCleanOutput(), false);
shell = this.startTestShell({
shell = startTestShell(this, {
args: [
await testServer.connectionString(),
'--deepInspect=false',
Expand Down
Loading
Loading