import { FtrProviderContext as CommonFtrProviderContext } from '../../../common/ftr_provider_context' ; import { USERS , ROLES } from './authentication' ; import { User , Role } from './types' ; export const createUsersAndRoles = async ( getService ) => { const security = getService ( 'security' ) ; const createRole = async ( { name , privileges } ) => { return await security . role . create ( name , privileges ) ; } ; const createUser = async ( { username , password , roles , superuser } ) => { if ( superuser ) { return ; } return await security . user . create ( username , { password , roles , full_name : username . replace ( '_' , ' ' ) , email : `${ username }@elastic.co` , } ) ; } ; for ( const role of Object . values ( ROLES ) ) { await createRole ( role ) ; } for ( const user of Object . values ( USERS ) ) { await createUser ( user ) ; } } ;