@@ -221,28 +221,10 @@ describe('proxyIntegration.routeHandler', () => {
221221 } , context ) ;
222222 } ) ;
223223 it ( 'should not change path if not coming over custom domain name' , ( ) => {
224- const actionSpy = jasmine . createSpy ( 'action' ) ;
225- const context = { } ;
226- const event = {
227- httpMethod : 'GET' , path : "/123/456" ,
228- headers : { Host : "blabla.execute-api.eu-central-1.amazonaws.com" } ,
229- requestContext : { apiId : 'blabla' }
230- } ;
231- proxyIntegration ( {
232- routes : [ {
233- method : 'GET' ,
234- path : '/123/456' ,
235- action : actionSpy
236- } ]
237- } , event , context , ( ) => {
238- } ) ;
239- expect ( actionSpy ) . toHaveBeenCalledWith ( {
240- httpMethod : 'GET' ,
241- headers : jasmine . anything ( ) ,
242- requestContext : jasmine . anything ( ) ,
243- path : "/123/456" ,
244- paths : { }
245- } , context ) ;
224+ assertPathIsUnchanged ( "blabla.execute-api.eu-central-1.amazonaws.com" ) ;
225+ } ) ;
226+ it ( 'should not change path if coming over localhost' , ( ) => {
227+ assertPathIsUnchanged ( "localhost" ) ;
246228 } ) ;
247229 it ( 'should return 400 for an invalid body' , ( done ) => {
248230 proxyIntegration ( { routes : [ { } ] } , { httpMethod : 'GET' , path : '/' , body : '{keinJson' } ) . then ( result => {
@@ -489,3 +471,28 @@ describe('proxyIntegration.routeHandler.returnvalues', () => {
489471 } ) ;
490472} ) ;
491473
474+ function assertPathIsUnchanged ( hostname ) {
475+ const actionSpy = jasmine . createSpy ( 'action' ) ;
476+ const context = { } ;
477+ const event = {
478+ httpMethod : 'GET' , path : "/123/456" ,
479+ headers : { Host : hostname } ,
480+ requestContext : { apiId : 'blabla' }
481+ } ;
482+ proxyIntegration ( {
483+ routes : [ {
484+ method : 'GET' ,
485+ path : '/123/456' ,
486+ action : actionSpy
487+ } ]
488+ } , event , context , ( ) => {
489+ } ) ;
490+ expect ( actionSpy ) . toHaveBeenCalledWith ( {
491+ httpMethod : 'GET' ,
492+ headers : jasmine . anything ( ) ,
493+ requestContext : jasmine . anything ( ) ,
494+ path : "/123/456" ,
495+ paths : { }
496+ } , context ) ;
497+ }
498+
0 commit comments