Skip to content

Commit 4c57897

Browse files
committed
feat: add support for extensions
1 parent ea944b3 commit 4c57897

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

doc/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
[0.1.9] - Unreleased
5+
--------------------
6+
7+
Added
8+
^^^^^
9+
- Added support for :class:`Extensions <scim2_models.Extension>`.
10+
411
[0.1.8] - 2024-11-29
512
--------------------
613

scim2_tester/resource.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from pydantic import EmailStr
88
from scim2_models import ComplexAttribute
9+
from scim2_models import EnterpriseUser
10+
from scim2_models import Extension
911
from scim2_models import Group
1012
from scim2_models import Meta
1113
from scim2_models import Reference
@@ -20,9 +22,13 @@
2022
from scim2_tester.utils import checker
2123

2224

23-
def model_from_resource_type(resource_type: ResourceType):
25+
def model_from_resource_type(conf: CheckConfig, resource_type: ResourceType):
2426
if resource_type.id == "User":
25-
return User
27+
return (
28+
User[EnterpriseUser]
29+
if User[EnterpriseUser] in conf.client.resource_models
30+
else User
31+
)
2632

2733
if resource_type.id == "Group":
2834
return Group
@@ -59,6 +65,10 @@ def fill_with_random_values(obj) -> Resource:
5965
value = field_type()
6066
fill_with_random_values(value)
6167

68+
elif isclass(field_type) and issubclass(field_type, Extension):
69+
value = field_type()
70+
fill_with_random_values(value)
71+
6272
else:
6373
value = str(uuid.uuid4())
6474

@@ -67,6 +77,7 @@ def fill_with_random_values(obj) -> Resource:
6777

6878
else:
6979
setattr(obj, field_name, value)
80+
7081
return obj
7182

7283

@@ -181,7 +192,7 @@ def check_resource_type(
181192
) -> list[CheckResult]:
182193
results = []
183194

184-
model = model_from_resource_type(resource_type)
195+
model = model_from_resource_type(conf, resource_type)
185196
obj = model()
186197
fill_with_random_values(obj)
187198

tests/conftest.py

Whitespace-only changes.

tests/test_scim2_server.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from scim2_client.engines.werkzeug import TestSCIMClient
3+
from scim2_models import EnterpriseUser
34
from scim2_models import Group
45
from scim2_models import User
56
from scim2_server.backend import InMemoryBackend
@@ -8,7 +9,6 @@
89
from scim2_server.utils import load_default_schemas
910

1011
from scim2_tester import check_server
11-
from scim2_tester.utils import Status
1212

1313
TestSCIMClient.__test__ = False
1414

@@ -28,6 +28,5 @@ def scim2_server():
2828

2929

3030
def test_scim2_server(scim2_server):
31-
scim = TestSCIMClient(scim2_server, resource_models=(User, Group))
32-
results = check_server(scim)
33-
assert all(result.status == Status.SUCCESS for result in results)
31+
scim = TestSCIMClient(scim2_server, resource_models=(User[EnterpriseUser], Group))
32+
check_server(scim, raise_exceptions=True)

0 commit comments

Comments
 (0)