Skip to content

Commit

Permalink
chore: fix auth in unified failpoint logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Jul 18, 2024
1 parent 8b8fb4f commit 197bf7a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/tools/unified-spec-runner/entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { expect } from 'chai';
import { EventEmitter } from 'events';

Expand Down Expand Up @@ -362,7 +361,15 @@ export class FailPointMap extends Map<string, Document> {
let address: string;
if (addressOrClient instanceof MongoClient) {
client = addressOrClient;
address = client.topology!.s.seedlist.join(',');
address = client.topology?.s.seedlist.join(',');
if (client.topology?.s.credentials) {
if (
client.topology.s.credentials.mechanism === 'DEFAULT' ||
client.topology.s.credentials.mechanism.startsWith('SCRAM')
) {
address = `${client.topology.s.credentials.username}:${client.topology.s.credentials.password}@${address}`;
}
}
} else {
// create a new client
address = addressOrClient.toString();
Expand Down Expand Up @@ -516,7 +523,7 @@ export class EntitiesMap<E = Entity> extends Map<string, E> {
const entity = this.get(key);
if (!entity) {
if (assertExists) throw new Error(`Entity '${key}' does not exist`);
return;
return undefined;
}
if (NO_INSTANCE_CHECK.includes(type)) {
// Skip constructor checks for interfaces.
Expand Down

0 comments on commit 197bf7a

Please sign in to comment.