import expect from '@kbn/expect' ; import { FtrProviderContext } from '../../ftr_provider_context' ; export default function ( { getService } ) { describe ( 'post_privileges' , ( ) => { it ( 'should allow privileges to be updated' , async ( ) => { const es = getService ( 'es' ) ; const application = 'foo' ; const response = await es . security . putPrivileges ( { body : { [ application ] : { all : { application , name : 'all' , actions : [ 'action:*' ] , metadata : { } , } , read : { application , name : 'read' , actions : [ 'action:readAction1' , 'action:readAction2' ] , metadata : { } , } , } , } , } ) ; expect ( response ) . to . eql ( { foo : { all : { created : true } , read : { created : true } , } , } ) ; const updateResponse = await es . security . putPrivileges ( { body : { [ application ] : { read : { application , name : 'read' , actions : [ 'action:readAction1' , 'action:readAction4' ] , metadata : { } , } , other : { application , name : 'other' , actions : [ 'action:otherAction1' ] , metadata : { } , } , } , } , } ) ; expect ( updateResponse ) . to . eql ( { foo : { other : { created : true } , read : { created : false } , } , } ) ; const retrievedPrivilege = await es . security . getPrivileges ( { application } ) ; expect ( retrievedPrivilege ) . to . eql ( { foo : { all : { application , name : 'all' , actions : [ 'action:*' ] , metadata : { } , } , read : { application , name : 'read' , actions : [ 'action:readAction1' , 'action:readAction4' ] , metadata : { } , } , other : { application , name : 'other' , actions : [ 'action:otherAction1' ] , metadata : { } , } , } , } ) ; } ) ; } ) ; }