pytest-scim2-server 0.1.0__py3-none-any.whl
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.
- pytest_scim2_server/__init__.py +34 -0
- pytest_scim2_server-0.1.0.dist-info/METADATA +60 -0
- pytest_scim2_server-0.1.0.dist-info/RECORD +6 -0
- pytest_scim2_server-0.1.0.dist-info/WHEEL +4 -0
- pytest_scim2_server-0.1.0.dist-info/entry_points.txt +2 -0
- pytest_scim2_server-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
import wsgiref.simple_server
|
|
3
|
+
|
|
4
|
+
import portpicker
|
|
5
|
+
import pytest
|
|
6
|
+
from scim2_server.backend import InMemoryBackend
|
|
7
|
+
from scim2_server.provider import SCIMProvider
|
|
8
|
+
from scim2_server.utils import load_default_resource_types
|
|
9
|
+
from scim2_server.utils import load_default_schemas
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@pytest.fixture(scope="session")
|
|
13
|
+
def scim2_server():
|
|
14
|
+
"""SCIM2 server running in a thread."""
|
|
15
|
+
backend = InMemoryBackend()
|
|
16
|
+
provider = SCIMProvider(backend)
|
|
17
|
+
|
|
18
|
+
for schema in load_default_schemas().values():
|
|
19
|
+
provider.register_schema(schema)
|
|
20
|
+
|
|
21
|
+
for resource_type in load_default_resource_types().values():
|
|
22
|
+
provider.register_resource_type(resource_type)
|
|
23
|
+
|
|
24
|
+
host = "localhost"
|
|
25
|
+
port = portpicker.pick_unused_port()
|
|
26
|
+
httpd = wsgiref.simple_server.make_server(host, port, provider)
|
|
27
|
+
|
|
28
|
+
server_thread = threading.Thread(target=httpd.serve_forever)
|
|
29
|
+
server_thread.start()
|
|
30
|
+
try:
|
|
31
|
+
yield host, port
|
|
32
|
+
finally:
|
|
33
|
+
httpd.shutdown()
|
|
34
|
+
server_thread.join()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytest-scim2-server
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: SCIM2 server fixture for Pytest
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: portpicker>=1.6.0
|
|
8
|
+
Requires-Dist: pytest>=8.3.4
|
|
9
|
+
Requires-Dist: scim2-server>=0.1.4
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# pytest-scim2-server
|
|
13
|
+
|
|
14
|
+
SCIM2 server fixture for Pytest
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
pip install pytest-scim2-server
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import requests
|
|
28
|
+
|
|
29
|
+
def test_scim_foobar(scim2_server):
|
|
30
|
+
host, port = scim2_server
|
|
31
|
+
|
|
32
|
+
res = request.get(f"http://{host}:{port}")
|
|
33
|
+
...
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Note that you can use [scim2-client](https://scim2-client.readthedocs.io) to interact with the SCIM server.
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import pytest
|
|
40
|
+
from httpx import Client
|
|
41
|
+
from scim2_client.engines.httpx import SyncSCIMClient
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@pytest.fixture(scope="session")
|
|
45
|
+
def scim_client(scim2_server):
|
|
46
|
+
host, port = scim2_server
|
|
47
|
+
http_client = Client(base_url=f"http://{host}:{port}")
|
|
48
|
+
scim_client = SyncSCIMClient(http_client)
|
|
49
|
+
scim_client.discover()
|
|
50
|
+
return scim_client
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_scim2_server(scim_client):
|
|
54
|
+
User = scim_client.get_resource_model("User")
|
|
55
|
+
user = User(user_name="bjensen@example.com")
|
|
56
|
+
response = scim_client.create(user)
|
|
57
|
+
|
|
58
|
+
users = scim_client.query(User)
|
|
59
|
+
assert users.resources[0].id == response.id
|
|
60
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
pytest_scim2_server/__init__.py,sha256=4I9JYCpksuhlFyKr44JgrBFTdcndfD_3d8xi-NdCJnk,994
|
|
2
|
+
pytest_scim2_server-0.1.0.dist-info/METADATA,sha256=XQZ5YFPkF8I784rdvKkAMUtqYWSgDAcFO_itngOVdmU,1480
|
|
3
|
+
pytest_scim2_server-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
4
|
+
pytest_scim2_server-0.1.0.dist-info/entry_points.txt,sha256=kfmqb12TI1m2tgtj4AIQq9AsZPGac_5WgOqIgksTypA,46
|
|
5
|
+
pytest_scim2_server-0.1.0.dist-info/licenses/LICENSE,sha256=PCIUf5J0_ii-LLZjs3eM4RN6IyfrKl9OioIdYPgUlpQ,1069
|
|
6
|
+
pytest_scim2_server-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Éloi Rivard
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|