import { BehaviorSubject } from 'rxjs' ; import { REPO_ROOT } from '@osd/dev-utils' ; import { ByteSizeValue } from '@osd/config-schema' ; import { Env } from '../config' ; import { HttpService } from './http_service' ; import { CoreContext } from '../core_context' ; import { getEnvOptions , configServiceMock } from '../config/mocks' ; import { loggingSystemMock } from '../logging/logging_system.mock' ; const coreId = Symbol ( 'core' ) ; const env = Env . createDefault ( REPO_ROOT , getEnvOptions ( ) ) ; const logger = loggingSystemMock . create ( ) ; const configService = configServiceMock . create ( ) ; configService . atPath . mockReturnValue ( new BehaviorSubject ( { hosts : [ 'localhost' ] , maxPayload : new ByteSizeValue ( 1024 ) , autoListen : true , ssl : { enabled : false , } , compression : { enabled : true } , xsrf : { disableProtection : true , whitelist : [ ] , } , customResponseHeaders : { } , requestId : { allowFromAnyIp : true , ipAllowlist : [ ] , } , keepaliveTimeout : 120000 , socketTimeout : 120000 , } as any ) ) ; const defaultContext = { coreId , env , logger , configService , } ; export const createCoreContext = ( overrides = { } ) : CoreContext => ( { ... defaultContext , ... overrides , } ) ; /**
 * Creates a concrete HttpServer with a mocked context.
 */ export const createHttpServer = ( overrides = { } ) : HttpService => { return new HttpService ( createCoreContext ( overrides ) ) ; } ;