MCPcopy
hub / github.com/mongodb/node-mongodb-native / createUsers

Function createUsers

test/integration/auth/auth.prose.test.ts:350–372  ·  view source on GitHub ↗
(configuration: TestConfiguration)

Source from the content-addressed store, hash-verified

348 }
349
350 async function createUsers(configuration: TestConfiguration) {
351 const utilClient = configuration.newClient();
352 const db = utilClient.db('admin');
353
354 const createUserCommands = users.map(user => ({
355 createUser: user.username,
356 pwd: user.password,
357 roles: ['root'],
358 mechanisms: user.mechanisms
359 }));
360
361 const failures = await Promise.allSettled(
362 createUserCommands.map(cmd => db.command(cmd))
363 ).then(resolutions => resolutions.filter(resolution => resolution.status === 'rejected'));
364
365 await utilClient.close();
366
367 if (failures.length) {
368 throw new Error(
369 'Error(s) creating users: ' + failures.map(failure => failure.reason).join(' | ')
370 );
371 }
372 }
373
374 before(async function () {
375 await cleanUpUsers(this.configuration);

Callers 1

auth.prose.test.tsFile · 0.85

Calls 6

newClientMethod · 0.45
dbMethod · 0.45
mapMethod · 0.45
commandMethod · 0.45
filterMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected