@@ -49,6 +49,20 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
49
49
httpProxy . setRedirectHostRewrite ( this . req , { } , this . proxyRes , this . options ) ;
50
50
expect ( this . proxyRes . headers . location ) . to . eql ( 'http://ext-manual.com/' ) ;
51
51
} ) ;
52
+
53
+ it ( 'not when the redirected location does not match target host' , function ( ) {
54
+ this . proxyRes . statusCode = 302 ;
55
+ this . proxyRes . headers . location = "http://some-other/" ;
56
+ httpProxy . setRedirectHostRewrite ( this . req , { } , this . proxyRes , this . options ) ;
57
+ expect ( this . proxyRes . headers . location ) . to . eql ( 'http://some-other/' ) ;
58
+ } ) ;
59
+
60
+ it ( 'not when the redirected location does not match target port' , function ( ) {
61
+ this . proxyRes . statusCode = 302 ;
62
+ this . proxyRes . headers . location = "http://backend.com:8080/" ;
63
+ httpProxy . setRedirectHostRewrite ( this . req , { } , this . proxyRes , this . options ) ;
64
+ expect ( this . proxyRes . headers . location ) . to . eql ( 'http://backend.com:8080/' ) ;
65
+ } ) ;
52
66
} ) ;
53
67
54
68
context ( 'rewrites location host with autoRewrite' , function ( ) {
@@ -74,6 +88,20 @@ describe('lib/http-proxy/passes/web-outgoing.js', function () {
74
88
httpProxy . setRedirectHostRewrite ( this . req , { } , this . proxyRes , this . options ) ;
75
89
expect ( this . proxyRes . headers . location ) . to . eql ( 'http://backend.com/' ) ;
76
90
} ) ;
91
+
92
+ it ( 'not when the redirected location does not match target host' , function ( ) {
93
+ this . proxyRes . statusCode = 302 ;
94
+ this . proxyRes . headers . location = "http://some-other/" ;
95
+ httpProxy . setRedirectHostRewrite ( this . req , { } , this . proxyRes , this . options ) ;
96
+ expect ( this . proxyRes . headers . location ) . to . eql ( 'http://some-other/' ) ;
97
+ } ) ;
98
+
99
+ it ( 'not when the redirected location does not match target port' , function ( ) {
100
+ this . proxyRes . statusCode = 302 ;
101
+ this . proxyRes . headers . location = "http://backend.com:8080/" ;
102
+ httpProxy . setRedirectHostRewrite ( this . req , { } , this . proxyRes , this . options ) ;
103
+ expect ( this . proxyRes . headers . location ) . to . eql ( 'http://backend.com:8080/' ) ;
104
+ } ) ;
77
105
} ) ;
78
106
79
107
context ( 'rewrites location protocol with protocolRewrite' , function ( ) {
0 commit comments