Metadata-Version: 2.4
Name: pytest-scim2-server
Version: 0.2.0
Summary: SCIM2 server fixture for Pytest
Keywords: pytest,fixture,scim,scim2,rfc7643,rfc7644
Author: Yaal Coop
Author-email: Yaal Coop <contact@yaal.coop>
License-Expression: MIT
License-File: LICENSE
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python
Classifier: Operating System :: OS Independent
Requires-Dist: portpicker>=1.6.0
Requires-Dist: pytest>=8.3.4
Requires-Dist: scim2-server>=0.3.0
Maintainer: Éloi Rivard
Maintainer-email: Éloi Rivard <eloi@yaal.coop>
Requires-Python: >=3.11
Project-URL: repository, https://github.com/pytest-dev/pytest-scim2-server
Description-Content-Type: text/markdown

# pytest-scim2-server

SCIM2 server fixture for Pytest

## Installation

```
pip install pytest-scim2-server
```

## Usage

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.

```python
import requests


def test_scim_foobar(scim2_server):
    res = request.get(f"http://localhost:{scim2_server.port}")
    ...
```

Note that you can use [scim2-client](https://scim2-client.readthedocs.io) to interact with the SCIM server.

```python
import pytest
from httpx2 import Client
from scim2_client.engines.httpx2 import SyncSCIMClient


@pytest.fixture(scope="session")
def scim_client(scim2_server):
    http_client = Client(base_url=f"http://localhost:{scim2_server.port}")
    scim_client = SyncSCIMClient(http_client)
    scim_client.discover()
    return scim_client


def test_scim2_server(scim_client):
    User = scim_client.get_resource_model("User")
    user = User(user_name="bjensen@example.com")
    response = scim_client.create(user)

    users = scim_client.query(User)
    assert users.resources[0].id == response.id
```

## Related projects

If you are working with SCIM and Python you might also want to have a look at:
- [scim2-models](https://scim2-models.readthedocs.io)
- [scim2-client](https://scim2-client.readthedocs.io)
- [scim2-cli](https://scim2-cli.readthedocs.io)
- [scim2-tester](https://scim2-tester.readthedocs.io)
