import { AuthHeadersStorage } from './auth_headers_storage' ; import { OpenSearchDashboardsRequest } from './router' ; import { httpServerMock } from './http_server.mocks' ; describe ( 'AuthHeadersStorage' , ( ) => { describe ( 'stores authorization headers' , ( ) => { it ( 'retrieves a copy of headers associated with OpenSearchDashboards request' , ( ) => { const headers = { authorization : 'token' } ; const storage = new AuthHeadersStorage ( ) ; const rawRequest = httpServerMock . createRawRequest ( ) ; storage . set ( OpenSearchDashboardsRequest . from ( rawRequest ) , headers ) ; expect ( storage . get ( OpenSearchDashboardsRequest . from ( rawRequest ) ) ) . toEqual ( headers ) ; } ) ; it ( 'retrieves a copy of headers associated with Legacy.Request' , ( ) => { const headers = { authorization : 'token' } ; const storage = new AuthHeadersStorage ( ) ; const rawRequest = httpServerMock . createRawRequest ( ) ; storage . set ( rawRequest , headers ) ; expect ( storage . get ( rawRequest ) ) . toEqual ( headers ) ; } ) ; it ( 'retrieves a copy of headers associated with both OpenSearchDashboardsRequest & Legacy.Request' , ( ) => { const headers = { authorization : 'token' } ; const storage = new AuthHeadersStorage ( ) ; const rawRequest = httpServerMock . createRawRequest ( ) ; storage . set ( OpenSearchDashboardsRequest . from ( rawRequest ) , headers ) ; expect ( storage . get ( rawRequest ) ) . toEqual ( headers ) ; } ) ; } ) ; } ) ;