import { getTestScenarios } from '../../common/lib/saved_object_test_utils' ; import { TestUser } from '../../common/lib/types' ; import { FtrProviderContext } from '../../common/ftr_provider_context' ; import { exportTestSuiteFactory , getTestCases , ExportTestDefinition , } from '../../common/suites/export' ; const createTestCases = ( spaceId ) => { const cases = getTestCases ( spaceId ) ; const exportableObjects = [ cases . singleNamespaceObject , cases . multiNamespaceObject , cases . multiNamespaceIsolatedObject , cases . namespaceAgnosticObject , ] ; const exportableTypes = [ cases . singleNamespaceType , cases . multiNamespaceType , cases . multiNamespaceIsolatedType , cases . namespaceAgnosticType , ] ; const nonExportableObjectsAndTypes = [ cases . hiddenObject , cases . hiddenType ] ; const allObjectsAndTypes = [ exportableObjects , exportableTypes , nonExportableObjectsAndTypes , ] . flat ( ) ; return { exportableObjects , exportableTypes , nonExportableObjectsAndTypes , allObjectsAndTypes } ; } ; export default function ( { getService } ) { const supertest = getService ( 'supertestWithoutAuth' ) ; const esArchiver = getService ( 'esArchiver' ) ; const { addTests , createTestDefinitions } = exportTestSuiteFactory ( esArchiver , supertest ) ; const createTests = ( spaceId ) => { const { exportableObjects , exportableTypes , nonExportableObjectsAndTypes , allObjectsAndTypes } = createTestCases ( spaceId ) ; return { unauthorized : [ createTestDefinitions ( exportableObjects , { statusCode : 403 , reason : 'unauthorized' } ) , createTestDefinitions ( exportableTypes , { statusCode : 403 , reason : 'unauthorized' } ) , createTestDefinitions ( nonExportableObjectsAndTypes , false ) , ] . flat ( ) , authorized : createTestDefinitions ( allObjectsAndTypes , false ) , } ; } ; describe ( '_export' , ( ) => { getTestScenarios ( ) . securityAndSpaces . forEach ( ( { spaceId , users } ) => { const suffix = ` within the ${ spaceId } space` ; const { unauthorized , authorized } = createTests ( spaceId ) ; const _addTests = ( user , tests ) => { addTests ( `${ user . description }${ suffix }` , { user , spaceId , tests } ) ; } ; [ users . noAccess , users . legacyAll , users . allAtOtherSpace ] . forEach ( ( user ) => { _addTests ( user , unauthorized ) ; } ) ; [ users . dualAll , users . dualRead , users . allGlobally , users . readGlobally , users . allAtSpace , users . readAtSpace , users . superuser , ] . forEach ( ( user ) => { _addTests ( user , authorized ) ; } ) ; } ) ; } ) ; }