Skip to content

Commit 23c845b

Browse files
authored
Merge pull request #25 from python-scim/scim2-tester-0.3
Bump to scim2-tester 0.3
2 parents 656ab00 + 4343069 commit 23c845b

16 files changed

Lines changed: 344 additions & 139 deletions

‎doc/changelog.rst‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
Changelog
22
=========
33

4+
[Unreleased]
5+
------------
6+
7+
Changed
8+
^^^^^^^
9+
- scim2-client 0.8.0 and scim2-tester 0.3.0 are now the minimum supported versions.
10+
- Requests are performed with `httpx2 <https://github.com/pydantic/httpx2>`_ instead of
11+
httpx, following the scim2-client 0.8 engine rename.
12+
- :ref:`query` only sends the ``attributes`` and ``excludedAttributes`` parameters when a
13+
single resource is queried, as :rfc:`RFC7644 §3.4.1 <7644#section-3.4.1>` defines those
14+
as the sole parameters of that request. ``--start-index``, ``--count``, ``--filter``,
15+
``--sort-by`` and ``--sort-order`` are refused in that case, instead of being sent along.
16+
17+
Fixed
18+
^^^^^
19+
- Server SCIM errors and invalid request payloads are reported as readable messages
20+
instead of a traceback. scim2-client 0.8 raises the scim2-models exceptions for those,
21+
which do not belong to its own exception hierarchy.
22+
- The :ref:`test` ``--dont-check-status-code`` and ``--dont-check-content-type`` options
23+
were not applied on the client.
24+
425
[0.2.4] - 2026-01-25
526
--------------------
627

‎doc/conf.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
pygments_style = "sphinx"
5151
todo_include_todos = True
5252
toctree_collapse = False
53+
suppress_warnings = ["autosectionlabel.changelog"]
5354

5455
intersphinx_mapping = {
5556
"python": ("https://docs.python.org/3", None),

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ classifiers = [
2828
requires-python = ">= 3.10"
2929
dependencies = [
3030
"click>=8.1.7",
31-
"scim2-client>=0.7.1",
32-
"scim2-tester[httpx]>=0.2.5",
31+
"scim2-client[httpx2]>=0.8.0",
32+
"scim2-tester>=0.3.0",
3333
"sphinx-click-rst-to-ansi-formatter>=0.1.0",
3434
"pydanclick>=0.4.0",
3535
"pygments>=2.18.0",

‎scim2_cli/__init__.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import re
33

44
import click
5-
from httpx import Client
6-
from scim2_client import SCIMClientError
7-
from scim2_client.engines.httpx import SyncSCIMClient
5+
from httpx2 import Client
6+
from scim2_client.engines.httpx2 import SyncSCIMClient
87
from scim2_models import Group
98
from scim2_models import ListResponse
109
from scim2_models import Resource
@@ -21,6 +20,7 @@
2120
from scim2_cli.search import search_cli
2221
from scim2_cli.test import test_cli
2322
from scim2_cli.utils import DOC_URL
23+
from scim2_cli.utils import SCIM_EXCEPTIONS
2424
from scim2_cli.utils import HeaderType
2525
from scim2_cli.utils import exception_to_click_error
2626
from scim2_cli.utils import split_headers
@@ -138,7 +138,7 @@ def cli(
138138
resource_types=not bool(resource_types),
139139
service_provider_config=not bool(service_provider_config),
140140
)
141-
except SCIMClientError as exc:
141+
except SCIM_EXCEPTIONS as exc:
142142
raise exception_to_click_error(exc) from exc
143143

144144
ctx.obj["client"] = scim_client

‎scim2_cli/create.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import click
22
from click import ClickException
33
from pydanclick import from_pydantic
4-
from scim2_client import SCIMClientError
54
from scim2_models import Context
65
from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
76

87
from scim2_cli.utils import DOC_URL
8+
from scim2_cli.utils import SCIM_EXCEPTIONS
99
from scim2_cli.utils import ModelCommand
1010
from scim2_cli.utils import exception_to_click_error
1111
from scim2_cli.utils import formatted_payload
@@ -16,7 +16,7 @@ def create_payload(client, payload, indent):
1616
try:
1717
response = client.create(payload, raise_scim_errors=False)
1818

19-
except SCIMClientError as scim_exc:
19+
except SCIM_EXCEPTIONS as scim_exc:
2020
raise exception_to_click_error(scim_exc) from scim_exc
2121

2222
payload = formatted_payload(response.model_dump(), indent)

‎scim2_cli/delete.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import click
22
from click import ClickException
3-
from scim2_client import SCIMClientError
43
from scim2_models import Message
54
from scim2_models import Resource
65
from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
76

87
from scim2_cli.utils import exception_to_click_error
98

109
from .utils import DOC_URL
10+
from .utils import SCIM_EXCEPTIONS
1111
from .utils import formatted_payload
1212

1313

@@ -39,7 +39,7 @@ def delete_cli(ctx, resource_type, id, indent):
3939
try:
4040
response = ctx.obj["client"].delete(resource_model, id, raise_scim_errors=False)
4141

42-
except SCIMClientError as scim_exc:
42+
except SCIM_EXCEPTIONS as scim_exc:
4343
raise exception_to_click_error(scim_exc) from scim_exc
4444

4545
if response:

‎scim2_cli/query.py‎

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import click
22
from click import ClickException
3-
from scim2_client import SCIMClientError
43
from scim2_models import ResourceType
4+
from scim2_models import ResponseParameters
55
from scim2_models import Schema
66
from scim2_models import SearchRequest
77
from scim2_models import ServiceProviderConfig
@@ -10,6 +10,7 @@
1010
from scim2_cli.utils import exception_to_click_error
1111

1212
from .utils import DOC_URL
13+
from .utils import SCIM_EXCEPTIONS
1314
from .utils import formatted_payload
1415

1516

@@ -73,6 +74,9 @@ def query_cli(
7374
- If :code:`RESOURCE_TYPE` is :code:`user` and :code:`id` is not set, then the request will made on the :code:`/Users` endpoint.
7475
- If :code:`RESOURCE_TYPE` is not set, then the request will made on the :code:`/` endpoint.
7576
77+
When a single resource is queried, only :code:`--attribute` and :code:`--excluded-attribute` are
78+
available, as defined in `RFC7644 §3.4.1 <https://www.rfc-editor.org/rfc/rfc7644#section-3.4.1>`_.
79+
7680
Data passed in JSON format to stdin is sent as request arguments and all the other query arguments are ignored:
7781
7882
.. code-block:: bash
@@ -92,10 +96,35 @@ def query_cli(
9296
f"Unknown resource type '{resource_type}. Available values are: {ok_values}'"
9397
) from exc
9498

99+
# ServiceProviderConfig is a singleton endpoint, so it is reached without an id.
100+
single_resource = bool(id) or resource_type is ServiceProviderConfig
101+
listing_options = [
102+
name
103+
for name, value in (
104+
("--start-index", start_index),
105+
("--count", count),
106+
("--filter", filter),
107+
("--sort-by", sort_by),
108+
("--sort-order", sort_order),
109+
)
110+
if value is not None
111+
]
112+
if single_resource and listing_options:
113+
raise ClickException(
114+
f"{', '.join(listing_options)} cannot be used when querying a single resource."
115+
)
116+
95117
if ctx.obj.get("stdin"):
96118
check_request_payload = False
97119
payload = ctx.obj.get("stdin")
98120

121+
elif single_resource:
122+
check_request_payload = True
123+
payload = ResponseParameters(
124+
attributes=attribute,
125+
excluded_attributes=excluded_attribute,
126+
)
127+
99128
else:
100129
check_request_payload = True
101130
payload = SearchRequest(
@@ -112,12 +141,12 @@ def query_cli(
112141
response = ctx.obj["client"].query(
113142
resource_type,
114143
id,
115-
search_request=payload,
144+
query_parameters=payload,
116145
check_request_payload=check_request_payload,
117146
raise_scim_errors=False,
118147
)
119148

120-
except SCIMClientError as scim_exc:
149+
except SCIM_EXCEPTIONS as scim_exc:
121150
raise exception_to_click_error(scim_exc) from scim_exc
122151

123152
payload = formatted_payload(response.model_dump(), indent)

‎scim2_cli/replace.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import click
22
from click import ClickException
33
from pydanclick import from_pydantic
4-
from scim2_client import SCIMClientError
54
from scim2_models import Context
65
from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
76

87
from scim2_cli.utils import exception_to_click_error
98

109
from .utils import DOC_URL
10+
from .utils import SCIM_EXCEPTIONS
1111
from .utils import ModelCommand
1212
from .utils import formatted_payload
1313
from .utils import unacceptable_fields
@@ -17,7 +17,7 @@ def replace_payload(client, payload, indent):
1717
try:
1818
response = client.replace(payload, raise_scim_errors=False)
1919

20-
except SCIMClientError as scim_exc:
20+
except SCIM_EXCEPTIONS as scim_exc:
2121
raise exception_to_click_error(scim_exc) from scim_exc
2222

2323
payload = formatted_payload(response.model_dump(), indent)

‎scim2_cli/search.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import click
2-
from scim2_client import SCIMClientError
32
from scim2_models import SearchRequest
43
from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
54

65
from scim2_cli.utils import exception_to_click_error
76

87
from .utils import DOC_URL
8+
from .utils import SCIM_EXCEPTIONS
99
from .utils import formatted_payload
1010

1111

@@ -91,7 +91,7 @@ def search_cli(
9191
raise_scim_errors=False,
9292
)
9393

94-
except SCIMClientError as scim_exc:
94+
except SCIM_EXCEPTIONS as scim_exc:
9595
raise exception_to_click_error(scim_exc) from scim_exc
9696

9797
payload = formatted_payload(response.model_dump(), indent)

‎scim2_cli/test.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def test_cli(ctx, verbose, check_status_code, check_content_type):
3232
test
3333
"""
3434
client = ctx.obj["client"]
35-
client.check_status_code = check_status_code
36-
client.check_content_type = check_content_type
35+
client.check_response_status_codes = check_status_code
36+
client.check_response_content_type = check_content_type
3737
results = check_server(client)
3838
click.echo(f"Performing a SCIM compliance check on {client.client.base_url} ...")
3939
success = True

0 commit comments

Comments
 (0)