Skip to content

Commit a7a3b99

Browse files
ci(NODE-3860): Enable auth on in CI (#3121)
1 parent 6218443 commit a7a3b99

34 files changed

+857
-228
lines changed

.evergreen/config.yml

Lines changed: 307 additions & 0 deletions
Large diffs are not rendered by default.

.evergreen/generate_evergreen_tasks.js

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const OPERATING_SYSTEMS = [
3636
].map(osConfig => ({
3737
mongoVersion: '>=3.6',
3838
nodeVersion: LOWEST_LTS,
39-
auth: false, // TODO test auth?
39+
auth: 'auth',
4040
clientEncryption: true,
4141
...osConfig
4242
}));
@@ -48,28 +48,40 @@ const MACOS_SKIP_TAGS = new Set(['load_balancer']);
4848
const TASKS = [];
4949
const SINGLETON_TASKS = [];
5050

51-
function makeTask({ mongoVersion, topology, tags = [] }) {
51+
function makeTask({ mongoVersion, topology, tags = [], auth = 'auth' }) {
5252
return {
53-
name: `test-${mongoVersion}-${topology}`,
53+
name: `test-${mongoVersion}-${topology}${auth === 'noauth' ? '-noauth' : ''}`,
5454
tags: [mongoVersion, topology, ...tags],
5555
commands: [
5656
{ func: 'install dependencies' },
5757
{
5858
func: 'bootstrap mongo-orchestration',
5959
vars: {
6060
VERSION: mongoVersion,
61-
TOPOLOGY: topology
61+
TOPOLOGY: topology,
62+
AUTH: auth
6263
}
6364
},
6465
{ func: 'run tests' }
6566
]
6667
};
6768
}
6869

69-
const BASE_TASKS = [];
70-
MONGODB_VERSIONS.forEach(mongoVersion => {
71-
TOPOLOGIES.forEach(topology => BASE_TASKS.push(makeTask({ mongoVersion, topology })));
72-
});
70+
function generateVersionTopologyMatrix() {
71+
function* _generate() {
72+
for (const mongoVersion of MONGODB_VERSIONS) {
73+
for (const topology of TOPOLOGIES) {
74+
yield { mongoVersion, topology}
75+
}
76+
}
77+
}
78+
79+
return Array.from(_generate());
80+
}
81+
82+
const BASE_TASKS = generateVersionTopologyMatrix().map(makeTask)
83+
const AUTH_DISABLED_TASKS = generateVersionTopologyMatrix().map((test) => makeTask({ ...test, auth: 'noauth', tags: ['noauth'] }))
84+
7385
BASE_TASKS.push({
7486
name: `test-latest-server-v1-api`,
7587
tags: ['latest', 'server', 'v1-api'],
@@ -80,7 +92,8 @@ BASE_TASKS.push({
8092
vars: {
8193
VERSION: 'latest',
8294
TOPOLOGY: 'server',
83-
REQUIRE_API_VERSION: '1'
95+
REQUIRE_API_VERSION: '1',
96+
AUTH: 'auth'
8497
}
8598
},
8699
{
@@ -119,6 +132,7 @@ TASKS.push(
119132
vars: {
120133
VERSION: 'latest',
121134
TOPOLOGY: 'sharded_cluster',
135+
AUTH: 'auth',
122136
LOAD_BALANCER: 'true'
123137
}
124138
},
@@ -179,7 +193,8 @@ TASKS.push(
179193
vars: {
180194
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple.json',
181195
VERSION: 'latest',
182-
TOPOLOGY: 'server'
196+
TOPOLOGY: 'server',
197+
AUTH: 'auth'
183198
}
184199
},
185200
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 1 } }
@@ -196,7 +211,8 @@ TASKS.push(
196211
vars: {
197212
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple.json',
198213
VERSION: 'latest',
199-
TOPOLOGY: 'server'
214+
TOPOLOGY: 'server',
215+
AUTH: 'auth'
200216
}
201217
},
202218
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -213,7 +229,8 @@ TASKS.push(
213229
vars: {
214230
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-disableStapling.json',
215231
VERSION: 'latest',
216-
TOPOLOGY: 'server'
232+
TOPOLOGY: 'server',
233+
AUTH: 'auth'
217234
}
218235
},
219236
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 1 } }
@@ -230,7 +247,8 @@ TASKS.push(
230247
vars: {
231248
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-disableStapling.json',
232249
VERSION: 'latest',
233-
TOPOLOGY: 'server'
250+
TOPOLOGY: 'server',
251+
AUTH: 'auth'
234252
}
235253
},
236254
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -246,7 +264,8 @@ TASKS.push(
246264
vars: {
247265
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-disableStapling.json',
248266
VERSION: 'latest',
249-
TOPOLOGY: 'server'
267+
TOPOLOGY: 'server',
268+
AUTH: 'auth'
250269
}
251270
},
252271
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 1 } }
@@ -263,7 +282,8 @@ TASKS.push(
263282
vars: {
264283
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple-disableStapling.json',
265284
VERSION: 'latest',
266-
TOPOLOGY: 'server'
285+
TOPOLOGY: 'server',
286+
AUTH: 'auth'
267287
}
268288
},
269289
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -279,7 +299,8 @@ TASKS.push(
279299
vars: {
280300
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple-disableStapling.json',
281301
VERSION: 'latest',
282-
TOPOLOGY: 'server'
302+
TOPOLOGY: 'server',
303+
AUTH: 'auth'
283304
}
284305
},
285306
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -299,7 +320,9 @@ TLS_VERSIONS.forEach(VERSION => {
299320
vars: {
300321
VERSION,
301322
SSL: 'ssl',
302-
TOPOLOGY: 'server'
323+
TOPOLOGY: 'server',
324+
// TODO: NODE-3891 - fix tests broken when AUTH enabled
325+
// AUTH: 'auth'
303326
}
304327
},
305328
{ func: 'run tls tests' }
@@ -322,7 +345,8 @@ OCSP_VERSIONS.forEach(VERSION => {
322345
vars: {
323346
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple.json',
324347
VERSION: VERSION,
325-
TOPOLOGY: 'server'
348+
TOPOLOGY: 'server',
349+
AUTH: 'auth'
326350
}
327351
},
328352
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 1 } }
@@ -339,7 +363,8 @@ OCSP_VERSIONS.forEach(VERSION => {
339363
vars: {
340364
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple.json',
341365
VERSION: VERSION,
342-
TOPOLOGY: 'server'
366+
TOPOLOGY: 'server',
367+
AUTH: 'auth'
343368
}
344369
},
345370
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -356,7 +381,8 @@ OCSP_VERSIONS.forEach(VERSION => {
356381
vars: {
357382
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-disableStapling.json',
358383
VERSION: VERSION,
359-
TOPOLOGY: 'server'
384+
TOPOLOGY: 'server',
385+
AUTH: 'auth'
360386
}
361387
},
362388
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 1 } }
@@ -373,7 +399,8 @@ OCSP_VERSIONS.forEach(VERSION => {
373399
vars: {
374400
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-disableStapling.json',
375401
VERSION: VERSION,
376-
TOPOLOGY: 'server'
402+
TOPOLOGY: 'server',
403+
AUTH: 'auth'
377404
}
378405
},
379406
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -389,7 +416,8 @@ OCSP_VERSIONS.forEach(VERSION => {
389416
vars: {
390417
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-disableStapling.json',
391418
VERSION: VERSION,
392-
TOPOLOGY: 'server'
419+
TOPOLOGY: 'server',
420+
AUTH: 'auth'
393421
}
394422
},
395423
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 1 } }
@@ -406,7 +434,8 @@ OCSP_VERSIONS.forEach(VERSION => {
406434
vars: {
407435
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple-disableStapling.json',
408436
VERSION: VERSION,
409-
TOPOLOGY: 'server'
437+
TOPOLOGY: 'server',
438+
AUTH: 'auth'
410439
}
411440
},
412441
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -422,7 +451,8 @@ OCSP_VERSIONS.forEach(VERSION => {
422451
vars: {
423452
ORCHESTRATION_FILE: 'rsa-basic-tls-ocsp-mustStaple-disableStapling.json',
424453
VERSION: VERSION,
425-
TOPOLOGY: 'server'
454+
TOPOLOGY: 'server',
455+
AUTH: 'auth'
426456
}
427457
},
428458
{ func: 'run-ocsp-test', vars: { OCSP_TLS_SHOULD_SUCCEED: 0 } }
@@ -631,7 +661,8 @@ const oneOffFuncAsTasks = oneOffFuncs.map(oneOffFunc => ({
631661
func: 'bootstrap mongo-orchestration',
632662
vars: {
633663
VERSION: '5.0',
634-
TOPOLOGY: 'server'
664+
TOPOLOGY: 'server',
665+
AUTH: 'auth'
635666
}
636667
},
637668
oneOffFunc
@@ -672,8 +703,15 @@ BUILD_VARIANTS.push({
672703
tasks: ['serverless_task_group']
673704
});
674705

706+
BUILD_VARIANTS.push({
707+
name: 'no-auth-tests',
708+
display_name: 'No Auth Tests',
709+
run_on: 'ubuntu1804-test',
710+
tasks: AUTH_DISABLED_TASKS.map(({ name }) => name)
711+
})
712+
675713
const fileData = yaml.load(fs.readFileSync(`${__dirname}/config.yml.in`, 'utf8'));
676-
fileData.tasks = (fileData.tasks || []).concat(BASE_TASKS).concat(TASKS).concat(SINGLETON_TASKS);
714+
fileData.tasks = (fileData.tasks || []).concat(BASE_TASKS).concat(TASKS).concat(SINGLETON_TASKS).concat(AUTH_DISABLED_TASKS);
677715
fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS);
678716

679717
fs.writeFileSync(`${__dirname}/config.yml`, yaml.dump(fileData, { lineWidth: 120 }), 'utf8');

.evergreen/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ else
5050
. $DRIVERS_TOOLS/.evergreen/csfle/set-temp-creds.sh
5151
fi
5252

53-
SINGLE_MONGOS_LB_URI=${SINGLE_MONGOS_LB_URI} MULTI_MONGOS_LB_URI=${MULTI_MONGOS_LB_URI} MONGODB_API_VERSION=${MONGODB_API_VERSION} MONGODB_UNIFIED_TOPOLOGY=${UNIFIED} MONGODB_URI=${MONGODB_URI} LOAD_BALANCER=${LOAD_BALANCER} npm run ${TEST_NPM_SCRIPT}
53+
AUTH=$AUTH SINGLE_MONGOS_LB_URI=${SINGLE_MONGOS_LB_URI} MULTI_MONGOS_LB_URI=${MULTI_MONGOS_LB_URI} MONGODB_API_VERSION=${MONGODB_API_VERSION} MONGODB_UNIFIED_TOPOLOGY=${UNIFIED} MONGODB_URI=${MONGODB_URI} LOAD_BALANCER=${LOAD_BALANCER} npm run ${TEST_NPM_SCRIPT}

global.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { OneOrMore } from './src/mongo_types';
12
import type { TestConfiguration } from './test/tools/runner/config';
23

34
type WithExclusion<T extends string> = `!${T}`
45
/** Defined in test/tools/runner/filters/mongodb_topology_filter.js (topologyTypeToString) */
56
type TopologyTypes = 'single' | 'replicaset' | 'sharded' | 'load-balanced';
6-
type TopologyTypeRequirement = WithExclusion<TopologyTypes> | WithExclusion<TopologyTypes>[]
7+
type TopologyTypeRequirement = OneOrMore<TopologyTypes> | OneOrMore<WithExclusion<TopologyTypes>>
78

9+
declare global {
810
interface MongoDBMetadataUI {
911
requires?: {
1012
topology?: TopologyTypeRequirement;
@@ -13,6 +15,7 @@ interface MongoDBMetadataUI {
1315
apiVersion?: '1';
1416
clientSideEncryption?: boolean;
1517
serverless?: 'forbid' | 'allow' | 'require';
18+
auth: 'enabled' | 'disabled'
1619
};
1720

1821
sessions?: {
@@ -24,8 +27,6 @@ interface MetadataAndTest<Fn> {
2427
metadata: MongoDBMetadataUI;
2528
test: Fn;
2629
}
27-
28-
declare global {
2930
namespace Mocha {
3031
interface TestFunction {
3132
(title: string, metadata: MongoDBMetadataUI, fn: Mocha.Func): Mocha.Test;

test/integration/auth/mongodb_aws.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const { expect } = require('chai');
3+
const { removeAuthFromConnectionString } = require('../../tools/utils');
34

45
describe('MONGODB-AWS', function () {
56
beforeEach(function () {
@@ -12,7 +13,8 @@ describe('MONGODB-AWS', function () {
1213

1314
it('should not authorize when not authenticated', function (done) {
1415
const config = this.configuration;
15-
const client = config.newClient(config.url()); // strip provided URI of credentials
16+
const url = removeAuthFromConnectionString(config.url());
17+
const client = config.newClient(url); // strip provided URI of credentials
1618
client.connect(err => {
1719
expect(err).to.not.exist;
1820
this.defer(() => client.close());

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ describe('Causal Consistency - prose tests', function () {
4242
*/
4343
{
4444
metadata: {
45-
requires: { topology: ['replicaset', 'sharded'] },
45+
requires: { topology: ['replicaset', 'sharded'], auth: 'disabled' },
4646
// Skipping session leak tests b/c these are explicit sessions
47-
sessions: { skipLeakTests: true }
47+
sessions: { skipLeakTests: true },
48+
skipReason: 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
4849
},
4950

5051
test: function () {
@@ -80,9 +81,10 @@ describe('Causal Consistency - prose tests', function () {
8081

8182
it('case: successful read with causal consistency', {
8283
metadata: {
83-
requires: { topology: ['replicaset', 'sharded'] },
84+
requires: { topology: ['replicaset', 'sharded'], auth: 'disabled' },
8485
// Skipping session leak tests b/c these are explicit sessions
85-
sessions: { skipLeakTests: true }
86+
sessions: { skipLeakTests: true },
87+
skipReason: 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
8688
},
8789

8890
test: function () {
@@ -118,9 +120,10 @@ describe('Causal Consistency - prose tests', function () {
118120
() => {
119121
it('case: second operation is findOne', {
120122
metadata: {
121-
requires: { topology: ['replicaset', 'sharded'] },
123+
requires: { topology: ['replicaset', 'sharded'], auth: 'disabled' },
122124
// Skipping session leak tests b/c these are explicit sessions
123-
sessions: { skipLeakTests: true }
125+
sessions: { skipLeakTests: true },
126+
skipReason: 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
124127
},
125128

126129
test: function () {
@@ -163,9 +166,10 @@ describe('Causal Consistency - prose tests', function () {
163166
() => {
164167
it('case: successful insert', {
165168
metadata: {
166-
requires: { topology: ['replicaset', 'sharded'] },
169+
requires: { topology: ['replicaset', 'sharded'], auth: 'disabled' },
167170
// Skipping session leak tests b/c these are explicit sessions
168-
sessions: { skipLeakTests: true }
171+
sessions: { skipLeakTests: true },
172+
skipReason: 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
169173
},
170174

171175
test: function () {
@@ -203,9 +207,10 @@ describe('Causal Consistency - prose tests', function () {
203207
*/
204208
{
205209
metadata: {
206-
requires: { topology: ['replicaset', 'sharded'] },
210+
requires: { topology: ['replicaset', 'sharded'], auth: 'disabled' },
207211
// Skipping session leak tests b/c these are explicit sessions
208-
sessions: { skipLeakTests: true }
212+
sessions: { skipLeakTests: true },
213+
skipReason: 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
209214
},
210215

211216
test: function () {

test/integration/change-streams/change_stream.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,10 @@ describe('Change Streams', function () {
13331333
});
13341334

13351335
it('when invoked using eventEmitter API', {
1336-
metadata: { requires: { topology: 'replicaset', mongodb: '>=3.6' } },
1336+
metadata: {
1337+
requires: { topology: 'replicaset', mongodb: '>=3.6', auth: 'disabled' },
1338+
skipReason: 'TODO: NODE-3891 - fix tests broken when AUTH enabled'
1339+
},
13371340
test: function (done) {
13381341
let closed = false;
13391342
const close = _err => {

test/integration/client-side-encryption/client_side_encryption.prose.deadlock.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ function deadlockTest(options, assertions) {
8686
};
8787
}
8888

89-
function deadlockTests(metadata) {
89+
function deadlockTests(_metadata) {
90+
const metadata = { ..._metadata, requires: { ..._metadata.requires, auth: 'disabled' } };
91+
metadata.skipReason = 'TODO: NODE-3891 - fix tests broken when AUTH enabled';
9092
describe('Connection Pool Deadlock Prevention', function () {
9193
beforeEach(function () {
9294
try {

0 commit comments

Comments
 (0)