From aa1f15fdcfc016fb1ddca8d8a712a9793e08a5f6 Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Fri, 4 Apr 2025 13:18:14 +0200 Subject: [PATCH] fix: flaky x509 test --- .evergreen/config.yml | 2 +- .evergreen/generate_evergreen_tasks.js | 2 +- test/manual/x509_auth.test.ts | 35 +++++++++++--------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index f74052f2a7..696255c27b 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -1345,7 +1345,7 @@ tasks: params: updates: - {key: VERSION, value: latest} - - {key: TOPOLOGY, value: sharded_cluster} + - {key: TOPOLOGY, value: server} - {key: AUTH, value: noauth} - {key: SSL, value: ssl} - func: install dependencies diff --git a/.evergreen/generate_evergreen_tasks.js b/.evergreen/generate_evergreen_tasks.js index 87ac59b908..1ed457d0b2 100644 --- a/.evergreen/generate_evergreen_tasks.js +++ b/.evergreen/generate_evergreen_tasks.js @@ -120,7 +120,7 @@ BASE_TASKS.push({ commands: [ updateExpansions({ VERSION: 'latest', - TOPOLOGY: 'sharded_cluster', + TOPOLOGY: 'server', AUTH: 'noauth', SSL: 'ssl' }), diff --git a/test/manual/x509_auth.test.ts b/test/manual/x509_auth.test.ts index 04fa5405ec..d0e5f1be86 100644 --- a/test/manual/x509_auth.test.ts +++ b/test/manual/x509_auth.test.ts @@ -54,22 +54,6 @@ describe('x509 Authentication', function () { }); }); - context( - 'when a valid cert is provided but the certificate does not correspond to a user', - function () { - it.skip('fails to authenticate', async function () { - client = new MongoClient(connectionString.toString(), validOptions); - const error = await client.connect().then( - () => null, - e => e - ); - - expect(error).to.be.instanceOf(MongoServerError); - expect(error.codeName).to.match(/UserNotFound/i); - }).skipReason = 'TODO(NODE-6834): fix flaky test'; - } - ); - context('when the client connects with an invalid certificate', function () { // unlike other authentication mechanisms, x509 authentication 1) requires TLS and // 2) the server uses the client certificate to derive a username to authenticate with @@ -93,6 +77,19 @@ describe('x509 Authentication', function () { expect(error).to.be.instanceOf(MongoServerSelectionError); }); }); + + context( + 'when a valid cert is provided but the certificate does not correspond to a user', + function () { + it('fails to authenticate', async function () { + client = new MongoClient(connectionString.toString(), validOptions); + const error = await client.connect().catch(error => error); + + expect(error).to.be.instanceOf(MongoServerError); + expect(error.codeName).to.match(/UserNotFound/i); + }); + } + ); }); async function createX509User() { @@ -110,8 +107,7 @@ async function createX509User() { roles: [ { role: 'readWrite', db: 'test' }, { role: 'userAdminAnyDatabase', db: 'admin' } - ], - writeConcern: { w: 'majority', wtimeout: 5000 } + ] }); } finally { await utilClient.close(); @@ -128,8 +124,7 @@ async function dropX509User() { try { await utilClient.connect(); await utilClient.db('$external').command({ - dropUser: process.env.SUBJECT, - writeConcern: { w: 'majority', wtimeout: 5000 } + dropUser: process.env.SUBJECT }); } finally { await utilClient.close();