@@ -193,17 +193,8 @@ public function testAuthorizeWithInvalidRedirectUri()
193193
194194 $ response = $ controller ->authorize ();
195195
196- $ expected = [
197- 'data ' => vsprintf ($ controller ::ERROR_UNREGISTERED_URI , [$ _GET ['redirect_uri ' ]]),
198- 'headers ' => [
199- 'Cache-Control ' => 'no-cache, no-store, must-revalidate ' ,
200- 'Content-Security-Policy ' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none' " ,
201- 'Content-Type ' => 'application/json; charset=utf-8 ' ,
202- 'Feature-Policy ' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none' " ,
203- 'X-Robots-Tag ' => 'noindex, nofollow ' ,
204- ],
205- 'status ' => Http::STATUS_BAD_REQUEST ,
206- ];
196+ $ data = vsprintf ($ controller ::ERROR_UNREGISTERED_URI , [$ _GET ['redirect_uri ' ]]);
197+ $ expected = $ this ->createExpectedResponse (Http::STATUS_BAD_REQUEST , $ data );
207198
208199 $ actual = [
209200 'data ' => $ response ->getData (),
@@ -248,17 +239,7 @@ public function testAuthorize()
248239
249240 $ response = $ controller ->authorize ();
250241
251- $ expected = [
252- 'data ' => 'ok ' ,
253- 'headers ' => [
254- 'Cache-Control ' => 'no-cache, no-store, must-revalidate ' ,
255- 'Content-Security-Policy ' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none' " ,
256- 'Content-Type ' => 'application/json; charset=utf-8 ' ,
257- 'Feature-Policy ' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none' " ,
258- 'X-Robots-Tag ' => 'noindex, nofollow ' ,
259- ],
260- 'status ' => Http::STATUS_FOUND ,
261- ];
242+ $ expected = $ this ->createExpectedResponse ();
262243
263244 $ actual = [
264245 'data ' => $ response ->getData (),
@@ -328,6 +309,20 @@ public function testRegisterWithRedirectUris()
328309
329310 $ response = $ controller ->register ();
330311
312+ $ data = [
313+ 'application_type ' => 'web ' ,
314+ 'client_id ' => 'f4a2d00f7602948a97ff409d7a581ec2 ' ,
315+ 'client_secret ' => '3b5798fddd49e23662ee6fe801085100 ' ,
316+ 'grant_types ' => ['implicit ' ],
317+ 'id_token_signed_response_alg ' => 'RS256 ' ,
318+ 'redirect_uris ' => ['https://mock.client/redirect ' ],
319+ 'registration_access_token ' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL21vY2suc2VydmVyIiwiYXVkIjoiZjRhMmQwMGY3NjAyOTQ4YTk3ZmY0MDlkN2E1ODFlYzIiLCJzdWIiOiJmNGEyZDAwZjc2MDI5NDhhOTdmZjQwOWQ3YTU4MWVjMiJ9.AfOi9YW70rL0EKn4_dvhkyu02iI4yGYV-Xh8hQ9RbHBUnvcXROFfQzn-OL-R3kV3nn8tknmpG-r_8Ouoo7O_Sjo8Hx1QSFfeqjJGOgB8HbXV7WN2spOMicSB-68EyftqfTGH0ksyPyJaNSTbkdIqtawsDaSKUVqTmziEo4IrE5anwDLZrtSUcS0A4KVrOAkJmgYGiC4MC0NMYXeBRxgkr1_h7GN4hekAXs9-5XwRH1mwswUVRL-6prx0IYpPNURFNqkS2NU83xNf-vONThOdLVkADVy-l3PCHT3E1sRdkklCHLjhWiZo7NcMlB0WdS-APnZYCi5hLEr5-jwNI2sxoA ' ,
320+ 'registration_client_uri ' => '' ,
321+ 'response_types ' => ['id_token token ' ],
322+ 'token_endpoint_auth_method ' => 'client_secret_basic ' ,
323+ ];
324+ $ expected = $ this ->createExpectedResponse (Http::STATUS_OK , $ data );
325+
331326 $ actual = [
332327 'data ' => $ response ->getData (),
333328 'headers ' => $ response ->getHeaders (),
@@ -337,27 +332,7 @@ public function testRegisterWithRedirectUris()
337332 // Not comparing time-sensitive data
338333 unset($ actual ['data ' ]['client_id_issued_at ' ], $ actual ['headers ' ]['X-Request-Id ' ]);
339334
340- $ this ->assertEquals ([
341- 'data ' => [
342- 'application_type ' => 'web ' ,
343- 'client_id ' => 'f4a2d00f7602948a97ff409d7a581ec2 ' ,
344- 'grant_types ' => ['implicit ' ],
345- 'id_token_signed_response_alg ' => 'RS256 ' ,
346- 'redirect_uris ' => ['https://mock.client/redirect ' ],
347- 'registration_access_token ' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL21vY2suc2VydmVyIiwiYXVkIjoiZjRhMmQwMGY3NjAyOTQ4YTk3ZmY0MDlkN2E1ODFlYzIiLCJzdWIiOiJmNGEyZDAwZjc2MDI5NDhhOTdmZjQwOWQ3YTU4MWVjMiJ9.AfOi9YW70rL0EKn4_dvhkyu02iI4yGYV-Xh8hQ9RbHBUnvcXROFfQzn-OL-R3kV3nn8tknmpG-r_8Ouoo7O_Sjo8Hx1QSFfeqjJGOgB8HbXV7WN2spOMicSB-68EyftqfTGH0ksyPyJaNSTbkdIqtawsDaSKUVqTmziEo4IrE5anwDLZrtSUcS0A4KVrOAkJmgYGiC4MC0NMYXeBRxgkr1_h7GN4hekAXs9-5XwRH1mwswUVRL-6prx0IYpPNURFNqkS2NU83xNf-vONThOdLVkADVy-l3PCHT3E1sRdkklCHLjhWiZo7NcMlB0WdS-APnZYCi5hLEr5-jwNI2sxoA ' ,
348- 'registration_client_uri ' => '' ,
349- 'response_types ' => ['id_token token ' ],
350- 'token_endpoint_auth_method ' => 'client_secret_basic ' ,
351- ],
352- 'headers ' => [
353- 'Cache-Control ' => 'no-cache, no-store, must-revalidate ' ,
354- 'Content-Security-Policy ' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none' " ,
355- 'Feature-Policy ' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none' " ,
356- 'X-Robots-Tag ' => 'noindex, nofollow ' ,
357- 'Content-Type ' => 'application/json; charset=utf-8 ' ,
358- ],
359- 'status ' => Http::STATUS_OK ,
360- ], $ actual );
335+ $ this ->assertEquals ($ expected , $ actual );
361336 }
362337
363338 /**
@@ -400,17 +375,7 @@ public function testToken()
400375
401376 $ tokenResponse = $ controller ->token ();
402377
403- $ expected = [
404- 'data ' => "I'm a teapot " ,
405- 'headers ' => [
406- 'Cache-Control ' => 'no-cache, no-store, must-revalidate ' ,
407- 'Content-Security-Policy ' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none' " ,
408- 'Feature-Policy ' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none' " ,
409- 'X-Robots-Tag ' => 'noindex, nofollow ' ,
410- 'Content-Type ' => 'application/json; charset=utf-8 ' ,
411- ],
412- 'status ' => Http::STATUS_IM_A_TEAPOT ,
413- ];
378+ $ expected = $ this ->createExpectedResponse (Http::STATUS_IM_A_TEAPOT , "I'm a teapot " );
414379
415380 $ actual = [
416381 'data ' => $ tokenResponse ->getData (),
@@ -474,6 +439,25 @@ public function createMockUserManager(): IUserManager|MockObject
474439 return $ this ->mockUserManager ;
475440 }
476441
442+ public function createExpectedResponse ($ status = Http::STATUS_FOUND , $ data = 'ok ' , $ headers = []): array
443+ {
444+ if (empty ($ headers )) {
445+ $ headers = [
446+ 'Cache-Control ' => 'no-cache, no-store, must-revalidate ' ,
447+ 'Content-Security-Policy ' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none' " ,
448+ 'Content-Type ' => 'application/json; charset=utf-8 ' ,
449+ 'Feature-Policy ' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none' " ,
450+ 'X-Robots-Tag ' => 'noindex, nofollow ' ,
451+ ];
452+ }
453+
454+ return [
455+ 'data ' => $ data ,
456+ 'headers ' => $ headers ,
457+ 'status ' => $ status ,
458+ ];
459+ }
460+
477461 /////////////////////////////// DATAPROVIDERS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
478462
479463 public static function provideConstructorParameterIndex ()
0 commit comments