@@ -252,3 +252,141 @@ def test_registration_response(self):
252252
253253 # Not what I asked for but something I can handle
254254 assert to_use ["subject_type" ] == "pairwise"
255+
256+ def test_registration_response_consistence (self ):
257+ client_conf = {
258+ "application_type" : "web" ,
259+ "base_url" : "https://client.example.org/" ,
260+ "redirect_uris" : [
261+ "https://client.example.org/callback" ,
262+ "https://client.example.org/callback2" ,
263+ ],
264+ "client_name" : "My Example" ,
265+ "client_id" : "client_id" ,
266+ "keys" : {"key_defs" : KEYSPEC , "read_only" : True },
267+ "client_secret" : "a longesh password" ,
268+ "logo_uri" : "https://client.example.org/logo.png" ,
269+ "contacts" : ["ve7jtb@example.org" , "mary@example.org" ],
270+ }
271+
272+ self .claims .load_conf (client_conf , self .supported )
273+
274+ self .claims .prefer = supported_to_preferred (
275+ supported = self .supported ,
276+ preference = self .claims .prefer ,
277+ base_url = "https://example.com" ,
278+ )
279+ to_use_1 = preferred_to_registered (
280+ prefers = self .claims .prefer ,
281+ supported = self .supported ,
282+ )
283+
284+ OP_BASEURL = "https://example.com"
285+ provider_info_response = {
286+ "version" : "3.0" ,
287+ "token_endpoint_auth_methods_supported" : [
288+ "client_secret_post" ,
289+ "client_secret_basic" ,
290+ "client_secret_jwt" ,
291+ "private_key_jwt" ,
292+ ],
293+ "issuer" : OP_BASEURL ,
294+ "jwks_uri" : f"{ OP_BASEURL } /static/jwks_tE2iLbOAqXhe8bqh.json" ,
295+ "authorization_endpoint" : f"{ OP_BASEURL } /authorization" ,
296+ "token_endpoint" : f"{ OP_BASEURL } /token" ,
297+ "userinfo_endpoint" : f"{ OP_BASEURL } /userinfo" ,
298+ "registration_endpoint" : f"{ OP_BASEURL } /registration" ,
299+ "end_session_endpoint" : f"{ OP_BASEURL } /end_session" ,
300+ # below are a set which the RP has default values but the OP overwrites
301+ "scopes_supported" : ["openid" , "fee" , "faa" , "foo" , "fum" ],
302+ "response_types_supported" : ["code" , "id_token" , "code id_token" ],
303+ "response_modes_supported" : ["query" , "form_post" , "new_fangled" ],
304+ # this does not have a default value
305+ "acr_values_supported" : ["mfa" ],
306+ }
307+
308+ pref = self .claims .prefer = supported_to_preferred (
309+ supported = self .supported ,
310+ preference = self .claims .prefer ,
311+ base_url = "https://example.com" ,
312+ info = provider_info_response ,
313+ )
314+
315+ registration_request = create_registration_request (self .claims .prefer , self .supported )
316+
317+ assert set (registration_request .keys ()) == {
318+ "application_type" ,
319+ "client_name" ,
320+ "contacts" ,
321+ "default_max_age" ,
322+ "id_token_signed_response_alg" ,
323+ "jwks" ,
324+ "logo_uri" ,
325+ "redirect_uris" ,
326+ "request_object_signing_alg" ,
327+ "response_modes" , # non-standard
328+ "response_types" ,
329+ "subject_type" ,
330+ "token_endpoint_auth_method" ,
331+ "token_endpoint_auth_signing_alg" ,
332+ "userinfo_signed_response_alg" ,
333+ }
334+
335+ assert registration_request ["subject_type" ] == "public"
336+
337+ registration_response = {
338+ "application_type" : "web" ,
339+ "redirect_uris" : [
340+ "https://client.example.org/callback" ,
341+ "https://client.example.org/callback2" ,
342+ ],
343+ "client_name" : "My Example" ,
344+ "logo_uri" : "https://client.example.org/logo.png" ,
345+ "subject_type" : "pairwise" ,
346+ "sector_identifier_uri" : "https://other.example.net/file_of_redirect_uris.json" ,
347+ "token_endpoint_auth_method" : "client_secret_basic" ,
348+ "jwks_uri" : "https://client.example.org/my_public_keys.jwks" ,
349+ "userinfo_encrypted_response_alg" : "RSA1_5" ,
350+ "userinfo_encrypted_response_enc" : "A128CBC-HS256" ,
351+ "contacts" : ["ve7jtb@example.org" , "mary@example.org" ],
352+ "request_uris" : [
353+ "https://client.example.org/rf.txt#qpXaRLh_n93TTR9F252ValdatUQvQiJi5BDub2BeznA"
354+ ],
355+ }
356+
357+ to_use_2 = preferred_to_registered (
358+ prefers = self .claims .prefer ,
359+ supported = self .supported ,
360+ registration_response = registration_response ,
361+ )
362+
363+ assert set (to_use_2 .keys ()) == {
364+ "application_type" ,
365+ "client_id" ,
366+ "client_name" ,
367+ "client_secret" ,
368+ "contacts" ,
369+ "default_max_age" ,
370+ "encrypt_request_object_supported" ,
371+ "encrypt_userinfo_supported" ,
372+ "id_token_signed_response_alg" ,
373+ "jwks" ,
374+ "jwks_uri" ,
375+ "logo_uri" ,
376+ "redirect_uris" ,
377+ "request_object_signing_alg" ,
378+ "request_uris" ,
379+ "response_modes" ,
380+ "response_types" ,
381+ "scope" ,
382+ "sector_identifier_uri" ,
383+ "subject_type" ,
384+ "token_endpoint_auth_method" ,
385+ "token_endpoint_auth_signing_alg" ,
386+ "userinfo_encrypted_response_alg" ,
387+ "userinfo_encrypted_response_enc" ,
388+ "userinfo_signed_response_alg" ,
389+ }
390+
391+ # Not what I asked for but something I can handle
392+ assert to_use_2 ["subject_type" ] == "pairwise"
0 commit comments