jstests/auth/change_stream_pre_image_coll_role_auth.js
// Helper to create users from the 'users' dictionary on the provided connection.
Helper to create users from the 'users' dictionary on the provided connection.
Helper to create users from the ' users ' dictionary on the provided connection .
function createUsers(conn) {
    function createUser(userName) {
        const adminDb = userName !== "admin" ? login(conn, "admin") : null;
        const user = users[userName];
        conn.getDB(user.db).createUser({user: userName, pwd: password, roles: user.roles});
        if (adminDb !== null) {
            adminDb.logout();
        }
        const db = login(conn, userName);
        db.logout();
    }
    createUser("admin");
    createUser("clusterAdmin");
    createUser("test");
    createUser("root");
}
function createUsers ( conn ) { function createUser ( userName ) { const adminDb = userName !== "admin" ? login ( conn , "admin" ) : null ; const user = users [ userName ] ; conn . getDB ( user . db ) . createUser ( { user : userName , pwd : password , roles : user . roles } ) ; if ( adminDb !== null ) { adminDb . logout ( ) ; } const db = login ( conn , userName ) ; db . logout ( ) ; } createUser ( "admin" ) ; createUser ( "clusterAdmin" ) ; createUser ( "test" ) ; createUser ( "root" ) ; }
Helper to create users from the 'users' dictionary on the provided connection.
Helper to create users from the ' users ' dictionary on the provided connection .
// A user-creation will happen by 'admin' user. If 'userName' is not 'admin', then login // first as an 'admin'. // Get the details of user to create and issue create command. // Logout if the current authenticated user is 'admin' // Verify that the user has been created by logging-in and then logging out. // Create the list of users on the specified connection.