scim2-cli 0.2.0__tar.gz → 0.2.1__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 (37) hide show
  1. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/PKG-INFO +1 -1
  2. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/doc/changelog.rst +8 -0
  3. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/doc/tutorial.rst +30 -2
  4. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/pyproject.toml +1 -1
  5. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/__init__.py +25 -9
  6. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/create.py +6 -13
  7. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/delete.py +3 -9
  8. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/query.py +3 -9
  9. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/replace.py +3 -9
  10. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/search.py +3 -10
  11. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/utils.py +10 -0
  12. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_cli.py +163 -14
  13. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/.github/FUNDING.yml +0 -0
  14. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/.github/workflows/release.yml +0 -0
  15. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/.github/workflows/tests.yaml +0 -0
  16. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/.gitignore +0 -0
  17. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/.pre-commit-config.yaml +0 -0
  18. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/.readthedocs.yml +0 -0
  19. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/LICENSE.md +0 -0
  20. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/README.md +0 -0
  21. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/doc/__init__.py +0 -0
  22. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/doc/conf.py +0 -0
  23. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/doc/contributing.rst +0 -0
  24. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/doc/index.rst +0 -0
  25. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/doc/reference.rst +0 -0
  26. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/py.typed +0 -0
  27. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/scim2_cli/test.py +0 -0
  28. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/__init__.py +0 -0
  29. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/conftest.py +0 -0
  30. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_create.py +0 -0
  31. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_delete.py +0 -0
  32. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_query.py +0 -0
  33. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_replace.py +0 -0
  34. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_search.py +0 -0
  35. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_test.py +0 -0
  36. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/tests/test_utils.py +0 -0
  37. {scim2_cli-0.2.0 → scim2_cli-0.2.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: scim2-cli
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: SCIM application development CLI
5
5
  Project-URL: documentation, https://scim2-cli.readthedocs.io
6
6
  Project-URL: repository, https://github.com/python-scim/scim2-cli
@@ -1,6 +1,14 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ [0.2.1] - 2024-12-04
5
+ --------------------
6
+
7
+ Added
8
+ ^^^^^
9
+ - Display server discovery step network connections.
10
+ - Support loading server configuration objects in :class:`~scim2_models.ListResponses`.
11
+
4
12
  [0.2.0] - 2024-12-03
5
13
  --------------------
6
14
 
@@ -6,8 +6,8 @@ The :ref:`cli` command allows you to interact with a SCIM server.
6
6
  Basic parameters
7
7
  ----------------
8
8
 
9
- In order to connect to a SCIM server you will need to pass the :option:`scim --url` parameter.
10
- You can also pass additional headers, such as authentication ones, with :option:`scim --url`.
9
+ In order to connect to a SCIM server you will need to pass the :option:`--url <scim --url>` parameter.
10
+ You can also pass additional headers, such as authentication ones, with :option:`--header <scim --header>`.
11
11
 
12
12
  .. code-block:: shell
13
13
 
@@ -45,3 +45,31 @@ To make commands shorter, you can set those parameters once for all by using the
45
45
  "location": "https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646",
46
46
  },
47
47
  }
48
+
49
+
50
+ Server configuration
51
+ --------------------
52
+
53
+ The CLI needs to reach the server configuration to find out which features are available,
54
+ which resource schemas are available, and where they are located.
55
+
56
+ By default the CLI will automatically discover those resources on the server, before each command is run.
57
+
58
+ However you might find too time consuming to achieve all those network requests.
59
+ You can store those data locally and reuse them for future command runs thanks to the
60
+ :option:`--schemas <scim --schemas>`, :option:`--resource-types <scim --resource-types>` and :option:`--service-provider-config <scim --service-provider-config>` (and their corresponding environment vars :ref:`SCIM_CLI_SCHEMAS <scim-schemas-scim_cli_schemas>`, :ref:`SCIM_CLI_RESOURCE_TYPES <scim-resource_types-scim_cli_resource_types>` and :ref:`SCIM_CLI_SERVICE_PROVIDER_CONFIG <scim-service_provider_config-scim_cli_service_provider_config>`)
61
+
62
+ .. code-block:: shell
63
+ :caption: Save the configuration resources
64
+
65
+ $ scim query schema > /tmp/schemas.json
66
+ $ scim query resourcetype > /tmp/resource-types.json
67
+ $ scim query serviceproviderconfig > /tmp/service-provider-config.json
68
+
69
+ .. code-block:: shell
70
+ :caption: Load the cached resources
71
+
72
+ $ export SCIM_SCHEMAS=/tmp/schemas.json
73
+ $ export SCIM_RESOURCE_TYPES=/tmp/resource-types.json
74
+ $ export SCIM_SERVICE_PROVIDER_CONFIG=/tmp/service-provider-config.json
75
+ $ scim2 query ...
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "scim2-cli"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  description = "SCIM application development CLI"
9
9
  authors = [{name="Yaal Coop", email="contact@yaal.coop"}]
10
10
  license = {file = "LICENSE.md"}
@@ -6,8 +6,10 @@ from typing import TypeGuard
6
6
  import click
7
7
  from httpx import Client
8
8
  from pydantic import BaseModel
9
+ from scim2_client import SCIMClientError
9
10
  from scim2_client.engines.httpx import SyncSCIMClient
10
11
  from scim2_models import Group
12
+ from scim2_models import ListResponse
11
13
  from scim2_models import Resource
12
14
  from scim2_models import ResourceType
13
15
  from scim2_models import Schema
@@ -23,6 +25,7 @@ from scim2_cli.search import search_cli
23
25
  from scim2_cli.test import test_cli
24
26
  from scim2_cli.utils import DOC_URL
25
27
  from scim2_cli.utils import HeaderType
28
+ from scim2_cli.utils import exception_to_click_error
26
29
  from scim2_cli.utils import split_headers
27
30
 
28
31
 
@@ -51,7 +54,10 @@ def load_config_files(
51
54
  ]:
52
55
  if schemas_fd:
53
56
  schemas_payload = json.load(schemas_fd)
54
- schemas_obj = [Schema.model_validate(schema) for schema in schemas_payload]
57
+ if isinstance(schemas_payload, dict):
58
+ schemas_obj = ListResponse[Schema].model_validate(schemas_payload).resources
59
+ else:
60
+ schemas_obj = [Schema.model_validate(schema) for schema in schemas_payload]
55
61
  resource_models = [Resource.from_schema(schema) for schema in schemas_obj]
56
62
 
57
63
  else:
@@ -59,9 +65,16 @@ def load_config_files(
59
65
 
60
66
  if resource_types_fd:
61
67
  resource_types_payload = json.load(resource_types_fd)
62
- resource_types = [
63
- ResourceType.model_validate(item) for item in resource_types_payload
64
- ]
68
+ if isinstance(schemas_payload, dict):
69
+ resource_types = (
70
+ ListResponse[ResourceType]
71
+ .model_validate(resource_types_payload)
72
+ .resources
73
+ )
74
+ else:
75
+ resource_types = [
76
+ ResourceType.model_validate(item) for item in resource_types_payload
77
+ ]
65
78
  else:
66
79
  resource_types = None
67
80
 
@@ -128,11 +141,14 @@ def cli(
128
141
  resource_types=resource_types_obj,
129
142
  service_provider_config=spc_obj,
130
143
  )
131
- scim_client.discover(
132
- schemas=not bool(schemas),
133
- resource_types=not bool(resource_types),
134
- service_provider_config=not bool(service_provider_config),
135
- )
144
+ try:
145
+ scim_client.discover(
146
+ schemas=not bool(schemas),
147
+ resource_types=not bool(resource_types),
148
+ service_provider_config=not bool(service_provider_config),
149
+ )
150
+ except SCIMClientError as exc:
151
+ raise exception_to_click_error(exc) from exc
136
152
 
137
153
  ctx.obj["client"] = scim_client
138
154
  ctx.obj["resource_models"] = {
@@ -1,5 +1,3 @@
1
- import sys
2
-
3
1
  import click
4
2
  from click import ClickException
5
3
  from pydanclick import from_pydantic
@@ -7,10 +5,11 @@ from scim2_client import SCIMClientError
7
5
  from scim2_models import Context
8
6
  from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
9
7
 
10
- from .utils import DOC_URL
11
- from .utils import ModelCommand
12
- from .utils import formatted_payload
13
- from .utils import unacceptable_fields
8
+ from scim2_cli.utils import DOC_URL
9
+ from scim2_cli.utils import ModelCommand
10
+ from scim2_cli.utils import exception_to_click_error
11
+ from scim2_cli.utils import formatted_payload
12
+ from scim2_cli.utils import unacceptable_fields
14
13
 
15
14
 
16
15
  def create_payload(client, payload, indent):
@@ -18,13 +17,7 @@ def create_payload(client, payload, indent):
18
17
  response = client.create(payload, raise_scim_errors=False)
19
18
 
20
19
  except SCIMClientError as scim_exc:
21
- message = str(scim_exc)
22
- if sys.version_info >= (3, 11) and hasattr(
23
- scim_exc, "__notes__"
24
- ): # pragma: no cover
25
- for note in scim_exc.__notes__:
26
- message = f"{message}\n{note}"
27
- raise ClickException(message) from scim_exc
20
+ raise exception_to_click_error(scim_exc) from scim_exc
28
21
 
29
22
  payload = formatted_payload(response.model_dump(), indent)
30
23
  click.echo(payload)
@@ -1,5 +1,3 @@
1
- import sys
2
-
3
1
  import click
4
2
  from click import ClickException
5
3
  from scim2_client import SCIMClientError
@@ -7,6 +5,8 @@ from scim2_models import Message
7
5
  from scim2_models import Resource
8
6
  from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
9
7
 
8
+ from scim2_cli.utils import exception_to_click_error
9
+
10
10
  from .utils import DOC_URL
11
11
  from .utils import formatted_payload
12
12
 
@@ -40,13 +40,7 @@ def delete_cli(ctx, resource_type, id, indent):
40
40
  response = ctx.obj["client"].delete(resource_model, id, raise_scim_errors=False)
41
41
 
42
42
  except SCIMClientError as scim_exc:
43
- message = str(scim_exc)
44
- if sys.version_info >= (3, 11) and hasattr(
45
- scim_exc, "__notes__"
46
- ): # pragma: no cover
47
- for note in scim_exc.__notes__:
48
- message = f"{message}\n{note}"
49
- raise ClickException(message) from scim_exc
43
+ raise exception_to_click_error(scim_exc) from scim_exc
50
44
 
51
45
  if response:
52
46
  payload = (
@@ -1,5 +1,3 @@
1
- import sys
2
-
3
1
  import click
4
2
  from click import ClickException
5
3
  from scim2_client import SCIMClientError
@@ -9,6 +7,8 @@ from scim2_models import SearchRequest
9
7
  from scim2_models import ServiceProviderConfig
10
8
  from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
11
9
 
10
+ from scim2_cli.utils import exception_to_click_error
11
+
12
12
  from .utils import DOC_URL
13
13
  from .utils import formatted_payload
14
14
 
@@ -118,13 +118,7 @@ def query_cli(
118
118
  )
119
119
 
120
120
  except SCIMClientError as scim_exc:
121
- message = str(scim_exc)
122
- if sys.version_info >= (3, 11) and hasattr(
123
- scim_exc, "__notes__"
124
- ): # pragma: no cover
125
- for note in scim_exc.__notes__:
126
- message = f"{message}\n{note}"
127
- raise ClickException(message) from scim_exc
121
+ raise exception_to_click_error(scim_exc) from scim_exc
128
122
 
129
123
  payload = formatted_payload(response.model_dump(), indent)
130
124
  click.echo(payload)
@@ -1,5 +1,3 @@
1
- import sys
2
-
3
1
  import click
4
2
  from click import ClickException
5
3
  from pydanclick import from_pydantic
@@ -7,6 +5,8 @@ from scim2_client import SCIMClientError
7
5
  from scim2_models import Context
8
6
  from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
9
7
 
8
+ from scim2_cli.utils import exception_to_click_error
9
+
10
10
  from .utils import DOC_URL
11
11
  from .utils import ModelCommand
12
12
  from .utils import formatted_payload
@@ -18,13 +18,7 @@ def replace_payload(client, payload, indent):
18
18
  response = client.replace(payload, raise_scim_errors=False)
19
19
 
20
20
  except SCIMClientError as scim_exc:
21
- message = str(scim_exc)
22
- if sys.version_info >= (3, 11) and hasattr(
23
- scim_exc, "__notes__"
24
- ): # pragma: no cover
25
- for note in scim_exc.__notes__:
26
- message = f"{message}\n{note}"
27
- raise ClickException(message) from scim_exc
21
+ raise exception_to_click_error(scim_exc) from scim_exc
28
22
 
29
23
  payload = formatted_payload(response.model_dump(), indent)
30
24
  click.echo(payload)
@@ -1,11 +1,10 @@
1
- import sys
2
-
3
1
  import click
4
- from click import ClickException
5
2
  from scim2_client import SCIMClientError
6
3
  from scim2_models import SearchRequest
7
4
  from sphinx_click.rst_to_ansi_formatter import make_rst_to_ansi_formatter
8
5
 
6
+ from scim2_cli.utils import exception_to_click_error
7
+
9
8
  from .utils import DOC_URL
10
9
  from .utils import formatted_payload
11
10
 
@@ -93,13 +92,7 @@ def search_cli(
93
92
  )
94
93
 
95
94
  except SCIMClientError as scim_exc:
96
- message = str(scim_exc)
97
- if sys.version_info >= (3, 11) and hasattr(
98
- scim_exc, "__notes__"
99
- ): # pragma: no cover
100
- for note in scim_exc.__notes__:
101
- message = f"{message}\n{note}"
102
- raise ClickException(message) from scim_exc
95
+ raise exception_to_click_error(scim_exc) from scim_exc
103
96
 
104
97
  payload = formatted_payload(response.model_dump(), indent)
105
98
  click.echo(payload)
@@ -1,4 +1,5 @@
1
1
  import json
2
+ import sys
2
3
  from enum import Enum
3
4
 
4
5
  import click
@@ -104,3 +105,12 @@ def unacceptable_fields(context, model):
104
105
  for field_name in model.model_fields
105
106
  if not is_field_acceptable(context, model, field_name)
106
107
  ]
108
+
109
+
110
+ def exception_to_click_error(exception):
111
+ message = str(exception)
112
+ if sys.version_info >= (3, 11) and hasattr(
113
+ exception, "__notes__"
114
+ ): # pragma: no cover
115
+ message += "\n" + "\n".join(exception.__notes__)
116
+ return click.ClickException(message)
@@ -1,13 +1,16 @@
1
1
  import json
2
2
  import os
3
3
 
4
+ import pytest
4
5
  from scim2_models import AuthenticationScheme
5
6
  from scim2_models import Bulk
6
7
  from scim2_models import ChangePassword
7
8
  from scim2_models import ETag
8
9
  from scim2_models import Filter
10
+ from scim2_models import ListResponse
9
11
  from scim2_models import Patch
10
12
  from scim2_models import ResourceType
13
+ from scim2_models import Schema
11
14
  from scim2_models import ServiceProviderConfig
12
15
  from scim2_models import Sort
13
16
  from scim2_models import User
@@ -27,6 +30,13 @@ def test_help(runner):
27
30
  assert "SCIM application development CLI.\n" in result.output
28
31
 
29
32
 
33
+ def test_bad_server(runner):
34
+ """Test that the discovery step display a readable error when a bad server has been passed."""
35
+ result = runner.invoke(cli, ["--url", "http://scim.invalid", "query"])
36
+ assert result.exit_code == 1
37
+ assert "Error: Network error happened during request\n" in result.output
38
+
39
+
30
40
  def test_stdin_bad_json(runner, httpserver):
31
41
  """Test that invalid JSON stdin raise an error."""
32
42
  result = runner.invoke(
@@ -105,9 +115,9 @@ def test_env_vars(runner, httpserver, simple_user_payload):
105
115
  del os.environ["SCIM_CLI_HEADERS"]
106
116
 
107
117
 
108
- def test_custom_configuration(runner, httpserver, simple_user_payload, tmp_path):
109
- """Test passing custom .JSON configuration files to the command."""
110
- spc = ServiceProviderConfig(
118
+ @pytest.fixture
119
+ def service_provider_configuration():
120
+ return ServiceProviderConfig(
111
121
  documentation_uri="https://scim.test",
112
122
  patch=Patch(supported=False),
113
123
  bulk=Bulk(supported=False, max_operations=0, max_payload_size=0),
@@ -125,29 +135,48 @@ def test_custom_configuration(runner, httpserver, simple_user_payload, tmp_path)
125
135
  primary=True,
126
136
  ),
127
137
  ],
128
- ).model_dump()
138
+ )
129
139
 
130
- spc_path = tmp_path / "service_provider_configuration.json"
131
- with open(spc_path, "w") as fd:
132
- json.dump(spc, fd)
133
140
 
134
- schemas = [User.to_schema().model_dump()]
135
- schemas_path = tmp_path / "schemas.json"
136
- with open(schemas_path, "w") as fd:
137
- json.dump(schemas, fd)
141
+ @pytest.fixture
142
+ def schemas():
143
+ return [User.to_schema()]
138
144
 
139
- resource_types = [
145
+
146
+ @pytest.fixture
147
+ def resource_types():
148
+ return [
140
149
  ResourceType(
141
150
  id="User",
142
151
  name="User",
143
152
  endpoint="/somewhere-different",
144
153
  description="User accounts",
145
154
  schema_="urn:ietf:params:scim:schemas:core:2.0:User",
146
- ).model_dump()
155
+ )
147
156
  ]
157
+
158
+
159
+ def test_custom_configuration_by_parameter(
160
+ runner,
161
+ httpserver,
162
+ simple_user_payload,
163
+ tmp_path,
164
+ service_provider_configuration,
165
+ schemas,
166
+ resource_types,
167
+ ):
168
+ """Test passing custom .JSON configuration files to the command."""
169
+ spc_path = tmp_path / "service_provider_configuration.json"
170
+ with open(spc_path, "w") as fd:
171
+ json.dump(service_provider_configuration.model_dump(), fd)
172
+
173
+ schemas_path = tmp_path / "schemas.json"
174
+ with open(schemas_path, "w") as fd:
175
+ json.dump([schema.model_dump() for schema in schemas], fd)
176
+
148
177
  resource_types_path = tmp_path / "resource_types.json"
149
178
  with open(resource_types_path, "w") as fd:
150
- json.dump(resource_types, fd)
179
+ json.dump([resource_type.model_dump() for resource_type in resource_types], fd)
151
180
 
152
181
  httpserver.expect_request(
153
182
  "/somewhere-different/foobar",
@@ -176,3 +205,123 @@ def test_custom_configuration(runner, httpserver, simple_user_payload, tmp_path)
176
205
  catch_exceptions=False,
177
206
  )
178
207
  assert result.exit_code == 0
208
+
209
+
210
+ def test_custom_configuration_in_list_response(
211
+ runner,
212
+ httpserver,
213
+ simple_user_payload,
214
+ tmp_path,
215
+ service_provider_configuration,
216
+ schemas,
217
+ resource_types,
218
+ ):
219
+ """Test that ListResponse format is supported."""
220
+ spc_path = tmp_path / "service_provider_configuration.json"
221
+ with open(spc_path, "w") as fd:
222
+ json.dump(service_provider_configuration.model_dump(), fd)
223
+
224
+ schemas_path = tmp_path / "schemas.json"
225
+ with open(schemas_path, "w") as fd:
226
+ json.dump(
227
+ ListResponse[Schema](
228
+ total_results=len(schemas),
229
+ start_index=1,
230
+ items_per_page=len(schemas),
231
+ resources=schemas,
232
+ ).model_dump(),
233
+ fd,
234
+ )
235
+
236
+ resource_types_path = tmp_path / "resource_types.json"
237
+ with open(resource_types_path, "w") as fd:
238
+ json.dump(
239
+ ListResponse[ResourceType](
240
+ total_results=len(resource_types),
241
+ start_index=1,
242
+ items_per_page=len(resource_types),
243
+ resources=resource_types,
244
+ ).model_dump(),
245
+ fd,
246
+ )
247
+
248
+ httpserver.expect_request(
249
+ "/somewhere-different/foobar",
250
+ method="GET",
251
+ ).respond_with_json(
252
+ simple_user_payload("foobar"),
253
+ status=200,
254
+ content_type="application/scim+json",
255
+ )
256
+
257
+ result = runner.invoke(
258
+ cli,
259
+ [
260
+ "--url",
261
+ httpserver.url_for("/"),
262
+ "--service-provider-config",
263
+ spc_path,
264
+ "--schemas",
265
+ schemas_path,
266
+ "--resource-types",
267
+ resource_types_path,
268
+ "query",
269
+ "user",
270
+ "foobar",
271
+ ],
272
+ catch_exceptions=False,
273
+ )
274
+ assert result.exit_code == 0
275
+
276
+
277
+ def test_custom_configuration_by_env(
278
+ runner,
279
+ httpserver,
280
+ simple_user_payload,
281
+ tmp_path,
282
+ service_provider_configuration,
283
+ schemas,
284
+ resource_types,
285
+ ):
286
+ """Test passing custom .JSON configuration files to the command."""
287
+ spc_path = tmp_path / "service_provider_configuration.json"
288
+ with open(spc_path, "w") as fd:
289
+ json.dump(service_provider_configuration.model_dump(), fd)
290
+
291
+ schemas_path = tmp_path / "schemas.json"
292
+ with open(schemas_path, "w") as fd:
293
+ json.dump([schema.model_dump() for schema in schemas], fd)
294
+
295
+ resource_types_path = tmp_path / "resource_types.json"
296
+ with open(resource_types_path, "w") as fd:
297
+ json.dump([resource_type.model_dump() for resource_type in resource_types], fd)
298
+
299
+ httpserver.expect_request(
300
+ "/somewhere-different/foobar",
301
+ method="GET",
302
+ ).respond_with_json(
303
+ simple_user_payload("foobar"),
304
+ status=200,
305
+ content_type="application/scim+json",
306
+ )
307
+
308
+ os.environ["SCIM_CLI_SERVICE_PROVIDER_CONFIG"] = str(spc_path)
309
+ os.environ["SCIM_CLI_SCHEMAS"] = str(schemas_path)
310
+ os.environ["SCIM_CLI_RESOURCE_TYPES"] = str(resource_types_path)
311
+ try:
312
+ result = runner.invoke(
313
+ cli,
314
+ [
315
+ "--url",
316
+ httpserver.url_for("/"),
317
+ "query",
318
+ "user",
319
+ "foobar",
320
+ ],
321
+ catch_exceptions=False,
322
+ )
323
+ assert result.exit_code == 0
324
+ finally:
325
+ del os.environ["SCIM_CLI_SERVICE_PROVIDER_CONFIG"]
326
+ del os.environ["SCIM_CLI_SCHEMAS"]
327
+ del os.environ["SCIM_CLI_RESOURCE_TYPES"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes