@@ -234,7 +234,7 @@ public function testValidTicketNameOverride()
234234 * @dataProvider buggyClientProvider
235235 * @return void
236236 */
237- public function testBuggyClientBadUrlEncodingWorkAround ($ service_url )
237+ public function testBuggyClientBadUrlEncodingWorkAround ($ service_url, $ expectedStartsWith , $ expectedEndsWith )
238238 {
239239 $ this ->authenticate ();
240240
@@ -247,20 +247,34 @@ public function testBuggyClientBadUrlEncodingWorkAround($service_url)
247247 CURLOPT_COOKIEFILE => $ this ->cookies_file
248248 ]
249249 );
250- $ this ->assertEquals (302 , $ resp ['code ' ]);
250+ $ this ->assertEquals (302 , $ resp ['code ' ], $ resp [ ' body ' ] );
251251
252252 $ this ->assertStringStartsWith (
253- $ service_url . ' ?ticket=ST- ' ,
253+ $ expectedStartsWith ,
254254 $ resp ['headers ' ]['Location ' ],
255255 'Ticket should be part of the redirect. '
256256 );
257+ if (!empty ($ expectedEndsWith )) {
258+ $ this ->assertStringEndsWith (
259+ $ expectedEndsWith ,
260+ $ resp ['headers ' ]['Location ' ],
261+ 'url fragments happen after the query params '
262+ );
263+ }
257264 }
258265
259266 public function buggyClientProvider (): array
260267 {
268+ $ urlWithQuery = 'https://buggy.edu/kc/portal.do?solo&ct=Search%20Prot&curl=https://kc.edu/kc/IRB.do?se=1875*&runSearch=1 ' ;
269+ $ urlNoQuery = 'https://buggy.edu/kc ' ;
270+ $ urlMultiKeys = 'https://buggy.edu/kc?a=val1&a=val2 ' ;
261271 return [
262- ['https://buggy.edu/kc/portal.do?solo&ct=Search%20Prot&curl=https://kc.edu/kc/IRB.do?se=1875*&runSearch=1 ' ],
263- ['https://buggy.edu/kc ' ],
272+ [$ urlWithQuery , $ urlWithQuery . '&ticket=ST- ' , '' ],
273+ [$ urlWithQuery . '#fragment ' , $ urlWithQuery . '&ticket=ST- ' , '#fragment ' ],
274+ [$ urlMultiKeys , $ urlMultiKeys . '&ticket=ST- ' , '' ],
275+ [$ urlMultiKeys . '#fragment ' , $ urlMultiKeys . '&ticket=ST- ' , '#fragment ' ],
276+ [$ urlNoQuery , $ urlNoQuery . '?ticket=ST- ' , '' ],
277+ [$ urlNoQuery . '#fragment ' , $ urlNoQuery . '?ticket=ST- ' , '#fragment ' ],
264278 ];
265279 }
266280
0 commit comments