Skip to content

Commit ddfe951

Browse files
committed
fix: don't execute PATCH tests when the ServiceProviderConfig advises patch is not supported
1 parent d7bd34a commit ddfe951

File tree

7 files changed

+91
-3
lines changed

7 files changed

+91
-3
lines changed

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Changelog
77
Fixed
88
^^^^^
99
- Discovery checkers are always executed, even with tag filtering.
10+
- Don't execute PATCH tests when the ServiceProviderConfig advises patch is not supported.
1011

1112
[0.2.1] - 2025-08-13
1213
--------------------

scim2_tester/checkers/patch_add.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,25 @@ def check_add_attribute(
3838
**Status:**
3939
- :attr:`~scim2_tester.Status.SUCCESS`: Attribute successfully added
4040
- :attr:`~scim2_tester.Status.ERROR`: Failed to add attribute
41-
- :attr:`~scim2_tester.Status.SKIPPED`: No addable attributes found
41+
- :attr:`~scim2_tester.Status.SKIPPED`: No addable attributes found or PATCH not supported
4242
4343
.. pull-quote:: :rfc:`RFC 7644 Section 3.5.2.1 - Add Operation <7644#section-3.5.2.1>`
4444
4545
"The 'add' operation is used to add a new attribute and/or values to
4646
an existing resource."
4747
"""
48+
if (
49+
context.client.service_provider_config
50+
and not context.client.service_provider_config.patch.supported
51+
):
52+
return [
53+
CheckResult(
54+
status=Status.SKIPPED,
55+
reason="PATCH operations not supported by server",
56+
resource_type=model.__name__,
57+
)
58+
]
59+
4860
results = []
4961
all_urns = list(
5062
iter_all_urns(

scim2_tester/checkers/patch_remove.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,26 @@ def check_remove_attribute(
3636
**Status:**
3737
- :attr:`~scim2_tester.Status.SUCCESS`: Attribute successfully removed
3838
- :attr:`~scim2_tester.Status.ERROR`: Failed to remove attribute or attribute still exists
39-
- :attr:`~scim2_tester.Status.SKIPPED`: No removable attributes found
39+
- :attr:`~scim2_tester.Status.SKIPPED`: No removable attributes found or PATCH not supported
4040
4141
.. pull-quote:: :rfc:`RFC 7644 Section 3.5.2.2 - Remove Operation <7644#section-3.5.2.2>`
4242
4343
"The 'remove' operation removes the value at the target location specified
4444
by the required attribute 'path'. The operation performs the following
4545
functions, depending on the target location specified by 'path'."
4646
"""
47+
if (
48+
context.client.service_provider_config
49+
and not context.client.service_provider_config.patch.supported
50+
):
51+
return [
52+
CheckResult(
53+
status=Status.SKIPPED,
54+
reason="PATCH operations not supported by server",
55+
resource_type=model.__name__,
56+
)
57+
]
58+
4759
results = []
4860
all_urns = list(
4961
iter_all_urns(

scim2_tester/checkers/patch_replace.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,25 @@ def check_replace_attribute(
3737
**Status:**
3838
- :attr:`~scim2_tester.Status.SUCCESS`: Attribute successfully replaced
3939
- :attr:`~scim2_tester.Status.ERROR`: Failed to replace attribute
40-
- :attr:`~scim2_tester.Status.SKIPPED`: No replaceable attributes found
40+
- :attr:`~scim2_tester.Status.SKIPPED`: No replaceable attributes found or PATCH not supported
4141
4242
.. pull-quote:: :rfc:`RFC 7644 Section 3.5.2.3 - Replace Operation <7644#section-3.5.2.3>`
4343
4444
"The 'replace' operation replaces the value at the target location
4545
specified by the 'path'."
4646
"""
47+
if (
48+
context.client.service_provider_config
49+
and not context.client.service_provider_config.patch.supported
50+
):
51+
return [
52+
CheckResult(
53+
status=Status.SKIPPED,
54+
reason="PATCH operations not supported by server",
55+
resource_type=model.__name__,
56+
)
57+
]
58+
4759
results = []
4860
all_urns = list(
4961
iter_all_urns(

tests/test_patch_add.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,20 @@ def test_patch_add_query_failure_after_patch(httpserver, testing_context):
408408
and "was not added or has incorrect value" in r.reason
409409
]
410410
assert len(error_results) > 0
411+
412+
413+
def test_patch_not_supported(testing_context):
414+
"""Test PATCH add returns SKIPPED when PATCH is not supported."""
415+
from unittest.mock import Mock
416+
417+
# Mock ServiceProviderConfig with patch.supported = False
418+
mock_service_provider_config = Mock()
419+
mock_service_provider_config.patch.supported = False
420+
testing_context.client.service_provider_config = mock_service_provider_config
421+
422+
results = check_add_attribute(testing_context, User)
423+
424+
assert len(results) == 1
425+
assert results[0].status == Status.SKIPPED
426+
assert "PATCH operations not supported by server" in results[0].reason
427+
assert results[0].resource_type == "User"

tests/test_patch_remove.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,20 @@ def test_patch_remove_writeonly_attribute(testing_context):
437437
if r.status == Status.SUCCESS and "password" in r.data.get("urn", "")
438438
]
439439
assert len(success_results) > 0
440+
441+
442+
def test_patch_not_supported(testing_context):
443+
"""Test PATCH remove returns SKIPPED when PATCH is not supported."""
444+
from unittest.mock import Mock
445+
446+
# Mock ServiceProviderConfig with patch.supported = False
447+
mock_service_provider_config = Mock()
448+
mock_service_provider_config.patch.supported = False
449+
testing_context.client.service_provider_config = mock_service_provider_config
450+
451+
results = check_remove_attribute(testing_context, User)
452+
453+
assert len(results) == 1
454+
assert results[0].status == Status.SKIPPED
455+
assert "PATCH operations not supported by server" in results[0].reason
456+
assert results[0].resource_type == "User"

tests/test_patch_replace.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,20 @@ def test_patch_replace_attribute_not_replaced(httpserver, testing_context):
306306
if r.status == Status.ERROR and "was not replaced" in r.reason
307307
]
308308
assert len(error_results) > 0
309+
310+
311+
def test_patch_not_supported(testing_context):
312+
"""Test PATCH replace returns SKIPPED when PATCH is not supported."""
313+
from unittest.mock import Mock
314+
315+
# Mock ServiceProviderConfig with patch.supported = False
316+
mock_service_provider_config = Mock()
317+
mock_service_provider_config.patch.supported = False
318+
testing_context.client.service_provider_config = mock_service_provider_config
319+
320+
results = check_replace_attribute(testing_context, User)
321+
322+
assert len(results) == 1
323+
assert results[0].status == Status.SKIPPED
324+
assert "PATCH operations not supported by server" in results[0].reason
325+
assert results[0].resource_type == "User"

0 commit comments

Comments
 (0)