Skip to content

Commit 49bfdd3

Browse files
ci(NODE-3891): unskip failing tests with authentication is enabled (#4572)
Co-authored-by: Durran Jordan <[email protected]>
1 parent 7cbb641 commit 49bfdd3

File tree

11 files changed

+45
-156
lines changed

11 files changed

+45
-156
lines changed

.evergreen/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,7 @@ tasks:
17881788
- {key: VERSION, value: latest}
17891789
- {key: SSL, value: ssl}
17901790
- {key: TOPOLOGY, value: server}
1791+
- {key: AUTH, value: auth}
17911792
- func: install dependencies
17921793
- func: bootstrap mongo-orchestration
17931794
- func: run tls tests
@@ -1802,6 +1803,7 @@ tasks:
18021803
- {key: VERSION, value: '8.0'}
18031804
- {key: SSL, value: ssl}
18041805
- {key: TOPOLOGY, value: server}
1806+
- {key: AUTH, value: auth}
18051807
- func: install dependencies
18061808
- func: bootstrap mongo-orchestration
18071809
- func: run tls tests
@@ -1816,6 +1818,7 @@ tasks:
18161818
- {key: VERSION, value: '7.0'}
18171819
- {key: SSL, value: ssl}
18181820
- {key: TOPOLOGY, value: server}
1821+
- {key: AUTH, value: auth}
18191822
- func: install dependencies
18201823
- func: bootstrap mongo-orchestration
18211824
- func: run tls tests
@@ -1830,6 +1833,7 @@ tasks:
18301833
- {key: VERSION, value: '6.0'}
18311834
- {key: SSL, value: ssl}
18321835
- {key: TOPOLOGY, value: server}
1836+
- {key: AUTH, value: auth}
18331837
- func: install dependencies
18341838
- func: bootstrap mongo-orchestration
18351839
- func: run tls tests
@@ -1844,6 +1848,7 @@ tasks:
18441848
- {key: VERSION, value: '5.0'}
18451849
- {key: SSL, value: ssl}
18461850
- {key: TOPOLOGY, value: server}
1851+
- {key: AUTH, value: auth}
18471852
- func: install dependencies
18481853
- func: bootstrap mongo-orchestration
18491854
- func: run tls tests
@@ -1858,6 +1863,7 @@ tasks:
18581863
- {key: VERSION, value: '4.4'}
18591864
- {key: SSL, value: ssl}
18601865
- {key: TOPOLOGY, value: server}
1866+
- {key: AUTH, value: auth}
18611867
- func: install dependencies
18621868
- func: bootstrap mongo-orchestration
18631869
- func: run tls tests
@@ -1872,6 +1878,7 @@ tasks:
18721878
- {key: VERSION, value: '4.2'}
18731879
- {key: SSL, value: ssl}
18741880
- {key: TOPOLOGY, value: server}
1881+
- {key: AUTH, value: auth}
18751882
- func: install dependencies
18761883
- func: bootstrap mongo-orchestration
18771884
- func: run tls tests

.evergreen/generate_evergreen_tasks.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,8 @@ for (const VERSION of TLS_VERSIONS) {
317317
updateExpansions({
318318
VERSION,
319319
SSL: 'ssl',
320-
TOPOLOGY: 'server'
321-
// TODO: NODE-3891 - fix tests broken when AUTH enabled
322-
// AUTH: 'auth'
320+
TOPOLOGY: 'server',
321+
AUTH: 'auth'
323322
}),
324323
{ func: 'install dependencies' },
325324
{ func: 'bootstrap mongo-orchestration' },

test/integration/causal-consistency/causal_consistency.prose.test.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const { LEGACY_HELLO_COMMAND } = require('../../mongodb');
44

55
const { setupDatabase } = require('../shared');
66
const { expect } = require('chai');
7-
const { skipBrokenAuthTestBeforeEachHook } = require('../../tools/runner/hooks/configuration');
87

98
const ignoredCommands = [LEGACY_HELLO_COMMAND, 'endSessions'];
109
const test = { commands: { started: [], succeeded: [] } };
@@ -15,21 +14,12 @@ describe('Causal Consistency - prose tests', function () {
1514
return setupDatabase(this.configuration);
1615
});
1716

18-
beforeEach(
19-
skipBrokenAuthTestBeforeEachHook({
20-
skippedTests: [
21-
'2. The first read in a causally consistent session must not send afterClusterTime to the server',
22-
'case: successful read with causal consistency',
23-
'case: second operation is findOne',
24-
'case: successful insert',
25-
'6. A read operation in a ClientSession that is not causally consistent should not include the afterClusterTime parameter in the command sent to the server'
26-
]
27-
})
28-
);
29-
3017
beforeEach(function () {
3118
test.commands = { started: [], succeeded: [] };
32-
test.client = this.configuration.newClient({ w: 1 }, { maxPoolSize: 1, monitorCommands: true });
19+
test.client = this.configuration.newClient(
20+
{ w: 1 },
21+
{ maxPoolSize: 1, monitorCommands: true, __skipPingOnConnect: true }
22+
);
3323
test.client.on('commandStarted', event => {
3424
if (ignoredCommands.indexOf(event.commandName) === -1) test.commands.started.push(event);
3525
});

test/integration/client-side-encryption/client_side_encryption.spec.test.ts

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,6 @@ import {
88
} from '../../tools/spec-runner';
99
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
1010

11-
const isAuthEnabled = process.env.AUTH === 'auth';
12-
13-
// 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
14-
const skippedAuthTests = [
15-
'Insert a document with auto encryption using the AWS provider with temporary credentials',
16-
'Insert a document with auto encryption using Azure KMS provider',
17-
'$rename works if target value has same encryption options',
18-
'Bulk write with encryption',
19-
'Insert with bypassAutoEncryption',
20-
'Insert with bypassAutoEncryption for local schema',
21-
'ping is bypassed',
22-
'deleteOne with deterministic encryption',
23-
'deleteMany with deterministic encryption',
24-
'distinct with deterministic encryption',
25-
'Find with deterministic encryption',
26-
'Find with $in with deterministic encryption',
27-
'findOneAndReplace with deterministic encryption',
28-
'findOneAndUpdate with deterministic encryption',
29-
'Insert a document with auto encryption using GCP KMS provider',
30-
'getMore with encryption',
31-
'unset works with an encrypted field',
32-
'updateOne with deterministic encryption',
33-
'updateMany with deterministic encryption',
34-
'replaceOne with encryption',
35-
'Insert with encryption on a missing key',
36-
'A local schema should override',
37-
'Count with deterministic encryption',
38-
'Insert a document with auto encryption using local KMS provider',
39-
'Insert with encryption using key alt name',
40-
'insertMany with encryption',
41-
'insertOne with encryption',
42-
'findOneAndDelete with deterministic encryption',
43-
'$unset works with an encrypted field',
44-
'Insert a document with auto encryption using KMIP KMS provider'
45-
];
46-
47-
// TODO(NODE-6048): Int32 and Long not allowed as batchSize option to cursor.
48-
const skippedNoAuthTests = ['getMore with encryption'];
49-
50-
const SKIPPED_TESTS = new Set([
51-
...(isAuthEnabled ? skippedAuthTests.concat(skippedNoAuthTests) : skippedNoAuthTests),
52-
...[
53-
// the node driver does not have a mapReduce helper
54-
'mapReduce deterministic encryption (unsupported)'
55-
]
56-
]);
57-
5811
describe('Client Side Encryption (Legacy)', function () {
5912
const testContext = new TestRunnerContext({ requiresCSFLE: true });
6013
const testSuites = gatherTestSuites(
@@ -70,8 +23,11 @@ describe('Client Side Encryption (Legacy)', function () {
7023

7124
generateTopologyTests(testSuites, testContext, (test, configuration) => {
7225
const { description } = test;
73-
if (SKIPPED_TESTS.has(description)) {
74-
return 'Skipped by generic test name skip filter.';
26+
if (description === 'getMore with encryption') {
27+
return `TODO(NODE-6048): Int32 and Long not allowed as batchSize option to cursor`;
28+
}
29+
if (description === 'mapReduce deterministic encryption (unsupported)') {
30+
return `the Node driver does not have a mapReduce helper.`;
7531
}
7632
if (
7733
[

test/integration/connection-monitoring-and-pooling/connection.test.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {
1414
makeClientMetadata,
1515
MongoClient,
1616
MongoClientAuthProviders,
17+
type MongoClientOptions,
1718
MongoDBResponse,
1819
MongoServerError,
1920
ns,
2021
ServerHeartbeatStartedEvent,
2122
Topology
2223
} from '../../mongodb';
2324
import * as mock from '../../tools/mongodb-mock/index';
24-
import { skipBrokenAuthTestBeforeEachHook } from '../../tools/runner/hooks/configuration';
2525
import { processTick, sleep } from '../../tools/utils';
2626
import { assert as test, setupDatabase } from '../shared';
2727

@@ -37,15 +37,6 @@ const commonConnectOptions = {
3737
};
3838

3939
describe('Connection', function () {
40-
beforeEach(
41-
skipBrokenAuthTestBeforeEachHook({
42-
skippedTests: [
43-
'should support calling back multiple times on exhaust commands',
44-
'should correctly connect to server using domain socket'
45-
]
46-
})
47-
);
48-
4940
before(function () {
5041
return setupDatabase(this.configuration);
5142
});
@@ -182,13 +173,16 @@ describe('Connection', function () {
182173
metadata: {
183174
requires: { topology: 'single', os: '!win32' }
184175
},
185-
186176
test: function (done) {
187177
const configuration = this.configuration;
188-
client = configuration.newClient(
189-
`mongodb://${encodeURIComponent('/tmp/mongodb-27017.sock')}?w=1`,
190-
{ maxPoolSize: 1 }
191-
);
178+
const uri = `mongodb://${encodeURIComponent('/tmp/mongodb-27017.sock')}?w=1`;
179+
const options: MongoClientOptions = {
180+
maxPoolSize: 1
181+
};
182+
if (this.configuration.options.auth) {
183+
options.auth = this.configuration.options.auth;
184+
}
185+
client = configuration.newClient(uri, options);
192186

193187
const db = client.db(configuration.db);
194188

test/integration/enumerate_databases.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ import { TestBuilder, UnifiedTestSuiteBuilder } from '../tools/utils';
66

77
const metadata: MongoDBMetadataUI = {
88
requires: {
9-
auth: 'enabled',
10-
11-
// 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
12-
// These tests should work on a load balanced topology
13-
topology: '!load-balanced'
9+
auth: 'enabled'
1410
}
1511
};
1612

test/integration/load-balancers/load_balancers.spec.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,9 @@ const filter = ({ description }) => {
2626

2727
if (
2828
process.env.AUTH === 'auth' &&
29-
[
30-
'errors during authentication are processed',
31-
'wait queue timeout errors include cursor statistics',
32-
'wait queue timeout errors include transaction statistics',
33-
'operations against non-load balanced clusters fail if URI contains loadBalanced=true',
34-
'operations against non-load balanced clusters succeed if URI contains loadBalanced=false'
35-
].includes(description)
29+
['errors during authentication are processed'].includes(description)
3630
) {
37-
return 'TODO(NODE-3891): fix tests broken when AUTH enabled';
31+
return 'TODO(NODE-7014): clear pool after handshake error in lb mode';
3832
}
3933

4034
return false;

test/integration/node-specific/operation_examples.test.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { expect } from 'chai';
2-
import { format as f } from 'util';
32

43
import {
54
Code,
@@ -8,7 +7,6 @@ import {
87
ProfilingLevel,
98
ReturnDocument
109
} from '../../mongodb';
11-
import { skipBrokenAuthTestBeforeEachHook } from '../../tools/runner/hooks/configuration';
1210
import { sleep as delay } from '../../tools/utils';
1311
import { setupDatabase } from '../shared';
1412

@@ -27,16 +25,6 @@ describe('Operations', function () {
2725
return setupDatabase(this.configuration, ['integration_tests_2', 'hr', 'reporting']);
2826
});
2927

30-
beforeEach(
31-
skipBrokenAuthTestBeforeEachHook({
32-
skippedTests: [
33-
'Should correctly connect to a replicaset',
34-
'Should connect to mongos proxies using connectiong string With Promises',
35-
'Should correctly connect to a replicaset With Promises'
36-
]
37-
})
38-
);
39-
4028
/**************************************************************************
4129
*
4230
* COLLECTION TESTS
@@ -3244,14 +3232,7 @@ describe('Operations', function () {
32443232

32453233
test: function () {
32463234
const configuration = this.configuration;
3247-
const url = f(
3248-
'mongodb://%s,%s/%s?replicaSet=%s&readPreference=%s',
3249-
f('%s:%s', configuration.host, configuration.port),
3250-
f('%s:%s', configuration.host, configuration.port + 1),
3251-
'integration_test_',
3252-
configuration.replicasetName,
3253-
'primary'
3254-
);
3235+
const url = configuration.url();
32553236

32563237
const client = configuration.newClient(url);
32573238
return client.connect().then(function (client) {
@@ -3291,13 +3272,7 @@ describe('Operations', function () {
32913272

32923273
test: function () {
32933274
const configuration = this.configuration;
3294-
const url = f(
3295-
'mongodb://%s:%s,%s:%s/sharded_test_db?w=1',
3296-
configuration.host,
3297-
configuration.port,
3298-
configuration.host,
3299-
configuration.port + 1
3300-
);
3275+
const url = configuration.url();
33013276

33023277
const client = configuration.newClient(url);
33033278
return client.connect().then(function (client) {

test/integration/unified-test-format/unified_test_format.spec.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ const filter: TestFilter = ({ description }) => {
2727
return 'TODO(NODE-5962): fix migration conflict in transaction tests';
2828
}
2929

30-
if (
31-
process.env.AUTH === 'auth' &&
32-
[
33-
'FindOneAndUpdate is committed on first attempt',
34-
'FindOneAndUpdate is not committed on first attempt',
35-
'FindOneAndUpdate is never committed'
36-
].includes(description)
37-
) {
38-
return 'TODO(NODE-3891): fix tests broken when AUTH enabled';
39-
}
40-
4130
return false;
4231
};
4332

test/manual/tls_support.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as tls from 'node:tls';
33

44
import { expect } from 'chai';
55
import { promises as fs } from 'fs';
6+
import ConnectionString from 'mongodb-connection-string-url';
67
import * as sinon from 'sinon';
78

89
import {
@@ -33,7 +34,7 @@ describe('TLS Support', function () {
3334

3435
it(
3536
'should connect with tls via client options',
36-
makeConnectionTest(CONNECTION_STRING, tlsSettings)
37+
makeConnectionTest(CONNECTION_STRING, {}, tlsSettings)
3738
);
3839

3940
beforeEach(function () {
@@ -48,11 +49,7 @@ describe('TLS Support', function () {
4849

4950
it(
5051
'should connect with tls via url options',
51-
makeConnectionTest(
52-
`${CONNECTION_STRING}?${Object.keys(tlsSettings)
53-
.map(key => `${key}=${tlsSettings[key]}`)
54-
.join('&')}`
55-
)
52+
makeConnectionTest(CONNECTION_STRING, tlsSettings, {})
5653
);
5754

5855
context('when tls filepaths are provided', () => {
@@ -283,9 +280,17 @@ describe('TLS Support', function () {
283280
});
284281
});
285282

286-
function makeConnectionTest(connectionString: string, clientOptions?: MongoClientOptions) {
283+
function makeConnectionTest(
284+
connectionString: string,
285+
uriOptions: Record<string, any>,
286+
clientOptions?: MongoClientOptions
287+
) {
288+
const uri = new ConnectionString(connectionString);
289+
for (const [k, v] of Object.entries(uriOptions)) {
290+
uri.searchParams.set(k, v);
291+
}
287292
return async function () {
288-
const client = new MongoClient(connectionString, clientOptions);
293+
const client = new MongoClient(uri.toString(), clientOptions);
289294

290295
await client.connect();
291296
await client.db('admin').command({ [LEGACY_HELLO_COMMAND]: 1 });

0 commit comments

Comments
 (0)