Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

[0.7.2] - Unreleased
--------------------

Fixed
^^^^^
- Skip ``Content-Type`` header validation for 204 responses. :issue:`34`

[0.7.1] - 2025-01-25
--------------------

Expand Down
3 changes: 1 addition & 2 deletions scim2_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ def check_response(
if raise_scim_errors is None:
raise_scim_errors = self.raise_scim_errors

self._check_content_types(headers)

# In addition to returning an HTTP response code, implementers MUST return
# the errors in the body of the response in a JSON format
# https://datatracker.ietf.org/doc/html/rfc7644.html#section-3.12
Expand All @@ -301,6 +299,7 @@ def check_response(
response_payload = None

else:
self._check_content_types(headers)
response_payload = payload

if check_response_payload is None:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ def test_delete_user(httpserver, sync_client):
assert response is None


def test_delete_user_without_content_type_header(httpserver, sync_client):
"""Server returns 204 without Content-Type header, which is valid per RFC 7231."""
httpserver.expect_request(
"/Users/2819c223-7f76-453a-919d-413861904646", method="DELETE"
).respond_with_data(status=204)

response = sync_client.delete(User, "2819c223-7f76-453a-919d-413861904646")
assert response is None


@pytest.mark.parametrize("code", [400, 401, 403, 404, 412, 500, 501])
def test_errors(httpserver, code, sync_client):
"""Test error cases defined in RFC7644."""
Expand Down
21 changes: 21 additions & 0 deletions tests/test_modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ def test_modify_user_204(httpserver, sync_client):
assert response is None


def test_modify_user_204_without_content_type_header(httpserver, sync_client):
"""Server returns 204 without Content-Type header, which is valid per RFC 7231."""
httpserver.expect_request(
"/Users/2819c223-7f76-453a-919d-413861904646", method="PATCH"
).respond_with_data(
"",
status=204,
)

operation = PatchOperation(
op=PatchOperation.Op.replace_, path="active", value=False
)
patch_op = PatchOp[User](operations=[operation])

response = sync_client.modify(
User, "2819c223-7f76-453a-919d-413861904646", patch_op
)

assert response is None


def test_modify_user_multiple_operations(httpserver, sync_client):
"""Test User modification with multiple patch operations."""
httpserver.expect_request(
Expand Down
Loading