Skip to content

Commit 209a91d

Browse files
nbbeekendurran
andauthored
test(NODE-5295): assert bypass mongocryptd connection fails with ECONNREFUSED (#3673)
Co-authored-by: Durran Jordan <durran@gmail.com>
1 parent be8faaf commit 209a91d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,12 @@ describe('Client Side Encryption Prose Tests', metadata, function () {
11781178
.to.be.instanceOf(Error)
11791179
.to.have.property('name', 'MongoServerSelectionError');
11801180

1181-
expect(insertError).to.match(/connect ECONNREFUSED 127.0.0.1:27021/);
1181+
// TODO(NODE-5296): check error.message once AggregateErrors are handled correctly
1182+
expect(insertError, 'Error must contain ECONNREFUSED').to.satisfy(
1183+
error =>
1184+
/ECONNREFUSED/.test(error.message) ||
1185+
!!error.cause?.cause?.errors?.every(e => e.code === 'ECONNREFUSED')
1186+
);
11821187

11831188
expect(insertError).not.to.be.instanceOf(
11841189
MongoServerSelectionError,
@@ -1270,9 +1275,17 @@ TODO(NODE-5283): The error thrown in this test fails an instanceof check with Mo
12701275
client = new MongoClient('mongodb://localhost:27021/db?serverSelectionTimeoutMS=1000');
12711276
const error = await client.connect().catch(e => e);
12721277

1273-
expect(error)
1278+
// TODO(NODE-5296): check error.message once AggregateErrors are handled correctly
1279+
expect(
1280+
error,
1281+
'Error MUST be a MongoServerSelectionError error that contains ECONNREFUSED information'
1282+
)
12741283
.to.be.instanceOf(MongoServerSelectionError)
1275-
.to.match(/connect ECONNREFUSED 127.0.0.1:27021/);
1284+
.that.satisfies(
1285+
error =>
1286+
/ECONNREFUSED/.test(error.message) ||
1287+
!!error.cause?.cause?.errors?.every(e => e.code === 'ECONNREFUSED')
1288+
);
12761289
});
12771290
});
12781291

0 commit comments

Comments
 (0)