Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
189 changes: 89 additions & 100 deletions packages/compass-e2e-tests/tests/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ describe('Connection string', function () {
});

it('can connect to an Atlas replicaset without srv', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't skip those, most of our web tests will use the user-pass based auth, let's rather exclude sasl prep only for published bundle, and not for one that will be compiled for tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Updated the webpack to only run on production with the comment.

// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -340,19 +341,18 @@ describe('Connection string', function () {

const connectionString = await resolveMongodbSrv(withSRV);
await browser.connectWithConnectionString(connectionString);
if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionNameFromString(connectionString),
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionNameFromString(connectionString),
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
});

it('can connect to an Atlas cluster with a direct connection', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -371,19 +371,18 @@ describe('Connection string', function () {
const connectionString = parsedString.toString();
await browser.connectWithConnectionString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionNameFromString(connectionString),
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionNameFromString(connectionString),
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
});

it('can connect to Atlas Serverless', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -395,19 +394,18 @@ describe('Connection string', function () {

await browser.connectWithConnectionString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
});

it('can connect to Atlas Datalake', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -419,19 +417,18 @@ describe('Connection string', function () {

await browser.connectWithConnectionString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
});

it('can connect to Atlas Analytics Node', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -443,19 +440,18 @@ describe('Connection string', function () {

await browser.connectWithConnectionString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
});

it('can connect to Atlas Free Tier', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -466,19 +462,18 @@ describe('Connection string', function () {
const connectionName = connectionNameFromString(connectionString);

await browser.connectWithConnectionString(connectionString);
if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
});

it('can connect with readWriteAnyDatabase builtin role', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -488,15 +483,13 @@ describe('Connection string', function () {

await browser.connectWithConnectionString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);

await assertCanReadData(
browser,
Expand All @@ -507,7 +500,8 @@ describe('Connection string', function () {
});

it('can connect with readAnyDatabase builtin role', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -518,15 +512,13 @@ describe('Connection string', function () {

const connectionName = connectionNameFromString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);

await assertCanReadData(
browser,
Expand Down Expand Up @@ -555,7 +547,8 @@ describe('Connection string', function () {
});

it('can connect with custom role', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
// Skip this on web because it doesn't support saslprep.
return this.skip();
}

Expand All @@ -566,15 +559,13 @@ describe('Connection string', function () {

const connectionName = connectionNameFromString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);

await assertCanReadData(browser, connectionName, 'test', 'users');
await assertCannotCreateDb(
Expand All @@ -592,7 +583,7 @@ describe('Connection string', function () {
});

it('can connect with read one collection specific permission', async function () {
if (!hasAtlasEnvironmentVariables()) {
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
return this.skip();
}

Expand All @@ -603,15 +594,13 @@ describe('Connection string', function () {

const connectionName = connectionNameFromString(connectionString);

if (!TEST_COMPASS_WEB) {
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);
}
const result = await browser.shellEval(
connectionName,
'db.runCommand({ connectionStatus: 1 })',
true
);
assertNotError(result);
expect(result).to.have.property('ok', 1);

await assertCanReadData(browser, connectionName, 'test', 'users');
await assertCannotInsertData(browser, connectionName, 'test', 'users');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function saslprep(): void {
throw new Error('saslprep is not supported in this environment');
}
7 changes: 6 additions & 1 deletion packages/compass-web/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ module.exports = (env, args) => {
'@mongodb-js/devtools-proxy-support'
),

// We don't need saslprep in the web, as we don't use scram auth.
// We use a local polyfill for the driver to avoid having it in the bundle
// as it is a decent size.
'@mongodb-js/saslprep': localPolyfill('@mongodb-js/saslprep'),

// Replace 'devtools-connect' with a package that just directly connects
// using the driver (= web-compatible driver) logic, because devtools-connect
// contains a lot of logic that makes sense in a desktop application/CLI but
Expand Down Expand Up @@ -218,7 +223,7 @@ module.exports = (env, args) => {
'react-dom': 'commonjs2 react-dom',

// TODO(CLOUDP-228421): move Socket implementation from mms codebase when
// active work on the connumicatino protocol is wrapped up
// active work on the communication protocol is wrapped up
tls: 'commonjs2 tls',
},
plugins: [
Expand Down