6767 XForwardedPrefix string
6868 SecureBackend bool
6969 enforceRegex bool
70+ pathType networking.PathType
7071 }{
7172 "when secure backend enabled" : {
7273 "/" ,
7879 "" ,
7980 true ,
8081 false ,
82+ networking .PathTypePrefix ,
8183 },
8284 "when secure backend and dynamic config enabled" : {
8385 "/" ,
8991 "" ,
9092 true ,
9193 false ,
94+ networking .PathTypePrefix ,
9295 },
9396 "when secure backend, stickiness and dynamic config enabled" : {
9497 "/" ,
@@ -100,6 +103,7 @@ var (
100103 "" ,
101104 true ,
102105 false ,
106+ networking .PathTypePrefix ,
103107 },
104108 "invalid redirect / to / with dynamic config enabled" : {
105109 "/" ,
@@ -111,6 +115,7 @@ var (
111115 "" ,
112116 false ,
113117 false ,
118+ networking .PathTypePrefix ,
114119 },
115120 "invalid redirect / to /" : {
116121 "/" ,
@@ -122,6 +127,7 @@ var (
122127 "" ,
123128 false ,
124129 false ,
130+ networking .PathTypePrefix ,
125131 },
126132 "redirect / to /jenkins" : {
127133 "/" ,
@@ -137,6 +143,7 @@ proxy_pass $scheme://upstream_balancer;`,
137143 "" ,
138144 false ,
139145 true ,
146+ networking .PathTypePrefix ,
140147 },
141148 "redirect / to /something with sticky enabled" : {
142149 "/" ,
@@ -152,6 +159,7 @@ proxy_pass $scheme://upstream_balancer;`,
152159 "" ,
153160 false ,
154161 true ,
162+ networking .PathTypePrefix ,
155163 },
156164 "redirect / to /something with sticky and dynamic config enabled" : {
157165 "/" ,
@@ -167,6 +175,7 @@ proxy_pass $scheme://upstream_balancer;`,
167175 "" ,
168176 false ,
169177 true ,
178+ networking .PathTypePrefix ,
170179 },
171180 "add the X-Forwarded-Prefix header" : {
172181 "/there" ,
@@ -184,6 +193,7 @@ proxy_pass $scheme://upstream_balancer;`,
184193 "/there" ,
185194 false ,
186195 true ,
196+ networking .PathTypePrefix ,
187197 },
188198 "use ~* location modifier when ingress does not use rewrite/regex target but at least one other ingress does" : {
189199 "/something" ,
@@ -195,6 +205,19 @@ proxy_pass $scheme://upstream_balancer;`,
195205 "" ,
196206 false ,
197207 true ,
208+ networking .PathTypePrefix ,
209+ },
210+ "exact paths should remain exact when enforce regex is enabled" : {
211+ "/something" ,
212+ "/something" ,
213+ `~* "^/something$"` ,
214+ "proxy_pass http://upstream_balancer;" ,
215+ "proxy_pass $scheme://upstream_balancer;" ,
216+ false ,
217+ "" ,
218+ false ,
219+ true ,
220+ networking .PathTypeExact ,
198221 },
199222 }
200223)
@@ -319,7 +342,7 @@ func TestBuildLocation(t *testing.T) {
319342 for k , tc := range tmplFuncTestcases {
320343 loc := & ingress.Location {
321344 Path : tc .Path ,
322- PathType : & pathPrefix ,
345+ PathType : & tc . pathType ,
323346 Rewrite : rewrite.Config {Target : tc .Target },
324347 }
325348
0 commit comments