@@ -158,7 +158,7 @@ public function testValidServiceUrl()
158158 * @dataProvider buggyClientProvider
159159 * @return void
160160 */
161- public function testBuggyClientBadUrlEncodingWorkAround ($ service_url )
161+ public function testBuggyClientBadUrlEncodingWorkAround ($ service_url, $ expectedStartsWith , $ expectedEndsWith )
162162 {
163163 $ this ->authenticate ();
164164
@@ -171,20 +171,34 @@ public function testBuggyClientBadUrlEncodingWorkAround($service_url)
171171 CURLOPT_COOKIEFILE => $ this ->cookies_file
172172 ]
173173 );
174- $ this ->assertEquals (302 , $ resp ['code ' ]);
174+ $ this ->assertEquals (302 , $ resp ['code ' ], $ resp [ ' body ' ] );
175175
176176 $ this ->assertStringStartsWith (
177- $ service_url . ' ?ticket=ST- ' ,
177+ $ expectedStartsWith ,
178178 $ resp ['headers ' ]['Location ' ],
179179 'Ticket should be part of the redirect. '
180180 );
181+ if (!empty ($ expectedEndsWith )) {
182+ $ this ->assertStringEndsWith (
183+ $ expectedEndsWith ,
184+ $ resp ['headers ' ]['Location ' ],
185+ 'url fragments happen after the query params '
186+ );
187+ }
181188 }
182189
183190 public function buggyClientProvider (): array
184191 {
192+ $ urlWithQuery = 'https://buggy.edu/kc/portal.do?solo&ct=Search%20Prot&curl=https://kc.edu/kc/IRB.do?se=1875*&runSearch=1 ' ;
193+ $ urlNoQuery = 'https://buggy.edu/kc ' ;
194+ $ urlMultiKeys = 'https://buggy.edu/kc?a=val1&a=val2 ' ;
185195 return [
186- ['https://buggy.edu/kc/portal.do?solo&ct=Search%20Prot&curl=https://kc.edu/kc/IRB.do?se=1875*&runSearch=1 ' ],
187- ['https://buggy.edu/kc ' ],
196+ [$ urlWithQuery , $ urlWithQuery . '&ticket=ST- ' , '' ],
197+ [$ urlWithQuery . '#fragment ' , $ urlWithQuery . '&ticket=ST- ' , '#fragment ' ],
198+ [$ urlMultiKeys , $ urlMultiKeys . '&ticket=ST- ' , '' ],
199+ [$ urlMultiKeys . '#fragment ' , $ urlMultiKeys . '&ticket=ST- ' , '#fragment ' ],
200+ [$ urlNoQuery , $ urlNoQuery . '?ticket=ST- ' , '' ],
201+ [$ urlNoQuery . '#fragment ' , $ urlNoQuery . '?ticket=ST- ' , '#fragment ' ],
188202 ];
189203 }
190204
0 commit comments