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.2.5] - Unreleased
--------------------

Changed
^^^^^^^
- Use scim2-models native path management.

[0.2.4] - 2025-10-10
--------------------

Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "uv_build"
[project]
name = "scim2-tester"
version = "0.2.4"
description = " Check SCIM RFCs server compliance"
description = "Check SCIM RFCs server compliance"
authors = [{name="Yaal Coop", email="contact@yaal.coop"}]
license = {file = "LICENSE.md"}
readme = "README.md"
Expand All @@ -27,8 +27,8 @@ classifiers = [

requires-python = ">= 3.10"
dependencies = [
"scim2-client>=0.6.1",
"scim2-models>=0.5.0",
"scim2-client>=0.7.0",
"scim2-models>=0.6.1",
]

[project.urls]
Expand Down
25 changes: 11 additions & 14 deletions scim2_tester/checkers/patch_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
from scim2_models import PatchOperation
from scim2_models import Required
from scim2_models import Resource
from scim2_models.path import Path

from ..filling import generate_random_value
from ..urns import get_annotation_by_urn
from ..urns import get_value_by_urn
from ..urns import iter_all_urns
from ..utils import CheckContext
from ..utils import CheckResult
from ..utils import Status
Expand Down Expand Up @@ -60,21 +58,19 @@ def check_add_attribute(
]

results = []
all_urns = list(
iter_all_urns(
model,
all_paths = list(
Path[model].iter_paths(
required=[Required.false],
mutability=[
Mutability.read_write,
Mutability.write_only,
Mutability.immutable,
],
# Not supported until filters are implemented in scim2_models
include_subattributes=False,
)
)

if not all_urns:
if not all_paths:
return [
check_result(
context,
Expand All @@ -86,15 +82,16 @@ def check_add_attribute(

base_resource = context.resource_manager.create_and_register(model)

for urn, source_model in all_urns:
patch_value = generate_random_value(context, urn=urn, model=source_model)
mutability = get_annotation_by_urn(Mutability, urn, source_model)
for path in all_paths:
urn = str(path)
patch_value = generate_random_value(context, path=path)
mutability = path.get_annotation(Mutability)

patch_op = PatchOp[type(base_resource)](
operations=[
PatchOperation(
op=PatchOperation.Op.add,
path=urn,
path=path,
value=patch_value,
)
]
Expand Down Expand Up @@ -123,7 +120,7 @@ def check_add_attribute(
continue

if modify_result is not None:
modify_actual_value = get_value_by_urn(modify_result, urn)
modify_actual_value = path.get(modify_result)
if mutability != Mutability.write_only and not fields_equality(
patch_value, modify_actual_value
):
Expand Down Expand Up @@ -167,7 +164,7 @@ def check_add_attribute(
)
continue

actual_value = get_value_by_urn(updated_resource, urn)
actual_value = path.get(updated_resource)

if mutability == Mutability.write_only or fields_equality(
patch_value, actual_value
Expand Down
25 changes: 11 additions & 14 deletions scim2_tester/checkers/patch_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from scim2_models import PatchOperation
from scim2_models import Required
from scim2_models import Resource
from scim2_models.path import Path

from ..urns import get_annotation_by_urn
from ..urns import get_value_by_urn
from ..urns import iter_all_urns
from ..utils import CheckContext
from ..utils import CheckResult
from ..utils import Status
Expand Down Expand Up @@ -59,17 +57,15 @@ def check_remove_attribute(
]

results = []
all_urns = list(
iter_all_urns(
model,
all_paths = list(
Path[model].iter_paths(
required=[Required.false],
mutability=[Mutability.read_write, Mutability.write_only],
# Not supported until filters are implemented in scim2_models
include_subattributes=False,
)
)

if not all_urns:
if not all_paths:
return [
check_result(
context,
Expand All @@ -81,17 +77,18 @@ def check_remove_attribute(

full_resource = context.resource_manager.create_and_register(model, fill_all=True)

for urn, source_model in all_urns:
initial_value = get_value_by_urn(full_resource, urn)
mutability = get_annotation_by_urn(Mutability, urn, source_model)
for path in all_paths:
urn = str(path)
initial_value = path.get(full_resource)
mutability = path.get_annotation(Mutability)
if initial_value is None:
continue

remove_op = PatchOp[type(full_resource)](
operations=[
PatchOperation(
op=PatchOperation.Op.remove,
path=urn,
path=path,
)
]
)
Expand Down Expand Up @@ -119,7 +116,7 @@ def check_remove_attribute(
continue

if modify_result is not None:
if modify_actual_value := get_value_by_urn(modify_result, urn):
if modify_actual_value := path.get(modify_result):
if (
mutability != Mutability.write_only
and modify_actual_value is not None
Expand Down Expand Up @@ -160,7 +157,7 @@ def check_remove_attribute(
)
continue

actual_value = get_value_by_urn(updated_resource, urn)
actual_value = path.get(updated_resource)
if mutability == Mutability.write_only or actual_value is None:
results.append(
check_result(
Expand Down
25 changes: 11 additions & 14 deletions scim2_tester/checkers/patch_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
from scim2_models import PatchOp
from scim2_models import PatchOperation
from scim2_models import Resource
from scim2_models.path import Path

from ..filling import generate_random_value
from ..urns import get_annotation_by_urn
from ..urns import get_value_by_urn
from ..urns import iter_all_urns
from ..utils import CheckContext
from ..utils import CheckResult
from ..utils import Status
Expand Down Expand Up @@ -59,16 +57,14 @@ def check_replace_attribute(
]

results = []
all_urns = list(
iter_all_urns(
model,
all_paths = list(
Path[model].iter_paths(
mutability=[Mutability.read_write, Mutability.write_only],
# Not supported until filters are implemented in scim2_models
include_subattributes=False,
)
)

if not all_urns:
if not all_paths:
return [
check_result(
context,
Expand All @@ -80,15 +76,16 @@ def check_replace_attribute(

base_resource = context.resource_manager.create_and_register(model)

for urn, source_model in all_urns:
patch_value = generate_random_value(context, urn=urn, model=source_model)
mutability = get_annotation_by_urn(Mutability, urn, source_model)
for path in all_paths:
urn = str(path)
patch_value = generate_random_value(context, path=path)
mutability = path.get_annotation(Mutability)

patch_op = PatchOp[type(base_resource)](
operations=[
PatchOperation(
op=PatchOperation.Op.replace_,
path=urn,
path=path,
value=patch_value,
)
]
Expand Down Expand Up @@ -117,7 +114,7 @@ def check_replace_attribute(
continue

if modify_result is not None:
modify_actual_value = get_value_by_urn(modify_result, urn)
modify_actual_value = path.get(modify_result)
if mutability != Mutability.write_only and not fields_equality(
patch_value, modify_actual_value
):
Expand Down Expand Up @@ -161,7 +158,7 @@ def check_replace_attribute(
)
continue

actual_value = get_value_by_urn(updated_resource, urn)
actual_value = path.get(updated_resource)
if mutability == Mutability.write_only or fields_equality(
patch_value, actual_value
):
Expand Down
2 changes: 1 addition & 1 deletion scim2_tester/checkers/resource_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def _model_from_resource_type(
corresponding Python model class registered in the SCIM client.
"""
for resource_model in context.client.resource_models:
if resource_model.model_fields["schemas"].default[0] == resource_type.schema_:
if resource_model.__schema__ == resource_type.schema_:
return resource_model

return None
Expand Down
Loading
Loading