1313from scim2_tester .utils import Status
1414
1515
16- def test_resource_types_endpoint (httpserver , check_config ):
16+ def test_resource_types_endpoint (httpserver , testing_context ):
1717 """Test a fully functional resource types endpoint."""
1818 httpserver .expect_request (re .compile (r"^/ResourceTypes$" )).respond_with_json (
1919 ListResponse [ResourceType ](
20- resources = check_config .client .resource_types ,
21- total_results = len (check_config .client .resource_types ),
20+ resources = testing_context .client .resource_types ,
21+ total_results = len (testing_context .client .resource_types ),
2222 ).model_dump (scim_ctx = Context .RESOURCE_QUERY_RESPONSE ),
2323 status = 200 ,
2424 content_type = "application/scim+json" ,
2525 )
26- for resource_type in check_config .client .resource_types :
26+ for resource_type in testing_context .client .resource_types :
2727 httpserver .expect_request (
2828 re .compile (rf"^/ResourceTypes/{ resource_type .id } $" )
2929 ).respond_with_json (
@@ -49,35 +49,35 @@ def test_resource_types_endpoint(httpserver, check_config):
4949 content_type = "application/scim+json" ,
5050 )
5151
52- results = _resource_types_endpoint (check_config )
52+ results = _resource_types_endpoint (testing_context )
5353
5454 assert all (result .status == Status .SUCCESS for result in results )
5555
5656
57- def test_resource_missing_query_endpoint (httpserver , check_config ):
57+ def test_resource_missing_query_endpoint (httpserver , testing_context ):
5858 """Test that individual ResourceType endpoints are missing."""
5959 httpserver .expect_request (re .compile (r"^/ResourceTypes$" )).respond_with_json (
6060 ListResponse [ResourceType ](
61- resources = check_config .client .resource_types ,
62- total_results = len (check_config .client .resource_types ),
61+ resources = testing_context .client .resource_types ,
62+ total_results = len (testing_context .client .resource_types ),
6363 ).model_dump (scim_ctx = Context .RESOURCE_QUERY_RESPONSE ),
6464 status = 200 ,
6565 content_type = "application/scim+json" ,
6666 )
67- results = _resource_types_endpoint (check_config )
67+ results = _resource_types_endpoint (testing_context )
6868
6969 assert all (result .status == Status .ERROR for result in results [1 :])
7070
7171
72- def test_resource_types_endpoint_methods (httpserver , check_config ):
72+ def test_resource_types_endpoint_methods (httpserver , testing_context ):
7373 """Test that resource types endpoint returns proper errors for unsupported HTTP methods."""
7474 # Mock all HTTP methods to return 405
7575 for method in ["POST" , "PUT" , "PATCH" , "DELETE" ]:
7676 httpserver .expect_request (
7777 uri = "/ResourceTypes" , method = method
7878 ).respond_with_data ("" , status = 405 )
7979
80- results = resource_types_endpoint_methods (check_config )
80+ results = resource_types_endpoint_methods (testing_context )
8181
8282 assert len (results ) == 4
8383 assert all (result .status == Status .SUCCESS for result in results )
@@ -88,7 +88,7 @@ def test_resource_types_endpoint_methods(httpserver, check_config):
8888 )
8989
9090
91- def test_query_resource_type_by_id_client_returns_error (httpserver , check_config ):
91+ def test_query_resource_type_by_id_client_returns_error (httpserver , testing_context ):
9292 """Test query_resource_type_by_id when server returns HTTP error."""
9393 resource_type = ResourceType (
9494 id = "test-id" , name = "Test" , endpoint = "/Test" , schema_ = "urn:test"
@@ -102,21 +102,21 @@ def test_query_resource_type_by_id_client_returns_error(httpserver, check_config
102102 content_type = "application/scim+json" ,
103103 )
104104
105- result = query_resource_type_by_id (check_config , resource_type )
105+ result = query_resource_type_by_id (testing_context , resource_type )
106106 assert result .status == Status .ERROR
107107 assert "Resource Type not found" in result .reason
108108
109109
110- def test_access_resource_type_by_id_success (httpserver , check_config ):
110+ def test_access_resource_type_by_id_success (httpserver , testing_context ):
111111 """Test successfully accessing a resource type by ID."""
112- resource_type = check_config .client .resource_types [0 ]
112+ resource_type = testing_context .client .resource_types [0 ]
113113 httpserver .expect_request (f"/ResourceTypes/{ resource_type .id } " ).respond_with_json (
114114 resource_type .model_dump (scim_ctx = Context .RESOURCE_QUERY_RESPONSE ),
115115 status = 200 ,
116116 content_type = "application/scim+json" ,
117117 )
118118
119- result = query_resource_type_by_id (check_config , resource_type )
119+ result = query_resource_type_by_id (testing_context , resource_type )
120120 assert result .status == Status .SUCCESS
121121 assert (
122122 f"Successfully accessed the /ResourceTypes/{ resource_type .id } endpoint."
@@ -125,7 +125,7 @@ def test_access_resource_type_by_id_success(httpserver, check_config):
125125 assert result .data == resource_type
126126
127127
128- def test_access_invalid_resource_type_non_error_response (httpserver , check_config ):
128+ def test_access_invalid_resource_type_non_error_response (httpserver , testing_context ):
129129 """Test accessing an invalid resource type that returns a non-Error object."""
130130 mock_resource_type = ResourceType (
131131 id = "invalid-resource-type" ,
@@ -142,14 +142,14 @@ def test_access_invalid_resource_type_non_error_response(httpserver, check_confi
142142 content_type = "application/scim+json" ,
143143 )
144144
145- result = access_invalid_resource_type (check_config )
145+ result = access_invalid_resource_type (testing_context )
146146
147147 assert result .status == Status .ERROR
148148 assert "invalid URL did not return an Error object" in result .reason
149149 assert result .data == mock_resource_type
150150
151151
152- def test_access_invalid_resource_type_wrong_status_code (httpserver , check_config ):
152+ def test_access_invalid_resource_type_wrong_status_code (httpserver , testing_context ):
153153 """Test accessing an invalid resource type that returns wrong status code."""
154154 error = Error (status = 400 , detail = "Bad Request" )
155155
@@ -161,7 +161,7 @@ def test_access_invalid_resource_type_wrong_status_code(httpserver, check_config
161161 content_type = "application/scim+json" ,
162162 )
163163
164- result = access_invalid_resource_type (check_config )
164+ result = access_invalid_resource_type (testing_context )
165165
166166 assert result .status == Status .ERROR
167167 assert "did return an object, but the status code is 400" in result .reason
0 commit comments