jstests/auth/listcommands_preauth_base.js
// Make sure that listCommands doesn't require authentication.
Make sure that listCommands doesn't require authentication.
Make sure that listCommands doesn ' t require authentication .
function runTest(conn) {
    const admin = conn.getDB('admin');
    assert.commandWorked(admin.runCommand({listDatabases: 1}),
                         "listDatabases shouldn't work pre-auth");
    assert.commandWorked(admin.runCommand({listCommands: 1}), "listCommands should work pre-auth");
    admin.createUser({user: 'admin', pwd: 'pass', roles: jsTest.adminUserRoles});
    assert.commandFailed(admin.runCommand({listDatabases: 1}),
                         "listDatabases shouldn't work pre-auth");
    assert.commandWorked(admin.runCommand({listCommands: 1}), "listCommands should work pre-auth");
}
function runTest ( conn ) { const admin = conn . getDB ( 'admin' ) ; assert . commandWorked ( admin . runCommand ( { listDatabases : 1 } ) , "listDatabases shouldn't work pre-auth" ) ; assert . commandWorked ( admin . runCommand ( { listCommands : 1 } ) , "listCommands should work pre-auth" ) ; admin . createUser ( { user : 'admin' , pwd : 'pass' , roles : jsTest . adminUserRoles } ) ; assert . commandFailed ( admin . runCommand ( { listDatabases : 1 } ) , "listDatabases shouldn't work pre-auth" ) ; assert . commandWorked ( admin . runCommand ( { listCommands : 1 } ) , "listCommands should work pre-auth" ) ; }
Make sure that listCommands doesn't require authentication.
Make sure that listCommands doesn ' t require authentication .
// Commands should succeed in auth-bypass mode regardless of requiresAuth(). // listDatabases should now fail, because auth bypass is no longer valid. // listCommands should STILL work, because it does not require auth.