@@ -112,7 +112,9 @@ def test_env_vars(runner, httpserver, simple_user_payload):
112112 del os .environ ["SCIM_CLI_HEADERS" ]
113113
114114
115- def test_custom_configuration (runner , httpserver , simple_user_payload , tmp_path ):
115+ def test_custom_configuration_by_parameter (
116+ runner , httpserver , simple_user_payload , tmp_path
117+ ):
116118 """Test passing custom .JSON configuration files to the command."""
117119 spc = ServiceProviderConfig (
118120 documentation_uri = "https://scim.test" ,
@@ -183,3 +185,78 @@ def test_custom_configuration(runner, httpserver, simple_user_payload, tmp_path)
183185 catch_exceptions = False ,
184186 )
185187 assert result .exit_code == 0
188+
189+
190+ def test_custom_configuration_by_env (runner , httpserver , simple_user_payload , tmp_path ):
191+ """Test passing custom .JSON configuration files to the command."""
192+ spc = ServiceProviderConfig (
193+ documentation_uri = "https://scim.test" ,
194+ patch = Patch (supported = False ),
195+ bulk = Bulk (supported = False , max_operations = 0 , max_payload_size = 0 ),
196+ change_password = ChangePassword (supported = True ),
197+ filter = Filter (supported = False , max_results = 0 ),
198+ sort = Sort (supported = False ),
199+ etag = ETag (supported = False ),
200+ authentication_schemes = [
201+ AuthenticationScheme (
202+ name = "OAuth Bearer Token" ,
203+ description = "Authentication scheme using the OAuth Bearer Token Standard" ,
204+ spec_uri = "http://www.rfc-editor.org/info/rfc6750" ,
205+ documentation_uri = "https://scim.test" ,
206+ type = "oauthbearertoken" ,
207+ primary = True ,
208+ ),
209+ ],
210+ ).model_dump ()
211+
212+ spc_path = tmp_path / "service_provider_configuration.json"
213+ with open (spc_path , "w" ) as fd :
214+ json .dump (spc , fd )
215+
216+ schemas = [User .to_schema ().model_dump ()]
217+ schemas_path = tmp_path / "schemas.json"
218+ with open (schemas_path , "w" ) as fd :
219+ json .dump (schemas , fd )
220+
221+ resource_types = [
222+ ResourceType (
223+ id = "User" ,
224+ name = "User" ,
225+ endpoint = "/somewhere-different" ,
226+ description = "User accounts" ,
227+ schema_ = "urn:ietf:params:scim:schemas:core:2.0:User" ,
228+ ).model_dump ()
229+ ]
230+ resource_types_path = tmp_path / "resource_types.json"
231+ with open (resource_types_path , "w" ) as fd :
232+ json .dump (resource_types , fd )
233+
234+ httpserver .expect_request (
235+ "/somewhere-different/foobar" ,
236+ method = "GET" ,
237+ ).respond_with_json (
238+ simple_user_payload ("foobar" ),
239+ status = 200 ,
240+ content_type = "application/scim+json" ,
241+ )
242+
243+ os .environ ["SCIM_CLI_SERVICE_PROVIDER_CONFIG" ] = str (spc_path )
244+ os .environ ["SCIM_CLI_SCHEMAS" ] = str (schemas_path )
245+ os .environ ["SCIM_CLI_RESOURCE_TYPES" ] = str (resource_types_path )
246+ try :
247+ result = runner .invoke (
248+ cli ,
249+ [
250+ "--url" ,
251+ httpserver .url_for ("/" ),
252+ "query" ,
253+ "user" ,
254+ "foobar" ,
255+ ],
256+ catch_exceptions = False ,
257+ )
258+ assert result .exit_code == 0
259+ finally :
260+ del os .environ ["SCIM_CLI_SERVICE_PROVIDER_CONFIG" ]
261+ del os .environ ["SCIM_CLI_SCHEMAS" ]
262+ del os .environ ["SCIM_CLI_RESOURCE_TYPES" ]
0 commit comments