Skip to content

Commit 31c98c9

Browse files
committed
fix(MongoMemoryServer): createAuth: fix typo in "customData" & add "customData" to extra users
1 parent 3d430c1 commit 31c98c9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/mongodb-memory-server-core/src/MongoMemoryServer.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ export class MongoMemoryServer extends EventEmitter {
656656

657657
/**
658658
* Create Users and restart instance to enable auth
659-
* This Function assumes "this.opts.auth" is defined / enabled
659+
* This Function assumes "this.opts.auth" is already processed into "this.auth"
660660
* @param data Used to get "ip" and "port"
661661
* @internal
662662
*/
@@ -680,7 +680,7 @@ export class MongoMemoryServer extends EventEmitter {
680680
pwd: 'rootuser',
681681
mechanisms: ['SCRAM-SHA-256'],
682682
customData: {
683-
createBy: 'mongodb-memory-server',
683+
createdBy: 'mongodb-memory-server',
684684
as: 'ROOTUSER',
685685
},
686686
roles: ['root'],
@@ -708,7 +708,11 @@ export class MongoMemoryServer extends EventEmitter {
708708
await db.command({
709709
createUser: user.createUser,
710710
pwd: user.pwd,
711-
customData: user.customData ?? {},
711+
customData: {
712+
...user.customData,
713+
createdBy: 'mongodb-memory-server',
714+
as: 'EXTRAUSER',
715+
},
712716
roles: user.roles,
713717
authenticationRestrictions: user.authenticationRestrictions ?? [],
714718
mechanisms: user.mechanisms ?? ['SCRAM-SHA-256'],

0 commit comments

Comments
 (0)