-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtests.patch
More file actions
5084 lines (4595 loc) · 215 KB
/
tests.patch
File metadata and controls
5084 lines (4595 loc) · 215 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/tests/op_config.json b/tests/op_config.json
index 3d0da0b..9ea2da4 100644
--- a/tests/op_config.json
+++ b/tests/op_config.json
@@ -44,7 +44,7 @@
}
}
},
- "capabilities": {
+ "preference": {
"subject_types_supported": [
"public",
"pairwise"
diff --git a/tests/private/cookie_jwks.json b/tests/private/cookie_jwks.json
index 9d47588..5b507b7 100644
--- a/tests/private/cookie_jwks.json
+++ b/tests/private/cookie_jwks.json
@@ -1 +1 @@
-{"keys": [{"kty": "oct", "use": "enc", "kid": "enc", "k": "4L_0vvQ5QsJvswvh5qCNFyLF4BTSI6xf"}, {"kty": "oct", "use": "sig", "kid": "sig", "k": "UsJ7o_W_ND7aoKnbeWEes3MJOECMMY_c"}]}
\ No newline at end of file
+{"keys": [{"kty": "oct", "use": "enc", "kid": "enc", "k": "GpKOJkB-QVo3qV2FZMVZFvha-TyJTHeH"}, {"kty": "oct", "use": "sig", "kid": "sig", "k": "ugxh7wUNKyolAiXiEWFVL_BVcjaNxvvb"}]}
\ No newline at end of file
diff --git a/tests/private/token_jwks.json b/tests/private/token_jwks.json
index d3e0f07..d171cfa 100644
--- a/tests/private/token_jwks.json
+++ b/tests/private/token_jwks.json
@@ -1 +1 @@
-{"keys": [{"kty": "oct", "use": "enc", "kid": "code", "k": "vSHDkLBHhDStkR0NWu8519rmV5zmnm5_"}, {"kty": "oct", "use": "enc", "kid": "refresh", "k": "vrjoMrmgK8SmJJPc318zTxqG_tvBqF5l"}]}
\ No newline at end of file
+{"keys": [{"kty": "oct", "use": "enc", "kid": "code", "k": "vSHDkLBHhDStkR0NWu8519rmV5zmnm5_"}, {"kty": "oct", "use": "enc", "kid": "refresh", "k": "rJGcHkBJrCCUYp5k62ABrQuUeug_gmL6"}]}
\ No newline at end of file
diff --git a/tests/request123456.jwt b/tests/request123456.jwt
index fed3886..5338a28 100644
--- a/tests/request123456.jwt
+++ b/tests/request123456.jwt
@@ -1 +1 @@
-eyJhbGciOiJSUzI1NiIsImtpZCI6IlNIRXlZV2N3TlZrMExUZFJPVFp6WjJGVVduZElWWGRhY2sweFdVTTVTRXB3Y1MwM2RWVXhXVTR6UlEifQ.eyJyZXNwb25zZV90eXBlIjogImNvZGUiLCAic3RhdGUiOiAic3RhdGUiLCAicmVkaXJlY3RfdXJpIjogImh0dHBzOi8vZXhhbXBsZS5jb20vY2xpL2F1dGh6X2NiIiwgInNjb3BlIjogIm9wZW5pZCIsICJub25jZSI6ICJpcno4SG5ELXFsOVhNYVJYUll1S3BpcEpHM2hiRWZ5akxBYXQwMjNLZEdvIiwgImNsaWVudF9pZCI6ICJjbGllbnRfaWQiLCAiaXNzIjogImNsaWVudF9pZCIsICJpYXQiOiAxNzEwODM2MDQwLCAiYXVkIjogWyJodHRwczovL2V4YW1wbGUuY29tIl19.EDvgPn7QJFm6O4d9QFU9gVZEmAREDIfl1RTiMtec7_ZJ4vGag3dxCyXgz15GbDrQgo6mqCydCe-Mal_4HBlRwMctqhy9NMIGM5PxIKzrqMjsk88jxAoz-WWw3I-pKrJUS4m23mEgLZkGQpB1N3YgO_RhG-7vGCkiJd_8VuomRMd2dX5_Jax3j12T7vhM_TUI9S6XJ5zsLn2ZOPQVXfoprr7HHY6UJjJ65Fp_hoGA3gmfJiHwbxYss8D2X1BNoLmEMze_e6cS-DGe648t2U47E77BvHdzsKi791Y1L3eizkm364gJ371KWbi3avvbSkTi4hEd3OikkyeMQZk6vDiJww
\ No newline at end of file
+eyJhbGciOiJSUzI1NiIsImtpZCI6IlNIRXlZV2N3TlZrMExUZFJPVFp6WjJGVVduZElWWGRhY2sweFdVTTVTRXB3Y1MwM2RWVXhXVTR6UlEifQ.eyJyZXNwb25zZV90eXBlIjogImNvZGUiLCAic3RhdGUiOiAic3RhdGUiLCAicmVkaXJlY3RfdXJpIjogImh0dHBzOi8vZXhhbXBsZS5jb20vY2xpL2F1dGh6X2NiIiwgInNjb3BlIjogIm9wZW5pZCIsICJub25jZSI6ICIxcGNuQ3RTSHlrc1JwVzE4N2NWS2p0X2JjTUN0S0dGZzBOZTFyYlhlRXZzIiwgImNsaWVudF9pZCI6ICJjbGllbnRfaWQiLCAiZXhwIjogMTczMDM3NzA5MiwgImlzcyI6ICJjbGllbnRfaWQiLCAiaWF0IjogMTczMDM3MzQ5MiwgImF1ZCI6IFsicmVxdWVzdF91cmkiXSwgImp0aSI6ICI1NzUxZDhmNTVkYzU0OTE1OTI4MjhiMjM0M2YxZTMxZSJ9.k2D_v7jv9cFWIcB6I3HlUPnZg4Tx9FBANR4kPH16fh8cI-c_YFvbCfrXpwUOj1CUY4ZdFqtZnYQD8rQHtjqgXjF79X8H6V6c_7GjQSzHlSAPshFMGm4eXiDKfSCq1xu4YEC-qaub19JjqHpzq6y2Sfz1ayI5qdg_-yJap8HHoPSYzaZ_oPVP7u1TAP24fI15w_leSlgYuXFyzbCWlcWjoHxCJaxYobw3HrAJE4p9h5XL84Rth73xi918CuGw4ngWcF7aQg5dUc1HZPrefU0iVs7Rhi75GmkQzByx7kqIN0T1J-wUod7o69sIqrfWuccam3ndo5E8YlUvwXo0JwKlFQ
\ No newline at end of file
diff --git a/tests/test_04_message.py b/tests/test_04_message.py
index 7fe1878..a3c05b7 100644
--- a/tests/test_04_message.py
+++ b/tests/test_04_message.py
@@ -14,6 +14,7 @@ from cryptojwt.key_jar import build_keyjar
from idpyoidc.exception import DecodeError
from idpyoidc.exception import MessageException
from idpyoidc.exception import OidcMsgError
+from idpyoidc.key_import import store_under_other_id
from idpyoidc.message import OPTIONAL_LIST_OF_MESSAGES
from idpyoidc.message import OPTIONAL_LIST_OF_STRINGS
from idpyoidc.message import OPTIONAL_MESSAGE
@@ -48,13 +49,13 @@ keym = [
KEYJAR = build_keyjar(keys)
IKEYJAR = build_keyjar(keys)
-IKEYJAR.import_jwks(IKEYJAR.export_jwks(private=True), "issuer")
+IKEYJAR = store_under_other_id(IKEYJAR, "", "issuer", True)
del IKEYJAR[""]
KEYJARS = {}
for iss in ["A", "B", "C"]:
_kj = build_keyjar(keym)
- _kj.import_jwks(_kj.export_jwks(private=True), iss)
+ _kj = store_under_other_id(_kj, "", iss, True)
del _kj[""]
KEYJARS[iss] = _kj
diff --git a/tests/test_05_oauth2.py b/tests/test_05_oauth2.py
index fc187db..2cf892c 100644
--- a/tests/test_05_oauth2.py
+++ b/tests/test_05_oauth2.py
@@ -8,6 +8,7 @@ from cryptojwt.key_jar import build_keyjar
from idpyoidc import verified_claim_name
from idpyoidc.exception import MissingRequiredAttribute
+from idpyoidc.key_import import store_under_other_id
from idpyoidc.message import DecodeError
from idpyoidc.message import json_deserializer
from idpyoidc.message import json_serializer
@@ -44,10 +45,10 @@ keym = [
]
KEYJAR = build_keyjar(keys)
-KEYJAR.import_jwks(KEYJAR.export_jwks(private=True), "issuer")
+KEYJAR = store_under_other_id(KEYJAR,"", "issuer", True)
IKEYJAR = build_keyjar(keys)
-IKEYJAR.import_jwks(IKEYJAR.export_jwks(private=True), "issuer")
+IKEYJAR = store_under_other_id(IKEYJAR, "", "issuer", True)
del IKEYJAR[""]
diff --git a/tests/test_07_session.py b/tests/test_07_session.py
index 94cbebd..b380635 100644
--- a/tests/test_07_session.py
+++ b/tests/test_07_session.py
@@ -10,6 +10,8 @@ from cryptojwt.key_jar import init_key_jar
from idpyoidc.exception import MessageException
from idpyoidc.exception import NotForMe
+from idpyoidc.key_import import import_jwks_as_json
+from idpyoidc.key_import import import_jwks_from_file
from idpyoidc.message.oidc import Claims
from idpyoidc.message.oidc import ClaimsRequest
from idpyoidc.message.oidc import IdToken
@@ -64,8 +66,8 @@ ISS_KEY = init_key_jar(
issuer_id=ISS,
)
-ISS_KEY.import_jwks_as_json(open(full_path("pub_client.jwks")).read(), CLIENT_ID)
-CLI_KEY.import_jwks_as_json(open(full_path("pub_iss.jwks")).read(), ISS)
+ISS_KEY = import_jwks_from_file(ISS_KEY, full_path("pub_client.jwks"), CLIENT_ID)
+CLI_KEY = import_jwks_from_file(CLI_KEY, full_path("pub_iss.jwks"), ISS)
class TestEndSessionResponse(object):
diff --git a/tests/test_08_transform.py b/tests/test_08_transform.py
index 71c83d9..33a2e14 100644
--- a/tests/test_08_transform.py
+++ b/tests/test_08_transform.py
@@ -4,12 +4,12 @@ import pytest
from cryptojwt.utils import importer
from idpyoidc.client.claims.oidc import Claims as OIDC_Claims
-from idpyoidc.client.claims.transform import create_registration_request
-from idpyoidc.client.claims.transform import preferred_to_registered
-from idpyoidc.client.claims.transform import supported_to_preferred
from idpyoidc.message.oidc import APPLICATION_TYPE_WEB
from idpyoidc.message.oidc import ProviderConfigurationResponse
from idpyoidc.message.oidc import RegistrationRequest
+from idpyoidc.transform import create_registration_request
+from idpyoidc.transform import preferred_to_registered
+from idpyoidc.transform import supported_to_preferred
class TestTransform:
@@ -42,117 +42,114 @@ class TestTransform:
def test_supported(self):
# These are all the available configuration parameters
- assert set(self.supported.keys()) == {
- "acr_values_supported",
- "application_type",
- "backchannel_logout_session_required",
- "backchannel_logout_supported",
- "backchannel_logout_uri",
- "callback_uris",
- "client_id",
- "client_name",
- "client_secret",
- "client_uri",
- "contacts",
- "default_max_age",
- "encrypt_id_token_supported",
- "encrypt_request_object_supported",
- "encrypt_userinfo_supported",
- "frontchannel_logout_session_required",
- "frontchannel_logout_supported",
- "frontchannel_logout_uri",
- "id_token_encryption_alg_values_supported",
- "id_token_encryption_enc_values_supported",
- "id_token_signing_alg_values_supported",
- "initiate_login_uri",
- "jwks",
- "jwks_uri",
- "logo_uri",
- "policy_uri",
- "post_logout_redirect_uris",
- "redirect_uris",
- "request_object_encryption_alg_values_supported",
- "request_object_encryption_enc_values_supported",
- "request_object_signing_alg_values_supported",
- "request_parameter",
- "request_parameter_supported",
- "request_uri_parameter_supported",
- "request_uris",
- "requests_dir",
- "require_auth_time",
- "response_modes_supported",
- "response_types_supported",
- "scopes_supported",
- "sector_identifier_uri",
- "subject_types_supported",
- # 'token_endpoint_auth_method',
- "token_endpoint_auth_methods_supported",
- "token_endpoint_auth_signing_alg_values_supported",
- "tos_uri",
- "userinfo_encryption_alg_values_supported",
- "userinfo_encryption_enc_values_supported",
- "userinfo_signing_alg_values_supported",
- }
+ assert set(self.supported.keys()) == {'acr_values_supported',
+ 'application_type',
+ 'backchannel_logout_session_required',
+ 'backchannel_logout_supported',
+ 'backchannel_logout_uri',
+ 'callback_uris',
+ 'client_id',
+ 'client_name',
+ 'client_secret',
+ 'client_uri',
+ 'code_challenge_methods_supported',
+ 'contacts',
+ 'default_max_age',
+ 'encrypt_id_token_supported',
+ 'encrypt_request_object_supported',
+ 'encrypt_userinfo_supported',
+ 'frontchannel_logout_session_required',
+ 'frontchannel_logout_supported',
+ 'frontchannel_logout_uri',
+ 'id_token_encryption_alg_values_supported',
+ 'id_token_encryption_enc_values_supported',
+ 'id_token_signing_alg_values_supported',
+ 'initiate_login_uri',
+ 'jwks',
+ 'jwks_uri',
+ 'logo_uri',
+ 'policy_uri',
+ 'post_logout_redirect_uris',
+ 'redirect_uris',
+ 'request_object_encryption_alg_values_supported',
+ 'request_object_encryption_enc_values_supported',
+ 'request_object_signing_alg_values_supported',
+ 'request_parameter',
+ 'request_parameter_supported',
+ 'request_uri_parameter_supported',
+ 'request_uris',
+ 'requests_dir',
+ 'require_auth_time',
+ 'response_modes_supported',
+ 'response_types_supported',
+ 'scopes_supported',
+ 'sector_identifier_uri',
+ 'subject_types_supported',
+ 'token_endpoint_auth_methods_supported',
+ 'token_endpoint_auth_signing_alg_values_supported',
+ 'tos_uri',
+ 'userinfo_encryption_alg_values_supported',
+ 'userinfo_encryption_enc_values_supported',
+ 'userinfo_signing_alg_values_supported'}
def test_oidc_setup(self):
# This is OP specified stuff
assert set(ProviderConfigurationResponse.c_param.keys()).difference(
set(self.supported)
) == {
- "authorization_endpoint",
- "check_session_iframe",
- "claim_types_supported",
- "claims_locales_supported",
- "claims_parameter_supported",
- "claims_supported",
- "display_values_supported",
- "end_session_endpoint",
- "error",
- "error_description",
- "error_uri",
- "grant_types_supported",
- "issuer",
- "op_policy_uri",
- "op_tos_uri",
- "registration_endpoint",
- "require_request_uri_registration",
- "service_documentation",
- "token_endpoint",
- "ui_locales_supported",
- "userinfo_endpoint",
- "code_challenge_methods_supported",
- }
+ "authorization_endpoint",
+ "check_session_iframe",
+ "claim_types_supported",
+ "claims_locales_supported",
+ "claims_parameter_supported",
+ "claims_supported",
+ "display_values_supported",
+ "end_session_endpoint",
+ "error",
+ "error_description",
+ "error_uri",
+ "grant_types_supported",
+ "issuer",
+ "op_policy_uri",
+ "op_tos_uri",
+ "registration_endpoint",
+ "require_request_uri_registration",
+ "service_documentation",
+ "token_endpoint",
+ "ui_locales_supported",
+ "userinfo_endpoint",
+ }
# parameters that are not mapped against what the OP's provider info says
assert set(self.supported).difference(
set(ProviderConfigurationResponse.c_param.keys())
) == {
- "application_type",
- "backchannel_logout_uri",
- "callback_uris",
- "client_id",
- "client_name",
- "client_secret",
- "client_uri",
- "contacts",
- "default_max_age",
- "encrypt_id_token_supported",
- "encrypt_request_object_supported",
- "encrypt_userinfo_supported",
- "frontchannel_logout_uri",
- "initiate_login_uri",
- "jwks",
- "logo_uri",
- "policy_uri",
- "post_logout_redirect_uris",
- "redirect_uris",
- "request_parameter",
- "request_uris",
- "requests_dir",
- "require_auth_time",
- "sector_identifier_uri",
- "tos_uri",
- }
+ "application_type",
+ "backchannel_logout_uri",
+ "callback_uris",
+ "client_id",
+ "client_name",
+ "client_secret",
+ "client_uri",
+ "contacts",
+ "default_max_age",
+ "encrypt_id_token_supported",
+ "encrypt_request_object_supported",
+ "encrypt_userinfo_supported",
+ "frontchannel_logout_uri",
+ "initiate_login_uri",
+ "jwks",
+ "logo_uri",
+ "policy_uri",
+ "post_logout_redirect_uris",
+ "redirect_uris",
+ "request_parameter",
+ "request_uris",
+ "requests_dir",
+ "require_auth_time",
+ "sector_identifier_uri",
+ "tos_uri",
+ }
claims = OIDC_Claims()
# No input from the IDP so info is absent
@@ -173,6 +170,7 @@ class TestTransform:
"request_object_encryption_alg_values_supported",
"request_object_encryption_enc_values_supported",
"request_object_signing_alg_values_supported",
+ "request_parameter_supported",
"response_modes_supported",
"response_types_supported",
"scopes_supported",
@@ -245,27 +243,24 @@ class TestTransform:
)
# These are the claims that has default values
- assert set(claims.prefer.keys()) == {
- "application_type",
- "default_max_age",
- "encrypt_request_object_supported",
- "encrypt_userinfo_supported",
- "id_token_encryption_alg_values_supported",
- "id_token_encryption_enc_values_supported",
- "id_token_signing_alg_values_supported",
- "request_object_encryption_alg_values_supported",
- "request_object_encryption_enc_values_supported",
- "request_object_signing_alg_values_supported",
- "response_modes_supported",
- "response_types_supported",
- "scopes_supported",
- "subject_types_supported",
- "token_endpoint_auth_methods_supported",
- "token_endpoint_auth_signing_alg_values_supported",
- "userinfo_encryption_alg_values_supported",
- "userinfo_encryption_enc_values_supported",
- "userinfo_signing_alg_values_supported",
- }
+ assert set(claims.prefer.keys()) == {'application_type',
+ 'default_max_age',
+ 'id_token_encryption_alg_values_supported',
+ 'id_token_encryption_enc_values_supported',
+ 'id_token_signing_alg_values_supported',
+ 'request_object_encryption_alg_values_supported',
+ 'request_object_encryption_enc_values_supported',
+ 'request_object_signing_alg_values_supported',
+ 'request_parameter_supported',
+ 'response_modes_supported',
+ 'response_types_supported',
+ 'scopes_supported',
+ 'subject_types_supported',
+ 'token_endpoint_auth_methods_supported',
+ 'token_endpoint_auth_signing_alg_values_supported',
+ 'userinfo_encryption_alg_values_supported',
+ 'userinfo_encryption_enc_values_supported',
+ 'userinfo_signing_alg_values_supported'}
# least common denominator
# The RP supports less than the OP
@@ -362,10 +357,13 @@ class TestTransform2:
"client_name",
"contacts",
"default_max_age",
+ 'encrypt_request_object_supported',
+ 'encrypt_userinfo_supported',
"id_token_signed_response_alg",
"logo_uri",
"redirect_uris",
"request_object_signing_alg",
+ 'request_parameter_supported',
"response_types",
"response_modes", # non-standard
"subject_type",
@@ -402,29 +400,28 @@ class TestTransform2:
registration_response=registration_response,
)
- assert set(to_use.keys()) == {
- "application_type",
- "client_name",
- "contacts",
- "default_max_age",
- "encrypt_request_object_supported",
- "encrypt_userinfo_supported",
- "id_token_signed_response_alg",
- "jwks_uri",
- "logo_uri",
- "redirect_uris",
- "request_object_signing_alg",
- "request_uris",
- "response_types",
- "response_modes", # non-standard
- "scope",
- "sector_identifier_uri",
- "subject_type",
- "token_endpoint_auth_method",
- "token_endpoint_auth_signing_alg",
- "userinfo_encrypted_response_alg",
- "userinfo_encrypted_response_enc",
- "userinfo_signed_response_alg",
- }
+ assert set(to_use.keys()) == {'application_type',
+ 'client_name',
+ 'contacts',
+ 'default_max_age',
+ 'id_token_signed_response_alg',
+ 'jwks_uri',
+ 'logo_uri',
+ 'redirect_uris',
+ 'request_object_signing_alg',
+ 'request_uris',
+ 'encrypt_userinfo_supported',
+ 'request_parameter_supported',
+ 'encrypt_request_object_supported',
+ 'response_modes',
+ 'response_types',
+ 'scope',
+ 'sector_identifier_uri',
+ 'subject_type',
+ 'token_endpoint_auth_method',
+ 'token_endpoint_auth_signing_alg',
+ 'userinfo_encrypted_response_alg',
+ 'userinfo_encrypted_response_enc',
+ 'userinfo_signed_response_alg'}
assert to_use["subject_type"] == "pairwise"
diff --git a/tests/test_09_work_condition.py b/tests/test_09_work_condition.py
index 957d857..34dd006 100644
--- a/tests/test_09_work_condition.py
+++ b/tests/test_09_work_condition.py
@@ -4,9 +4,10 @@ import pytest as pytest
from cryptojwt.utils import importer
from idpyoidc.client.claims.oidc import Claims
-from idpyoidc.client.claims.transform import create_registration_request
-from idpyoidc.client.claims.transform import preferred_to_registered
-from idpyoidc.client.claims.transform import supported_to_preferred
+from idpyoidc.message.oidc import RegistrationRequest
+from idpyoidc.transform import create_registration_request
+from idpyoidc.transform import preferred_to_registered
+from idpyoidc.transform import supported_to_preferred
from idpyoidc.message.oidc import APPLICATION_TYPE_WEB
KEYSPEC = [
@@ -168,14 +169,14 @@ class TestWorkEnvironment:
"acr_values_supported": ["mfa"],
}
- pref = self.claims.prefer = supported_to_preferred(
+ self.claims.prefer = supported_to_preferred(
supported=self.supported,
preference=self.claims.prefer,
base_url="https://example.com",
info=provider_info_response,
)
- registration_request = create_registration_request(self.claims.prefer, self.supported)
+ registration_request = self.claims.get_client_metadata(metadata_schema=RegistrationRequest)
assert set(registration_request.keys()) == {
"application_type",
@@ -230,8 +231,8 @@ class TestWorkEnvironment:
"client_secret",
"contacts",
"default_max_age",
- "encrypt_request_object_supported",
- "encrypt_userinfo_supported",
+ 'encrypt_userinfo_supported',
+ 'encrypt_request_object_supported',
"id_token_signed_response_alg",
"jwks",
"jwks_uri",
@@ -239,6 +240,7 @@ class TestWorkEnvironment:
"redirect_uris",
"request_object_signing_alg",
"request_uris",
+ 'request_parameter_supported',
"response_modes",
"response_types",
"scope",
@@ -313,7 +315,7 @@ class TestWorkEnvironment:
info=provider_info_response,
)
- registration_request = create_registration_request(self.claims.prefer, self.supported)
+ registration_request = self.claims.get_client_metadata(metadata_schema=RegistrationRequest)
assert set(registration_request.keys()) == {
"application_type",
@@ -376,6 +378,7 @@ class TestWorkEnvironment:
"logo_uri",
"redirect_uris",
"request_object_signing_alg",
+ 'request_parameter_supported',
"request_uris",
"response_modes",
"response_types",
diff --git a/tests/test_11_impexp.py b/tests/test_11_impexp.py
index 3f525b1..14e1e4e 100644
--- a/tests/test_11_impexp.py
+++ b/tests/test_11_impexp.py
@@ -94,3 +94,27 @@ def test_flush():
assert len(b.bundles) == 2
for kb in b.bundles:
assert isinstance(kb, KeyBundle)
+
+
+def test_dict():
+ b = ImpExpTest()
+ b.string = "foo"
+ b.list = ["a", "b", "c"]
+ b.dict = {"a": 1, "b": 2}
+ b.message = {
+ "scope": "openid",
+ "redirect_uri": "https://example.com/cb",
+ "response_type": "code",
+ "client_id": "abcdefg",
+ }
+
+ dump = b.dump()
+
+ b.flush()
+
+ b.load(dump)
+
+ assert b.string == "foo"
+ assert b.list == ["a", "b", "c"]
+ assert b.dict == {"a": 1, "b": 2}
+ assert isinstance(b.message, AuthorizationRequest)
diff --git a/tests/test_14_read_only_list_file.py b/tests/test_14_read_only_list_file.py
index 2abdf9e..fd30b9d 100644
--- a/tests/test_14_read_only_list_file.py
+++ b/tests/test_14_read_only_list_file.py
@@ -24,6 +24,4 @@ def test_read_only_list_file():
fp.write(line + '\n')
# sleep(2)
- # assert _read_only.is_changed(FILE_NAME) is True
assert set(_read_only) == {"one", "two", "three"}
- assert _read_only[-1] == "three"
\ No newline at end of file
diff --git a/tests/test_20_config.py b/tests/test_20_config.py
index ad737ec..3f6b27a 100644
--- a/tests/test_20_config.py
+++ b/tests/test_20_config.py
@@ -172,14 +172,12 @@ def test_init_crypto_keys():
"keys": {
"private_path": "private/cookie_jwks.json",
"key_defs": [
- {"type": "OCT", "use": ["enc"], "kid": "enc"},
- {"type": "OCT", "use": ["sig"], "kid": "sig"},
+ {"type": "OCT", "use": ["enc"], "kid": "key", "bytes": 32},
],
"read_only": False,
}
}
_res = init_encrypter(_conf)
assert _res["conf"]["class"] == DEFAULT_CRYPTO
- assert set(_res["conf"]["kwargs"].keys()) == {"password", "salt"}
- assert "password" in _res["conf"]["kwargs"]
- assert "salt" in _res["conf"]["kwargs"]
+ assert set(_res["conf"]["kwargs"].keys()) == {"key", "salt"}
+ assert len(_res["conf"]["kwargs"]["salt"]) == 16
diff --git a/tests/test_21_abfile_no_cache.py b/tests/test_21_abfile_no_cache.py
new file mode 100644
index 0000000..cfe7e86
--- /dev/null
+++ b/tests/test_21_abfile_no_cache.py
@@ -0,0 +1,116 @@
+import os
+import shutil
+
+import pytest
+
+from idpyoidc.impexp import ImpExp
+from idpyoidc.storage.abfile_no_cache import AbstractFileSystemNoCache
+
+BASEDIR = os.path.abspath(os.path.dirname(__file__))
+
+
+def full_path(local_file):
+ return os.path.join(BASEDIR, local_file)
+
+
+CLIENT_1 = {
+ "client_secret": "hemligtkodord",
+ "redirect_uris": [["https://example.com/cb", ""]],
+ "client_salt": "salted",
+ "token_endpoint_auth_method": "client_secret_post",
+ "response_types": ["code", "token"],
+}
+
+CLIENT_2 = {
+ "client_secret": "spraket",
+ "redirect_uris": [["https://app1.example.net/foo", ""], ["https://app2.example.net/bar", ""]],
+ "response_types": ["code"],
+}
+
+
+class ImpExpTest(ImpExp):
+ parameter = {
+ "string": "",
+ "list": [],
+ "dict": "DICT_TYPE",
+ }
+
+
+class TestAFS(object):
+ @pytest.fixture(autouse=True)
+ def setup(self):
+ filename = full_path("afs")
+ if os.path.isdir(filename):
+ shutil.rmtree(filename)
+
+ def test_create_cdb(self):
+ abf = AbstractFileSystemNoCache(fdir=full_path("afs"), value_conv="idpyoidc.util.JSON")
+
+ # add a client
+
+ abf["client_1"] = CLIENT_1
+
+ assert list(abf.keys()) == ["client_1"]
+
+ # add another one
+
+ abf["client_2"] = CLIENT_2
+
+ assert set(abf.keys()) == {"client_1", "client_2"}
+
+ def test_read_cdb(self):
+ abf = AbstractFileSystemNoCache(fdir=full_path("afs"), value_conv="idpyoidc.util.JSON")
+ # add a client
+ abf["client_1"] = CLIENT_1
+ # add another one
+ abf["client_2"] = CLIENT_2
+
+ afs_2 = AbstractFileSystemNoCache(fdir=full_path("afs"), value_conv="idpyoidc.util.JSON")
+ assert set(afs_2.keys()) == {"client_1", "client_2"}
+
+ def test_dump_load_afs(self):
+ b = ImpExpTest()
+ b.string = "foo"
+ b.list = ["a", "b", "c"]
+ b.dict = AbstractFileSystemNoCache(fdir=full_path("afs"), value_conv="idpyoidc.util.JSON")
+
+ # add a client
+ b.dict["client_1"] = CLIENT_1
+ # add another one
+ b.dict["client_2"] = CLIENT_2
+
+ dump = b.dump()
+
+ b_copy = ImpExpTest().load(dump)
+ assert b_copy
+ assert isinstance(b_copy.dict, AbstractFileSystemNoCache)
+ assert set(b_copy.dict.keys()) == {"client_1", "client_2"}
+
+ def test_dump_load_dict(self):
+ b = ImpExpTest()
+ b.string = "foo"
+ b.list = ["a", "b", "c"]
+ b.dict = {"a": 1, "b": 2, "c": 3}
+
+ dump = b.dump()
+
+ b_copy = ImpExpTest().load(dump)
+ assert b_copy
+ assert isinstance(b_copy.dict, dict)
+
+ def test_get(self):
+ abf = AbstractFileSystemNoCache(fdir=full_path("afs"), value_conv="idpyoidc.util.JSON")
+ # add a client
+ abf["client_1"] = CLIENT_1
+ # add another one
+ abf["client_2"] = CLIENT_2
+
+ val = abf["client_2"]
+ assert val == CLIENT_2
+
+ del abf["client_2"]
+
+ assert set(abf.keys()) == {"client_1"}
+
+ abf.clear()
+ assert set(abf.keys()) == set()
diff --git a/tests/test_client_02_entity.py b/tests/test_client_02_entity.py
index 369ef7f..0598146 100644
--- a/tests/test_client_02_entity.py
+++ b/tests/test_client_02_entity.py
@@ -39,7 +39,7 @@ class TestEntity:
assert _srv is None
def test_get_client_id(self):
- assert self.entity.get_service_context().get_preference("client_id") == "Number5"
+ assert self.entity.client_id == "Number5"
assert self.entity.get_attribute("client_id") == "Number5"
def test_get_service_by_endpoint_name(self):
diff --git a/tests/test_client_02b_entity_metadata.py b/tests/test_client_02b_entity_metadata.py
index 8f122a5..16002e4 100644
--- a/tests/test_client_02b_entity_metadata.py
+++ b/tests/test_client_02b_entity_metadata.py
@@ -74,6 +74,7 @@ def test_create_client():
"redirect_uris",
"request_object_signing_alg_values_supported",
"request_parameter",
+ "request_parameter_supported",
"response_modes_supported",
"response_types_supported",
"scopes_supported",
@@ -95,7 +96,7 @@ def test_create_client():
_conf_args = list(_context.collect_usage().keys())
assert _conf_args
- assert len(_conf_args) == 23
+ assert len(_conf_args) == 24
rr = set(RegistrationRequest.c_param.keys())
# The ones that are not defined and will therefore not appear in a registration request
d = rr.difference(set(_conf_args))
@@ -146,3 +147,28 @@ def test_create_client_jwks_uri():
client_config["jwks_uri"] = "https://rp.example.com/jwks_uri.json"
client = Entity(config=client_config)
assert client.get_service_context().get_preference("jwks_uri")
+
+
+def test_metadata():
+ client = Entity(config=CLIENT_CONFIG, client_type="oidc")
+ # With entity type
+ metadata = client.context.claims.get_client_metadata("openid_relying_party",
+ metadata_schema=RegistrationRequest)
+ assert set(metadata.keys()) == {"openid_relying_party"}
+ # Without entity type, no endpoints. Typical client
+ metadata = client.context.claims.get_client_metadata(metadata_schema=RegistrationRequest)
+ assert set(metadata.keys()) == {'application_type',
+ 'backchannel_logout_session_required',
+ 'backchannel_logout_uri',
+ 'contacts',
+ 'default_max_age',
+ 'grant_types',
+ 'id_token_signed_response_alg',
+ 'redirect_uris',
+ 'request_object_signing_alg',
+ 'response_modes',
+ 'response_types',
+ 'subject_type',
+ 'token_endpoint_auth_method',
+ 'token_endpoint_auth_signing_alg',
+ 'userinfo_signed_response_alg'}
diff --git a/tests/test_client_04_service.py b/tests/test_client_04_service.py
index 95e0934..2eec542 100644
--- a/tests/test_client_04_service.py
+++ b/tests/test_client_04_service.py
@@ -62,6 +62,7 @@ class TestService:
"jwks",
"redirect_uris",
"request_object_signing_alg",
+ 'request_parameter_supported',
"response_modes",
"response_types",
"scope",
diff --git a/tests/test_client_05_util.py b/tests/test_client_05_util.py
index 3a22416..057c954 100644
--- a/tests/test_client_05_util.py
+++ b/tests/test_client_05_util.py
@@ -7,6 +7,7 @@ from urllib.parse import urlsplit
import pytest
from idpyoidc.client.exception import WrongContentType
+from idpyoidc.client.util import get_content_type
from idpyoidc.client.util import get_deserialization_method
from idpyoidc.client.util import get_http_body
from idpyoidc.client.util import get_http_url
@@ -139,28 +140,35 @@ def test_verify_header():
def test_get_deserialization_method_json():
resp = FakeResponse("application/json")
- assert get_deserialization_method(resp) == "json"
+ ctype = get_content_type(resp)
+ assert get_deserialization_method(ctype) == "json"
resp = FakeResponse("application/json; charset=utf-8")
- assert get_deserialization_method(resp) == "json"
+ ctype = get_content_type(resp)
+ assert get_deserialization_method(ctype) == "json"
resp.headers["content-type"] = "application/jrd+json"
- assert get_deserialization_method(resp) == "json"
+ ctype = get_content_type(resp)
+ assert get_deserialization_method(ctype) == "json"
def test_get_deserialization_method_jwt():
resp = FakeResponse("application/jwt")
- assert get_deserialization_method(resp) == "jwt"
+ ctype = get_content_type(resp)
+ assert get_deserialization_method(ctype) == "jwt"
def test_get_deserialization_method_urlencoded():
resp = FakeResponse(URL_ENCODED)
- assert get_deserialization_method(resp) == "urlencoded"
+ ctype = get_content_type(resp)
+ assert get_deserialization_method(ctype) == "urlencoded"
def test_get_deserialization_method_text():
resp = FakeResponse("text/html")
- assert get_deserialization_method(resp) == ""
+ ctype = get_content_type(resp)
+ assert get_deserialization_method(ctype) == ""
resp = FakeResponse("text/plain")
- assert get_deserialization_method(resp) == ""
+ ctype = get_content_type(resp)
+ assert get_deserialization_method(ctype) == ""
diff --git a/tests/test_client_06_client_authn.py b/tests/test_client_06_client_authn.py
index 52fb95c..6a42ae5 100644
--- a/tests/test_client_06_client_authn.py
+++ b/tests/test_client_06_client_authn.py
@@ -3,26 +3,28 @@ import os
import pytest
from cryptojwt.exception import MissingKey
-from cryptojwt.jws.jws import JWS
from cryptojwt.jws.jws import factory
+from cryptojwt.jws.jws import JWS
from cryptojwt.jwt import JWT
from cryptojwt.key_bundle import KeyBundle
-from cryptojwt.key_jar import KeyJar
from cryptojwt.key_jar import init_key_jar
+from cryptojwt.key_jar import KeyJar
from idpyoidc.claims import Claims
+from idpyoidc.client.client_auth import assertion_jwt
from idpyoidc.client.client_auth import AuthnFailure
+from idpyoidc.client.client_auth import bearer_auth
from idpyoidc.client.client_auth import BearerBody
from idpyoidc.client.client_auth import BearerHeader
from idpyoidc.client.client_auth import ClientSecretBasic
from idpyoidc.client.client_auth import ClientSecretJWT
from idpyoidc.client.client_auth import ClientSecretPost
from idpyoidc.client.client_auth import PrivateKeyJWT
-from idpyoidc.client.client_auth import assertion_jwt
-from idpyoidc.client.client_auth import bearer_auth
from idpyoidc.client.client_auth import valid_service_context
from idpyoidc.client.entity import Entity
from idpyoidc.defaults import JWT_BEARER
+from idpyoidc.key_import import add_kb
+from idpyoidc.key_import import import_jwks
from idpyoidc.message import Message
from idpyoidc.message.oauth2 import AccessTokenRequest
from idpyoidc.message.oauth2 import AccessTokenResponse
@@ -88,12 +90,13 @@ def test_quote():
)
assert (
- http_args["headers"]["Authorization"] == "Basic "
- "Nzk2ZDhmYWUtYTQyZi00ZTRmLWFiMjUtZDYyMDViNmQ0ZmEyOk1LRU0vQTdQa243SnVVMExBY3h5SFZLdndkY3pzdWdhUFUwQmllTGI0Q2JRQWdRait5cGNhbkZPQ2IwL0ZBNWg="
+ http_args["headers"]["Authorization"] == "Basic "
+ "Nzk2ZDhmYWUtYTQyZi00ZTRmLWFiMjUtZDYyMDViNmQ0ZmEyOk1LRU0vQTdQa243SnVVMExBY3h5SFZLdndkY3pzdWdhUFUwQmllTGI0Q2JRQWdRait5cGNhbkZPQ2IwL0ZBNWg="
)
class TestClientSecretBasic(object):
+
def test_construct(self, entity):
_service = entity.get_service("")
request = _service.construct(
@@ -127,6 +130,7 @@ class TestClientSecretBasic(object):
class TestBearerHeader(object):
+
def test_construct(self, entity):
request = ResourceRequest(access_token="Sesame")
bh = BearerHeader()
@@ -196,6 +200,7 @@ class TestBearerHeader(object):
class TestBearerBody(object):
+
def test_construct(self, entity):
_token_service = entity.get_service("")
request = ResourceRequest(access_token="Sesame")
@@ -252,6 +257,7 @@ class TestBearerBody(object):
class TestClientSecretPost(object):
+
def test_construct(self, entity):
_token_service = entity.get_service("")
request = _token_service.construct(
@@ -292,6 +298,7 @@ class TestClientSecretPost(object):
class TestPrivateKeyJWT(object):
+
def test_construct(self, entity):
token_service = entity.get_service("")
kb_rsa = KeyBundle(
@@ -320,8 +327,8 @@ class TestPrivateKeyJWT(object):
# Receiver
_kj = KeyJar()
- _kj.import_jwks(_keyjar.export_jwks(), issuer_id=_context.get_client_id())
- _kj.add_kb(_context.get_client_id(), kb_rsa)
+ _kj = import_jwks(_kj, _keyjar.export_jwks(), _context.get_client_id())
+ _kj = add_kb(_kj, kb_rsa, _context.get_client_id())
jso = JWT(key_jar=_kj).unpack(cas)
assert _eq(jso.keys(), ["aud", "iss", "sub", "jti", "exp", "iat"])
# assert _jwt.headers == {'alg': 'RS256'}
@@ -350,6 +357,7 @@ class TestPrivateKeyJWT(object):
class TestClientSecretJWT_TE(object):
+
def test_client_secret_jwt(self, entity):
_service_context = entity.get_context()
_service_context.token_endpoint = "https://example.com/token"
@@ -487,6 +495,7 @@ class TestClientSecretJWT_TE(object):
class TestClientSecretJWT_UI(object):
+
def test_client_secret_jwt(self, entity):
access_token_service = entity.get_service("")
@@ -526,6 +535,7 @@ class TestClientSecretJWT_UI(object):
class TestValidClientInfo(object):
+
def test_valid_service_context(self, entity):
_service_context = entity.get_context()
diff --git a/tests/test_client_16_util.py b/tests/test_client_16_util.py
index a09d65a..57c4bf6 100644
--- a/tests/test_client_16_util.py
+++ b/tests/test_client_16_util.py
@@ -12,6 +12,7 @@ from idpyoidc.client import util
from idpyoidc.client.exception import WrongContentType
from idpyoidc.client.util import JSON_ENCODED
from idpyoidc.client.util import URL_ENCODED
+from idpyoidc.client.util import get_content_type
from idpyoidc.client.util import get_deserialization_method
from idpyoidc.message.oauth2 import AccessTokenRequest
from idpyoidc.message.oauth2 import AuthorizationRequest