scim2-client 0.4.2__tar.gz → 0.4.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scim2_client-0.4.2 → scim2_client-0.4.3}/PKG-INFO +1 -1
- {scim2_client-0.4.2 → scim2_client-0.4.3}/doc/changelog.rst +6 -1
- {scim2_client-0.4.2 → scim2_client-0.4.3}/pyproject.toml +1 -1
- {scim2_client-0.4.2 → scim2_client-0.4.3}/scim2_client/client.py +61 -41
- {scim2_client-0.4.2 → scim2_client-0.4.3}/uv.lock +1 -1
- {scim2_client-0.4.2 → scim2_client-0.4.3}/.github/FUNDING.yml +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/.github/workflows/release.yml +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/.github/workflows/tests.yaml +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/.gitignore +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/.pre-commit-config.yaml +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/.readthedocs.yml +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/LICENSE.md +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/README.md +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/doc/__init__.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/doc/conf.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/doc/contributing.rst +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/doc/index.rst +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/doc/reference.rst +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/doc/tutorial.rst +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/scim2_client/__init__.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/scim2_client/engines/__init__.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/scim2_client/engines/httpx.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/scim2_client/engines/werkzeug.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/scim2_client/errors.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/scim2_client/py.typed +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/__init__.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/conftest.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/engines/__init__.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/engines/test_httpx.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/engines/test_werkzeug.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/test_create.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/test_delete.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/test_query.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/test_replace.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/test_search.py +0 -0
- {scim2_client-0.4.2 → scim2_client-0.4.3}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: scim2-client
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Pythonically build SCIM requests and parse SCIM responses
|
|
5
5
|
Project-URL: documentation, https://scim2-client.readthedocs.io
|
|
6
6
|
Project-URL: repository, https://github.com/python-scim/scim2-client
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
=========
|
|
3
3
|
|
|
4
|
+
[0.4.3] - 2024-12-06
|
|
5
|
+
--------------------
|
|
6
|
+
|
|
7
|
+
- Add :paramref:`~scim2_client.SCIMClient.check_response_content_type` and
|
|
8
|
+
:paramref:`~scim2_client.SCIMClient.check_response_status_codes` parameters.
|
|
9
|
+
|
|
4
10
|
[0.4.2] - 2024-12-03
|
|
5
11
|
--------------------
|
|
6
12
|
|
|
@@ -8,7 +14,6 @@ Added
|
|
|
8
14
|
^^^^^
|
|
9
15
|
- :class:`~scim2_client.client.BaseSyncSCIMClient.discover` has parameters to select which objects to discover.
|
|
10
16
|
|
|
11
|
-
|
|
12
17
|
[0.4.1] - 2024-12-02
|
|
13
18
|
--------------------
|
|
14
19
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scim2-client"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.3"
|
|
8
8
|
description = "Pythonically build SCIM requests and parse SCIM responses"
|
|
9
9
|
authors = [{name="Yaal Coop", email="contact@yaal.coop"}]
|
|
10
10
|
license = {file = "LICENSE.md"}
|
|
@@ -60,6 +60,8 @@ class SCIMClient:
|
|
|
60
60
|
This value can be overwritten in methods.
|
|
61
61
|
:param check_response_payload: Whether to validate that the response payloads are valid.
|
|
62
62
|
If set, the raw payload will be returned. This value can be overwritten in methods.
|
|
63
|
+
:param check_response_content_type: Whether to validate that the response content types are valid.
|
|
64
|
+
:param check_response_status_codes: Whether to validate that the response status codes are valid.
|
|
63
65
|
:param raise_scim_errors: If :data:`True` and the server returned an
|
|
64
66
|
:class:`~scim2_models.Error` object during a request, a :class:`~scim2_client.SCIMResponseErrorObject`
|
|
65
67
|
exception will be raised. If :data:`False` the error object is returned. This value can be overwritten in methods.
|
|
@@ -156,6 +158,8 @@ class SCIMClient:
|
|
|
156
158
|
service_provider_config: Optional[ServiceProviderConfig] = None,
|
|
157
159
|
check_request_payload: bool = True,
|
|
158
160
|
check_response_payload: bool = True,
|
|
161
|
+
check_response_content_type: bool = True,
|
|
162
|
+
check_response_status_codes: bool = True,
|
|
159
163
|
raise_scim_errors: bool = True,
|
|
160
164
|
):
|
|
161
165
|
self.resource_models = tuple(resource_models or [])
|
|
@@ -163,6 +167,8 @@ class SCIMClient:
|
|
|
163
167
|
self.service_provider_config = service_provider_config
|
|
164
168
|
self.check_request_payload = check_request_payload
|
|
165
169
|
self.check_response_payload = check_response_payload
|
|
170
|
+
self.check_response_content_type = check_response_content_type
|
|
171
|
+
self.check_response_status_codes = check_response_status_codes
|
|
166
172
|
self.raise_scim_errors = raise_scim_errors
|
|
167
173
|
|
|
168
174
|
def get_resource_model(self, name: str) -> Optional[type[Resource]]:
|
|
@@ -220,6 +226,31 @@ class SCIMClient:
|
|
|
220
226
|
if model not in CONFIG_RESOURCES
|
|
221
227
|
]
|
|
222
228
|
|
|
229
|
+
def _check_status_codes(
|
|
230
|
+
self, status_code: int, expected_status_codes: Optional[list[int]]
|
|
231
|
+
):
|
|
232
|
+
if (
|
|
233
|
+
self.check_response_status_codes
|
|
234
|
+
and expected_status_codes
|
|
235
|
+
and status_code not in expected_status_codes
|
|
236
|
+
):
|
|
237
|
+
raise UnexpectedStatusCode(status_code)
|
|
238
|
+
|
|
239
|
+
def _check_content_types(self, headers: dict):
|
|
240
|
+
# Interoperability considerations: The "application/scim+json" media
|
|
241
|
+
# type is intended to identify JSON structure data that conforms to
|
|
242
|
+
# the SCIM protocol and schema specifications. Older versions of
|
|
243
|
+
# SCIM are known to informally use "application/json".
|
|
244
|
+
# https://datatracker.ietf.org/doc/html/rfc7644.html#section-8.1
|
|
245
|
+
|
|
246
|
+
actual_content_type = headers.get("content-type", "").split(";").pop(0)
|
|
247
|
+
expected_response_content_types = ("application/scim+json", "application/json")
|
|
248
|
+
if (
|
|
249
|
+
self.check_response_content_type
|
|
250
|
+
and actual_content_type not in expected_response_content_types
|
|
251
|
+
):
|
|
252
|
+
raise UnexpectedContentType(content_type=actual_content_type)
|
|
253
|
+
|
|
223
254
|
def check_response(
|
|
224
255
|
self,
|
|
225
256
|
payload: Optional[dict],
|
|
@@ -234,19 +265,8 @@ class SCIMClient:
|
|
|
234
265
|
if raise_scim_errors is None:
|
|
235
266
|
raise_scim_errors = self.raise_scim_errors
|
|
236
267
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
# Interoperability considerations: The "application/scim+json" media
|
|
241
|
-
# type is intended to identify JSON structure data that conforms to
|
|
242
|
-
# the SCIM protocol and schema specifications. Older versions of
|
|
243
|
-
# SCIM are known to informally use "application/json".
|
|
244
|
-
# https://datatracker.ietf.org/doc/html/rfc7644.html#section-8.1
|
|
245
|
-
|
|
246
|
-
actual_content_type = headers.get("content-type", "").split(";").pop(0)
|
|
247
|
-
expected_response_content_types = ("application/scim+json", "application/json")
|
|
248
|
-
if actual_content_type not in expected_response_content_types:
|
|
249
|
-
raise UnexpectedContentType(content_type=actual_content_type)
|
|
268
|
+
self._check_status_codes(status_code, expected_status_codes)
|
|
269
|
+
self._check_content_types(headers)
|
|
250
270
|
|
|
251
271
|
# In addition to returning an HTTP response code, implementers MUST return
|
|
252
272
|
# the errors in the body of the response in a JSON format
|
|
@@ -560,11 +580,11 @@ class BaseSyncSCIMClient(SCIMClient):
|
|
|
560
580
|
|
|
561
581
|
:param resource: The resource to create
|
|
562
582
|
If is a :data:`dict`, the resource type will be guessed from the schema.
|
|
563
|
-
:param check_request_payload: If set, overwrites :paramref
|
|
564
|
-
:param check_response_payload: If set, overwrites :paramref
|
|
583
|
+
:param check_request_payload: If set, overwrites :paramref:`~scim2_client.SCIMClient.check_request_payload`.
|
|
584
|
+
:param check_response_payload: If set, overwrites :paramref:`~scim2_client.SCIMClient.check_response_payload`.
|
|
565
585
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
566
586
|
If :data:`None` any status code is accepted.
|
|
567
|
-
:param raise_scim_errors: If set, overwrites :paramref
|
|
587
|
+
:param raise_scim_errors: If set, overwrites :paramref:`~scim2_client.SCIMClient.raise_scim_errors`.
|
|
568
588
|
:param kwargs: Additional parameters passed to the underlying HTTP request
|
|
569
589
|
library.
|
|
570
590
|
|
|
@@ -612,11 +632,11 @@ class BaseSyncSCIMClient(SCIMClient):
|
|
|
612
632
|
:param resource_model: A :class:`~scim2_models.Resource` subtype or :data:`None`
|
|
613
633
|
:param id: The SCIM id of an object to get, or :data:`None`
|
|
614
634
|
:param search_request: An object detailing the search query parameters.
|
|
615
|
-
:param check_request_payload: If set, overwrites :paramref:`SCIMClient.check_request_payload`.
|
|
616
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
635
|
+
:param check_request_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_request_payload`.
|
|
636
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
617
637
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
618
638
|
If :data:`None` any status code is accepted.
|
|
619
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
639
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
620
640
|
:param kwargs: Additional parameters passed to the underlying HTTP request library.
|
|
621
641
|
|
|
622
642
|
:return:
|
|
@@ -681,11 +701,11 @@ class BaseSyncSCIMClient(SCIMClient):
|
|
|
681
701
|
:param resource_models: Resource type or union of types expected
|
|
682
702
|
to be read from the response.
|
|
683
703
|
:param search_request: An object detailing the search query parameters.
|
|
684
|
-
:param check_request_payload: If set, overwrites :paramref:`SCIMClient.check_request_payload`.
|
|
685
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
704
|
+
:param check_request_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_request_payload`.
|
|
705
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
686
706
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
687
707
|
If :data:`None` any status code is accepted.
|
|
688
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
708
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
689
709
|
:param kwargs: Additional parameters passed to the underlying
|
|
690
710
|
HTTP request library.
|
|
691
711
|
|
|
@@ -728,10 +748,10 @@ class BaseSyncSCIMClient(SCIMClient):
|
|
|
728
748
|
|
|
729
749
|
:param resource_model: The type of the resource to delete.
|
|
730
750
|
:param id: The type id the resource to delete.
|
|
731
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
751
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
732
752
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
733
753
|
If :data:`None` any status code is accepted.
|
|
734
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
754
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
735
755
|
:param kwargs: Additional parameters passed to the underlying
|
|
736
756
|
HTTP request library.
|
|
737
757
|
|
|
@@ -766,11 +786,11 @@ class BaseSyncSCIMClient(SCIMClient):
|
|
|
766
786
|
|
|
767
787
|
:param resource: The new resource to replace.
|
|
768
788
|
If is a :data:`dict`, the resource type will be guessed from the schema.
|
|
769
|
-
:param check_request_payload: If set, overwrites :paramref:`SCIMClient.check_request_payload`.
|
|
770
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
789
|
+
:param check_request_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_request_payload`.
|
|
790
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
771
791
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
772
792
|
If :data:`None` any status code is accepted.
|
|
773
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
793
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
774
794
|
:param kwargs: Additional parameters passed to the underlying
|
|
775
795
|
HTTP request library.
|
|
776
796
|
|
|
@@ -837,11 +857,11 @@ class BaseAsyncSCIMClient(SCIMClient):
|
|
|
837
857
|
|
|
838
858
|
:param resource: The resource to create
|
|
839
859
|
If is a :data:`dict`, the resource type will be guessed from the schema.
|
|
840
|
-
:param check_request_payload: If set, overwrites :paramref:`SCIMClient.check_request_payload`.
|
|
841
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
860
|
+
:param check_request_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_request_payload`.
|
|
861
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
842
862
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
843
863
|
If :data:`None` any status code is accepted.
|
|
844
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
864
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
845
865
|
:param kwargs: Additional parameters passed to the underlying HTTP request
|
|
846
866
|
library.
|
|
847
867
|
|
|
@@ -889,11 +909,11 @@ class BaseAsyncSCIMClient(SCIMClient):
|
|
|
889
909
|
:param resource_model: A :class:`~scim2_models.Resource` subtype or :data:`None`
|
|
890
910
|
:param id: The SCIM id of an object to get, or :data:`None`
|
|
891
911
|
:param search_request: An object detailing the search query parameters.
|
|
892
|
-
:param check_request_payload: If set, overwrites :paramref:`SCIMClient.check_request_payload`.
|
|
893
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
912
|
+
:param check_request_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_request_payload`.
|
|
913
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
894
914
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
895
915
|
If :data:`None` any status code is accepted.
|
|
896
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
916
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
897
917
|
:param kwargs: Additional parameters passed to the underlying HTTP request library.
|
|
898
918
|
|
|
899
919
|
:return:
|
|
@@ -958,11 +978,11 @@ class BaseAsyncSCIMClient(SCIMClient):
|
|
|
958
978
|
:param resource_models: Resource type or union of types expected
|
|
959
979
|
to be read from the response.
|
|
960
980
|
:param search_request: An object detailing the search query parameters.
|
|
961
|
-
:param check_request_payload: If set, overwrites :paramref:`SCIMClient.check_request_payload`.
|
|
962
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
981
|
+
:param check_request_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_request_payload`.
|
|
982
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
963
983
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
964
984
|
If :data:`None` any status code is accepted.
|
|
965
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
985
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
966
986
|
:param kwargs: Additional parameters passed to the underlying
|
|
967
987
|
HTTP request library.
|
|
968
988
|
|
|
@@ -1005,10 +1025,10 @@ class BaseAsyncSCIMClient(SCIMClient):
|
|
|
1005
1025
|
|
|
1006
1026
|
:param resource_model: The type of the resource to delete.
|
|
1007
1027
|
:param id: The type id the resource to delete.
|
|
1008
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
1028
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
1009
1029
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
1010
1030
|
If :data:`None` any status code is accepted.
|
|
1011
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
1031
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
1012
1032
|
:param kwargs: Additional parameters passed to the underlying
|
|
1013
1033
|
HTTP request library.
|
|
1014
1034
|
|
|
@@ -1043,11 +1063,11 @@ class BaseAsyncSCIMClient(SCIMClient):
|
|
|
1043
1063
|
|
|
1044
1064
|
:param resource: The new resource to replace.
|
|
1045
1065
|
If is a :data:`dict`, the resource type will be guessed from the schema.
|
|
1046
|
-
:param check_request_payload: If set, overwrites :paramref:`SCIMClient.check_request_payload`.
|
|
1047
|
-
:param check_response_payload: If set, overwrites :paramref:`SCIMClient.check_response_payload`.
|
|
1066
|
+
:param check_request_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_request_payload`.
|
|
1067
|
+
:param check_response_payload: If set, overwrites :paramref:`scim2_client.SCIMClient.check_response_payload`.
|
|
1048
1068
|
:param expected_status_codes: The list of expected status codes form the response.
|
|
1049
1069
|
If :data:`None` any status code is accepted.
|
|
1050
|
-
:param raise_scim_errors: If set, overwrites :paramref:`SCIMClient.raise_scim_errors`.
|
|
1070
|
+
:param raise_scim_errors: If set, overwrites :paramref:`scim2_client.SCIMClient.raise_scim_errors`.
|
|
1051
1071
|
:param kwargs: Additional parameters passed to the underlying
|
|
1052
1072
|
HTTP request library.
|
|
1053
1073
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|