scim2-server 0.8.8__tar.gz → 0.8.9__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 (33) hide show
  1. {scim2_server-0.8.8 → scim2_server-0.8.9}/PKG-INFO +2 -2
  2. {scim2_server-0.8.8 → scim2_server-0.8.9}/pyproject.toml +2 -2
  3. {scim2_server-0.8.8 → scim2_server-0.8.9}/pyproject.toml.orig +2 -2
  4. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/storage.py +14 -0
  5. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/testing.py +66 -0
  6. {scim2_server-0.8.8 → scim2_server-0.8.9}/LICENSE +0 -0
  7. {scim2_server-0.8.8 → scim2_server-0.8.9}/README.md +0 -0
  8. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/__init__.py +0 -0
  9. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/applications/__init__.py +0 -0
  10. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/applications/asgi.py +0 -0
  11. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/applications/base.py +0 -0
  12. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/applications/wsgi.py +0 -0
  13. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/bulk.py +0 -0
  14. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/conditions.py +0 -0
  15. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/cursor.py +0 -0
  16. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/errors.py +0 -0
  17. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/handler.py +0 -0
  18. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/keyset.py +0 -0
  19. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/memory.py +0 -0
  20. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/py.typed +0 -0
  21. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/requests.py +0 -0
  22. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/resources/default-resource-types.json +0 -0
  23. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/resources/default-schemas.json +0 -0
  24. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/resources/default-service-provider-config.json +0 -0
  25. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/responses.py +0 -0
  26. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/routing.py +0 -0
  27. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/service.py +0 -0
  28. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/testserver/__init__.py +0 -0
  29. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/testserver/application.py +0 -0
  30. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/testserver/cli.py +0 -0
  31. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/testserver/oauth.py +0 -0
  32. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/testserver/precis.py +0 -0
  33. {scim2_server-0.8.8 → scim2_server-0.8.9}/scim2_server/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: scim2-server
3
- Version: 0.8.8
3
+ Version: 0.8.9
4
4
  Summary: SCIM server core for any storage and web framework
5
5
  Keywords: scim,scim2,provisioning,rfc7643,rfc7644
6
6
  Author: Yaal Coop, Christian Friedrich Coors
@@ -218,7 +218,7 @@ Classifier: License :: OSI Approved :: Apache Software License
218
218
  Classifier: Environment :: Web Environment
219
219
  Classifier: Programming Language :: Python
220
220
  Classifier: Operating System :: OS Independent
221
- Requires-Dist: scim2-models>=0.12.2
221
+ Requires-Dist: scim2-models>=0.12.7
222
222
  Requires-Dist: cryptography>=50.0.1 ; extra == 'cursor'
223
223
  Requires-Dist: authlib>=1.10.0b1 ; extra == 'oauth'
224
224
  Requires-Dist: precis-i18n>=1.1.2 ; extra == 'precis'
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "scim2-server"
7
- version = "0.8.8"
7
+ version = "0.8.9"
8
8
  description = "SCIM server core for any storage and web framework"
9
9
  readme = "README.md"
10
10
  keywords = [
@@ -29,7 +29,7 @@ classifiers = [
29
29
  "Operating System :: OS Independent",
30
30
  ]
31
31
  requires-python = ">= 3.11"
32
- dependencies = ["scim2-models>=0.12.2"]
32
+ dependencies = ["scim2-models>=0.12.7"]
33
33
 
34
34
  [[project.authors]]
35
35
  name = "Yaal Coop"
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "scim2-server"
7
- version = "0.8.8"
7
+ version = "0.8.9"
8
8
  description = "SCIM server core for any storage and web framework"
9
9
  authors = [
10
10
  {name="Yaal Coop", email="contact@yaal.coop"},
@@ -30,7 +30,7 @@ classifiers = [
30
30
 
31
31
  requires-python = ">= 3.11"
32
32
  dependencies = [
33
- "scim2-models>=0.12.2",
33
+ "scim2-models>=0.12.7",
34
34
  ]
35
35
 
36
36
  [project.optional-dependencies]
@@ -173,6 +173,14 @@ class ScimStorage(ABC):
173
173
  Without ``response_parameters``, the storage returns the whole
174
174
  resource.
175
175
 
176
+ The whole resource holds the write-only and never returned
177
+ attributes, such as ``password``, in the form the storage keeps them,
178
+ a hash for instance. The server never returns them to the client
179
+ (:rfc:`RFC 7643 §2.2 <7643#section-2.2>`). It needs them to keep a
180
+ value that a PUT leaves out (:rfc:`RFC 7644 §3.5.1
181
+ <7644#section-3.5.1>`), and to clear one that a PATCH removes
182
+ (:rfc:`RFC 7644 §3.5.2.2 <7644#section-3.5.2.2>`).
183
+
176
184
  A ``get`` method without ``response_parameters`` is deprecated, and
177
185
  raises a :class:`DeprecationWarning`. The server then does not pass
178
186
  the parameters. scim2-server 0.9 will require it.
@@ -252,6 +260,12 @@ class ScimStorage(ABC):
252
260
  request to the stored resource first, so ``resource`` is the whole new
253
261
  state of the resource.
254
262
 
263
+ A write-only or never returned value that :meth:`get` returned comes
264
+ back unchanged
265
+ when the request does not change it. The storage keeps it as it is,
266
+ and does not hash it again. It clears the value when it comes back as
267
+ :data:`None`.
268
+
255
269
  :param expected_version: The version the stored resource must still
256
270
  have, when given.
257
271
  :raises ~scim2_models.NotFoundException: When the resource does not exist.
@@ -180,6 +180,16 @@ class ScimStorageContract:
180
180
  empty.
181
181
  """
182
182
 
183
+ stores_password: bool = True
184
+ """Whether the storage stores the ``password`` of the users.
185
+
186
+ Set it to :data:`False` only for a storage that does not keep the
187
+ password at all. The tests of the write-only and never returned
188
+ attributes are then skipped. A storage that keeps a hash of the password
189
+ stores it: its :meth:`~scim2_server.storage.ScimStorage.get` returns the
190
+ hash.
191
+ """
192
+
183
193
  @pytest.fixture
184
194
  def provider(self) -> ScimProvider:
185
195
  """Return the description of the service the storage serves."""
@@ -447,6 +457,62 @@ class ScimStorageContract:
447
457
 
448
458
  assert storage.get(user_type, user.id).user_name == "bjensen"
449
459
 
460
+ def create_user_with_password(
461
+ self, storage: Any, user_type: ResourceType, user_model: Any
462
+ ) -> Any:
463
+ """Create a user with a password, and read it back, as the server does before a PUT or a PATCH."""
464
+ self.require(self.stores_password, "the password")
465
+ user = storage.create(
466
+ user_type, user_model(user_name="bjensen", password="secret")
467
+ )
468
+ return storage.get(user_type, user.id)
469
+
470
+ def test_get_returns_the_write_only_values(
471
+ self, storage: Any, user_type: ResourceType, user_model: Any
472
+ ) -> None:
473
+ """A whole resource holds its password, in the form the storage keeps it."""
474
+ user = self.create_user_with_password(storage, user_type, user_model)
475
+
476
+ assert user.password is not None
477
+
478
+ def test_update_keeps_the_write_only_values_read_back(
479
+ self, storage: Any, user_type: ResourceType, user_model: Any
480
+ ) -> None:
481
+ """The password read back and given to update unchanged stays as it is.
482
+
483
+ It is what a PUT without password gives, per :rfc:`RFC 7644 §3.5.1
484
+ <7644#section-3.5.1>`.
485
+ """
486
+ user = self.create_user_with_password(storage, user_type, user_model)
487
+ user.display_name = "Barbara"
488
+
489
+ storage.update(user_type, user)
490
+
491
+ assert storage.get(user_type, user.id).password == user.password
492
+
493
+ def test_update_clears_a_write_only_value(
494
+ self, storage: Any, user_type: ResourceType, user_model: Any
495
+ ) -> None:
496
+ """A PATCH removing the password clears it."""
497
+ user = self.create_user_with_password(storage, user_type, user_model)
498
+ user.password = None
499
+
500
+ storage.update(user_type, user)
501
+
502
+ assert storage.get(user_type, user.id).password is None
503
+
504
+ def test_update_changes_a_write_only_value(
505
+ self, storage: Any, user_type: ResourceType, user_model: Any
506
+ ) -> None:
507
+ """A new password replaces the stored one."""
508
+ user = self.create_user_with_password(storage, user_type, user_model)
509
+ former = user.password
510
+ user.password = "other"
511
+
512
+ storage.update(user_type, user)
513
+
514
+ assert storage.get(user_type, user.id).password not in (None, former)
515
+
450
516
  def test_update_an_unknown_resource(
451
517
  self, storage: Any, user_type: ResourceType, user_model: Any
452
518
  ) -> None:
File without changes
File without changes