jstests/noPassthrough/libs/user_write_blocking.js
// user. Create a connection authenticated as each user.
user. Create a connection authenticated as each user.
user . Create a connection authenticated as each user .
spawnConnections(port) {
            this.adminConn = new Mongo("127.0.0.1:" + port);
            this.adminConn.port = port;
            const admin = this.adminConn.getDB("admin");
            if (!this.haveCreatedUsers) {
                assert.commandWorked(admin.runCommand({
                    createUser: bypassUser,
                    pwd: password,
                    roles: [{role: "__system", db: "admin"}]
                }));
            }
            assert(admin.auth(bypassUser, password));
            if (!this.haveCreatedUsers) {
                assert.commandWorked(admin.runCommand({
                    createUser: noBypassUser,
                    pwd: password,
                    roles: [
                        {role: "readWriteAnyDatabase", db: "admin"},
                        {role: "dbAdminAnyDatabase", db: "admin"},
                        {role: "clusterAdmin", db: "admin"}
                    ]
                }));
                this.haveCreatedUsers = true;
            }
            this.conn = new Mongo("127.0.0.1:" + port);
            this.conn.port = port;
            assert(this.conn.getDB("admin").auth(noBypassUser, password));
        }
spawnConnections ( port ) { this . adminConn = new Mongo ( "127.0.0.1:" + port ) ; this . adminConn . port = port ; const admin = this . adminConn . getDB ( "admin" ) ; if ( ! this . haveCreatedUsers ) { assert . commandWorked ( admin . runCommand ( { createUser : bypassUser , pwd : password , roles : [ { role : "__system" , db : "admin" } ] } ) ) ; } assert ( admin . auth ( bypassUser , password ) ) ; if ( ! this . haveCreatedUsers ) { assert . commandWorked ( admin . runCommand ( { createUser : noBypassUser , pwd : password , roles : [ { role : "readWriteAnyDatabase" , db : "admin" } , { role : "dbAdminAnyDatabase" , db : "admin" } , { role : "clusterAdmin" , db : "admin" } ] } ) ) ; this . haveCreatedUsers = true ; } this . conn = new Mongo ( "127.0.0.1:" + port ) ; this . conn . port = port ; assert ( this . conn . getDB ( "admin" ) . auth ( noBypassUser , password ) ) ; }
user.
user .
// User with "__system" role has restore role and thus can bypass user write blocking. // Can also run setUserWriteBlockMode. // Need for CUD operations // Need for DDL operations // Need for importCollection