Skip to content

Commit f978d36

Browse files
authored
Merge pull request #20 from yaal-coop/pr18
fix: separate type/subtype from possible parameters
2 parents ecac043 + e3080c0 commit f978d36

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

doc/changelog.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
[0.1.11] - Unreleased
5+
---------------------
6+
7+
Fixed
8+
^^^^^^^
9+
- Support for content-types with charset information. #18 #19
10+
411
[0.1.10] - 2024-08-18
512
---------------------
613

scim2_client/client.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ def check_response(
176176
# https://datatracker.ietf.org/doc/html/rfc7644.html#section-8.1
177177

178178
expected_response_content_types = ("application/scim+json", "application/json")
179-
if response.headers.get("content-type") not in expected_response_content_types:
179+
if (
180+
response.headers.get("content-type").split(";").pop(0)
181+
not in expected_response_content_types
182+
):
180183
raise UnexpectedContentType(source=response)
181184

182185
# In addition to returning an HTTP response code, implementers MUST return

tests/test_query.py

+25
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,23 @@ def httpserver(httpserver):
8585
{"foo": "bar"}, status=200, content_type="application/scim+json"
8686
)
8787

88+
httpserver.expect_request("/Users/content-type-with-charset").respond_with_json(
89+
{
90+
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
91+
"id": "2819c223-7f76-453a-919d-413861904646",
92+
"userName": "[email protected]",
93+
"meta": {
94+
"resourceType": "User",
95+
"created": "2010-01-23T04:56:22Z",
96+
"lastModified": "2011-05-13T04:42:34Z",
97+
"version": 'W\\/"3694e05e9dff590"',
98+
"location": "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646",
99+
},
100+
},
101+
status=200,
102+
content_type="application/scim+json; charset=utf-8",
103+
)
104+
88105
httpserver.expect_request("/Users/bad-content-type").respond_with_json(
89106
{
90107
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
@@ -518,6 +535,14 @@ def test_response_bad_status_code(client):
518535
scim_client.query(User, "status-201", check_status_code=False)
519536

520537

538+
def test_response_content_type_with_charset(client):
539+
"""Test sitations where servers return a valid content-type with a charset
540+
information."""
541+
scim_client = SCIMClient(client, resource_types=(User, Group))
542+
user = scim_client.query(User, "content-type-with-charset")
543+
assert isinstance(user, User)
544+
545+
521546
def test_response_bad_content_type(client):
522547
"""Test sitations where servers return an invalid content-type response."""
523548
scim_client = SCIMClient(

0 commit comments

Comments
 (0)