pytest-scim2-server 0.1.2__tar.gz → 0.1.4__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.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  repos:
3
3
  - repo: https://github.com/astral-sh/ruff-pre-commit
4
- rev: 'v0.9.2'
4
+ rev: 'v0.11.9'
5
5
  hooks:
6
6
  - id: ruff
7
7
  args: [--fix, --exit-non-zero-on-fix]
@@ -16,7 +16,7 @@ repos:
16
16
  exclude: "\\.svg$|\\.map$|\\.min\\.css$|\\.min\\.js$|\\.po$|\\.pot$"
17
17
  - id: check-toml
18
18
  - repo: https://github.com/codespell-project/codespell
19
- rev: v2.3.0
19
+ rev: v2.4.1
20
20
  hooks:
21
21
  - id: codespell
22
22
  additional_dependencies:
@@ -1,3 +1,11 @@
1
+ # 0.1.4 - 2025-05-11
2
+
3
+ - Python package metadata update.
4
+
5
+ # 0.1.3 - 2025-03-28
6
+
7
+ - Option to disable the server request logging.
8
+
1
9
  # 0.1.2 - 2025-01-27
2
10
 
3
11
  - Initial GHA workflow.
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-scim2-server
3
+ Version: 0.1.4
4
+ Summary: SCIM2 server fixture for Pytest
5
+ Project-URL: repository, https://gitlab.com/pytest-dev/pytest-scim2-server
6
+ Author-email: Yaal Coop <contact@yaal.coop>
7
+ Maintainer-email: Éloi Rivard <eloi@yaal.coop>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2025 Éloi Rivard
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Keywords: fixture,pytest,rfc7643,rfc7644,scim,scim2
31
+ Classifier: Development Status :: 4 - Beta
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Operating System :: OS Independent
35
+ Classifier: Programming Language :: Python
36
+ Classifier: Programming Language :: Python :: 3.10
37
+ Classifier: Programming Language :: Python :: 3.11
38
+ Classifier: Programming Language :: Python :: 3.12
39
+ Classifier: Programming Language :: Python :: 3.13
40
+ Requires-Python: >=3.10
41
+ Requires-Dist: portpicker>=1.6.0
42
+ Requires-Dist: pytest>=8.3.4
43
+ Requires-Dist: scim2-server>=0.1.4
44
+ Description-Content-Type: text/markdown
45
+
46
+ # pytest-scim2-server
47
+
48
+ SCIM2 server fixture for Pytest
49
+
50
+ ## Installation
51
+
52
+ ```
53
+ pip install pytest-scim2-server
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ pytest-scim2-server creates a ``scim2_server`` fixture that runs an instance of [scim2-server](https://github.com/python-scim/scim2-server) on a random port, in a dedicated thread.
59
+
60
+ ```python
61
+ import requests
62
+
63
+ def test_scim_foobar(scim2_server):
64
+ res = request.get(f"http://localhost:{scim2_server.port}")
65
+ ...
66
+ ```
67
+
68
+ Note that you can use [scim2-client](https://scim2-client.readthedocs.io) to interact with the SCIM server.
69
+
70
+ ```python
71
+ import pytest
72
+ from httpx import Client
73
+ from scim2_client.engines.httpx import SyncSCIMClient
74
+
75
+
76
+ @pytest.fixture(scope="session")
77
+ def scim_client(scim2_server):
78
+ http_client = Client(base_url=f"http://localhost:{scim2_server.port}")
79
+ scim_client = SyncSCIMClient(http_client)
80
+ scim_client.discover()
81
+ return scim_client
82
+
83
+
84
+ def test_scim2_server(scim_client):
85
+ User = scim_client.get_resource_model("User")
86
+ user = User(user_name="bjensen@example.com")
87
+ response = scim_client.create(user)
88
+
89
+ users = scim_client.query(User)
90
+ assert users.resources[0].id == response.id
91
+ ```
@@ -4,15 +4,33 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pytest-scim2-server"
7
- version = "0.1.2"
8
- description = " SCIM2 server fixture for Pytest "
7
+ version = "0.1.4"
8
+ description = "SCIM2 server fixture for Pytest"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
+ license = {file = "LICENSE"}
12
+ keywords = ["pytest", "fixture", "scim", "scim2", "rfc7643", "rfc7644"]
11
13
  dependencies = [
12
14
  "portpicker>=1.6.0",
13
15
  "pytest>=8.3.4",
14
16
  "scim2-server>=0.1.4",
15
17
  ]
18
+ authors = [{name="Yaal Coop", email="contact@yaal.coop"}]
19
+ maintainers = [{name="Éloi Rivard", email="eloi@yaal.coop"}]
20
+ classifiers = [
21
+ "Intended Audience :: Developers",
22
+ "Development Status :: 4 - Beta",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Programming Language :: Python",
29
+ "Operating System :: OS Independent",
30
+ ]
31
+
32
+ [project.urls]
33
+ repository = "https://gitlab.com/pytest-dev/pytest-scim2-server"
16
34
 
17
35
  [dependency-groups]
18
36
  dev = [
@@ -1,6 +1,7 @@
1
1
  import threading
2
- import wsgiref.simple_server
3
2
  from dataclasses import dataclass
3
+ from wsgiref.simple_server import WSGIRequestHandler
4
+ from wsgiref.simple_server import make_server
4
5
 
5
6
  import portpicker
6
7
  import pytest
@@ -20,6 +21,19 @@ class Server:
20
21
  app: SCIMProvider
21
22
  """The scim2-server WSGI application."""
22
23
 
24
+ logging: bool = False
25
+ """Whether the request access log is enabled."""
26
+
27
+ def make_request_handler(self):
28
+ server = self
29
+
30
+ class RequestHandler(WSGIRequestHandler):
31
+ def log_request(self, code="-", size="-"):
32
+ if server.logging:
33
+ super().log_request(code, size)
34
+
35
+ return RequestHandler
36
+
23
37
 
24
38
  @pytest.fixture(scope="session")
25
39
  def scim2_server():
@@ -35,13 +49,16 @@ def scim2_server():
35
49
 
36
50
  host = "localhost"
37
51
  port = portpicker.pick_unused_port()
38
- httpd = wsgiref.simple_server.make_server(host, port, provider)
52
+
53
+ server = Server(port=port, app=provider)
54
+
55
+ httpd = make_server(
56
+ host, port, provider, handler_class=server.make_request_handler()
57
+ )
39
58
 
40
59
  server_thread = threading.Thread(target=httpd.serve_forever)
41
60
  server_thread.start()
42
61
 
43
- server = Server(port=port, app=provider)
44
-
45
62
  try:
46
63
  yield server
47
64
  finally: