scim2-models 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. {scim2_models-0.3.0 → scim2_models-0.3.1}/.pre-commit-config.yaml +3 -3
  2. {scim2_models-0.3.0 → scim2_models-0.3.1}/PKG-INFO +3 -2
  3. {scim2_models-0.3.0 → scim2_models-0.3.1}/doc/changelog.rst +8 -0
  4. {scim2_models-0.3.0 → scim2_models-0.3.1}/pyproject.toml +1 -1
  5. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7644/list_response.py +13 -1
  6. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7644/search_request.py +5 -5
  7. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_list_response.py +23 -0
  8. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_search_request.py +5 -8
  9. scim2_models-0.3.1/uv.lock +1197 -0
  10. scim2_models-0.3.0/uv.lock +0 -1200
  11. {scim2_models-0.3.0 → scim2_models-0.3.1}/.github/FUNDING.yml +0 -0
  12. {scim2_models-0.3.0 → scim2_models-0.3.1}/.github/workflows/release.yml +0 -0
  13. {scim2_models-0.3.0 → scim2_models-0.3.1}/.github/workflows/tests.yaml +0 -0
  14. {scim2_models-0.3.0 → scim2_models-0.3.1}/.gitignore +0 -0
  15. {scim2_models-0.3.0 → scim2_models-0.3.1}/.readthedocs.yml +0 -0
  16. {scim2_models-0.3.0 → scim2_models-0.3.1}/LICENSE +0 -0
  17. {scim2_models-0.3.0 → scim2_models-0.3.1}/README.md +0 -0
  18. {scim2_models-0.3.0 → scim2_models-0.3.1}/conftest.py +0 -0
  19. {scim2_models-0.3.0 → scim2_models-0.3.1}/doc/__init__.py +0 -0
  20. {scim2_models-0.3.0 → scim2_models-0.3.1}/doc/conf.py +0 -0
  21. {scim2_models-0.3.0 → scim2_models-0.3.1}/doc/contributing.rst +0 -0
  22. {scim2_models-0.3.0 → scim2_models-0.3.1}/doc/index.rst +0 -0
  23. {scim2_models-0.3.0 → scim2_models-0.3.1}/doc/reference.rst +0 -0
  24. {scim2_models-0.3.0 → scim2_models-0.3.1}/doc/tutorial.rst +0 -0
  25. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.1-user-minimal.json +0 -0
  26. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.2-user-full.json +0 -0
  27. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.3-enterprise_user.json +0 -0
  28. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.4-group.json +0 -0
  29. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.5-service_provider_configuration.json +0 -0
  30. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.6-resource_type-group.json +0 -0
  31. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.6-resource_type-user.json +0 -0
  32. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.7.1-schema-enterprise_user.json +0 -0
  33. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.7.1-schema-group.json +0 -0
  34. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.7.1-schema-user.json +0 -0
  35. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.7.2-schema-resource_type.json +0 -0
  36. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.7.2-schema-schema.json +0 -0
  37. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7643-8.7.2-schema-service_provider_configuration.json +0 -0
  38. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.12-error-bad_request.json +0 -0
  39. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.12-error-not_found.json +0 -0
  40. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.14-user-post_request.json +0 -0
  41. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.14-user-post_response.json +0 -0
  42. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.3-user-post_request.json +0 -0
  43. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.3-user-post_response.json +0 -0
  44. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.4.1-user-known-resource.json +0 -0
  45. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.4.2-list_response-partial_attributes.json +0 -0
  46. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.4.3-list_response-post_query.json +0 -0
  47. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.4.3-search_request.json +0 -0
  48. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.1-user-put_request.json +0 -0
  49. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.1-user-put_response.json +0 -0
  50. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.1-patch_op-add_emails.json +0 -0
  51. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.1-patch_op-add_members.json +0 -0
  52. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.2-patch_op-remove_all_members.json +0 -0
  53. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.2-patch_op-remove_and_add_one_member.json +0 -0
  54. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.2-patch_op-remove_multi_complex_value.json +0 -0
  55. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.2-patch_op-remove_one_member.json +0 -0
  56. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.3-patch_op-replace_all_email_values.json +0 -0
  57. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.3-patch_op-replace_all_members.json +0 -0
  58. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.3-patch_op-replace_street_address.json +0 -0
  59. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.5.2.3-patch_op-replace_user_work_address.json +0 -0
  60. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.6-error-not_found.json +0 -0
  61. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.1-bulk_request-circular_conflict.json +0 -0
  62. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.1-list_response-circular_reference.json +0 -0
  63. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.2-bulk_request-enterprise_user.json +0 -0
  64. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.2-bulk_request-temporary_identifier.json +0 -0
  65. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.2-bulk_response-temporary_identifier.json +0 -0
  66. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.3-bulk_request-multiple_operations.json +0 -0
  67. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.3-bulk_response-error_invalid_syntax.json +0 -0
  68. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.3-bulk_response-multiple_errors.json +0 -0
  69. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.3-bulk_response-multiple_operations.json +0 -0
  70. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.3-error-invalid_syntax.json +0 -0
  71. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.7.4-error-payload_too_large.json +0 -0
  72. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-3.9-user-partial_response.json +0 -0
  73. {scim2_models-0.3.0 → scim2_models-0.3.1}/samples/rfc7644-4-list_response-resource_types.json +0 -0
  74. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/__init__.py +0 -0
  75. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/base.py +0 -0
  76. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/constants.py +0 -0
  77. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/py.typed +0 -0
  78. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/__init__.py +0 -0
  79. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/enterprise_user.py +0 -0
  80. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/group.py +0 -0
  81. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/resource.py +0 -0
  82. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/resource_type.py +0 -0
  83. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/schema.py +0 -0
  84. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/service_provider_config.py +0 -0
  85. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7643/user.py +0 -0
  86. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7644/__init__.py +0 -0
  87. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7644/bulk.py +0 -0
  88. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7644/error.py +0 -0
  89. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7644/message.py +0 -0
  90. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/rfc7644/patch_op.py +0 -0
  91. {scim2_models-0.3.0 → scim2_models-0.3.1}/scim2_models/utils.py +0 -0
  92. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/__init__.py +0 -0
  93. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/conftest.py +0 -0
  94. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_dynamic_resources.py +0 -0
  95. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_dynamic_schemas.py +0 -0
  96. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_enterprise_user.py +0 -0
  97. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_errors.py +0 -0
  98. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_group.py +0 -0
  99. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_model_attributes.py +0 -0
  100. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_model_serialization.py +0 -0
  101. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_model_validation.py +0 -0
  102. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_models.py +0 -0
  103. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_patch_op.py +0 -0
  104. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_resource_extension.py +0 -0
  105. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_resource_type.py +0 -0
  106. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_schema.py +0 -0
  107. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_service_provider_configuration.py +0 -0
  108. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_user.py +0 -0
  109. {scim2_models-0.3.0 → scim2_models-0.3.1}/tests/test_utils.py +0 -0
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  repos:
3
3
  - repo: https://github.com/astral-sh/ruff-pre-commit
4
- rev: 'v0.8.2'
4
+ rev: 'v0.9.10'
5
5
  hooks:
6
6
  - id: ruff
7
7
  args: [--fix, --exit-non-zero-on-fix]
@@ -16,11 +16,11 @@ repos:
16
16
  exclude: "\\.svg$|\\.map$|\\.min\\.css$|\\.min\\.js$|\\.po$|\\.pot$"
17
17
  - id: check-toml
18
18
  - repo: https://github.com/pre-commit/mirrors-mypy
19
- rev: v1.13.0
19
+ rev: v1.15.0
20
20
  hooks:
21
21
  - id: mypy
22
22
  - repo: https://github.com/codespell-project/codespell
23
- rev: v2.3.0
23
+ rev: v2.4.1
24
24
  hooks:
25
25
  - id: codespell
26
26
  additional_dependencies:
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: scim2-models
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: SCIM2 models serialization and validation with pydantic
5
5
  Project-URL: documentation, https://scim2-models.readthedocs.io
6
6
  Project-URL: repository, https://github.com/python-scim/scim2-models
@@ -208,6 +208,7 @@ License: Apache License
208
208
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
209
209
  See the License for the specific language governing permissions and
210
210
  limitations under the License.
211
+ License-File: LICENSE
211
212
  Keywords: provisioning,pydantic,rfc7643,rfc7644,scim,scim2
212
213
  Classifier: Development Status :: 3 - Alpha
213
214
  Classifier: Environment :: Web Environment
@@ -1,6 +1,14 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ [0.3.1] - 2025-03-07
5
+ --------------------
6
+
7
+ Fixed
8
+ ^^^^^
9
+ - Fix :attr:`~SearchRequest.start_index` and :attr:`~SearchRequest.count` limits. :issue:`84`
10
+ - :attr:`~ListResponse.total_resuls` is required.
11
+
4
12
  [0.3.0] - 2024-12-11
5
13
  --------------------
6
14
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "scim2-models"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "SCIM2 models serialization and validation with pydantic"
9
9
  authors = [{name="Yaal Coop", email="contact@yaal.coop"}]
10
10
  license = {file = "LICENSE"}
@@ -104,7 +104,13 @@ class ListResponse(Message, Generic[AnyResource], metaclass=ListResponseMetaclas
104
104
  def check_results_number(
105
105
  cls, value: Any, handler: ValidatorFunctionWrapHandler, info: ValidationInfo
106
106
  ) -> Self:
107
- """:rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>` indicates that 'resources' must be set if 'totalResults' is non-zero."""
107
+ """Validate result numbers.
108
+
109
+ :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>` indicates that:
110
+
111
+ - 'totalResults' is required
112
+ - 'resources' must be set if 'totalResults' is non-zero.
113
+ """
108
114
  obj = handler(value)
109
115
 
110
116
  if (
@@ -114,6 +120,12 @@ class ListResponse(Message, Generic[AnyResource], metaclass=ListResponseMetaclas
114
120
  ):
115
121
  return obj
116
122
 
123
+ if obj.total_results is None:
124
+ raise PydanticCustomError(
125
+ "required_error",
126
+ "Field 'total_results' is required but value is missing or null",
127
+ )
128
+
117
129
  if obj.total_results > 0 and not obj.resources:
118
130
  raise PydanticCustomError(
119
131
  "no_resource_error",
@@ -49,11 +49,11 @@ class SearchRequest(Message):
49
49
  @field_validator("start_index")
50
50
  @classmethod
51
51
  def start_index_floor(cls, value: int) -> int:
52
- """According to :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>, start_index values less than 0 are interpreted as 0.
52
+ """According to :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>, start_index values less than 1 are interpreted as 1.
53
53
 
54
54
  A value less than 1 SHALL be interpreted as 1.
55
55
  """
56
- return None if value is None else max(0, value)
56
+ return None if value is None else max(1, value)
57
57
 
58
58
  count: Optional[int] = None
59
59
  """An integer indicating the desired maximum number of query results per
@@ -62,11 +62,11 @@ class SearchRequest(Message):
62
62
  @field_validator("count")
63
63
  @classmethod
64
64
  def count_floor(cls, value: int) -> int:
65
- """According to :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>, count values less than 1 are interpreted as 1.
65
+ """According to :rfc:`RFC7644 §3.4.2 <7644#section-3.4.2.4>, count values less than 0 are interpreted as 0.
66
66
 
67
- A value less than 1 SHALL be interpreted as 1.
67
+ A negative value SHALL be interpreted as 0.
68
68
  """
69
- return None if value is None else max(1, value)
69
+ return None if value is None else max(0, value)
70
70
 
71
71
  @model_validator(mode="after")
72
72
  def attributes_validator(self):
@@ -217,3 +217,26 @@ def test_list_response_schema_ordering():
217
217
  ],
218
218
  }
219
219
  ListResponse[Union[User[EnterpriseUser], Group]].model_validate(payload)
220
+
221
+
222
+ def test_total_results_required():
223
+ """ListResponse.total_results is required."""
224
+ payload = {
225
+ "Resources": [
226
+ {
227
+ "schemas": [
228
+ "urn:ietf:params:scim:schemas:core:2.0:User",
229
+ ],
230
+ "userName": "bjensen@example.com",
231
+ "id": "foobar",
232
+ }
233
+ ],
234
+ }
235
+
236
+ with pytest.raises(
237
+ ValidationError,
238
+ match="Field 'total_results' is required but value is missing or null",
239
+ ):
240
+ ListResponse[User].model_validate(
241
+ payload, scim_ctx=Context.RESOURCE_QUERY_RESPONSE
242
+ )
@@ -29,13 +29,13 @@ def test_start_index_floor():
29
29
 
30
30
  https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.4
31
31
 
32
- A negative value SHALL be interpreted as 0.
32
+ A value less than 1 SHALL be interpreted as 1.
33
33
  """
34
34
  sr = SearchRequest(start_index=100)
35
35
  assert sr.start_index == 100
36
36
 
37
- sr = SearchRequest(start_index=-1)
38
- assert sr.start_index == 0
37
+ sr = SearchRequest(start_index=0)
38
+ assert sr.start_index == 1
39
39
 
40
40
 
41
41
  def test_count_floor():
@@ -43,16 +43,13 @@ def test_count_floor():
43
43
 
44
44
  https://datatracker.ietf.org/doc/html/rfc7644#section-3.4.2.4
45
45
 
46
- A value less than 1 SHALL be interpreted as 1.
46
+ A negative value SHALL be interpreted as 0.
47
47
  """
48
48
  sr = SearchRequest(count=100)
49
49
  assert sr.count == 100
50
50
 
51
- sr = SearchRequest(count=0)
52
- assert sr.count == 1
53
-
54
51
  sr = SearchRequest(count=-1)
55
- assert sr.count == 1
52
+ assert sr.count == 0
56
53
 
57
54
 
58
55
  def test_attributes_or_excluded_attributes():