@@ -248,6 +248,42 @@ async def test_patch_data_connector(sanic_client: SanicASGITestClient, create_da
248248 assert set (data_connector .get ("keywords" )) == {"keyword 1" , "keyword 2" }
249249
250250
251+ @pytest .mark .asyncio
252+ async def test_patch_data_connector_can_unset_storage_field (
253+ sanic_client : SanicASGITestClient , create_data_connector , user_headers
254+ ) -> None :
255+ initial_storage = {
256+ "configuration" : {
257+ "provider" : "AWS" ,
258+ "type" : "s3" ,
259+ "region" : "us-east-1" ,
260+ "access_key_id" : "ACCESS KEY" ,
261+ "secret_access_key" : "SECRET" ,
262+ },
263+ "source_path" : "my-bucket" ,
264+ "target_path" : "my_data" ,
265+ }
266+ data_connector = await create_data_connector ("My data connector" , storage = initial_storage )
267+
268+ headers = merge_headers (user_headers , {"If-Match" : data_connector ["etag" ]})
269+ data_connector_id = data_connector ["id" ]
270+ patch = {"storage" : {"configuration" : {"region" : None , "access_key_id" : None , "secret_access_key" : None }}}
271+ _ , response = await sanic_client .patch (
272+ f"/api/data/data_connectors/{ data_connector_id } " , headers = headers , json = patch
273+ )
274+
275+ assert response .status_code == 200 , response .text
276+ assert response .json is not None
277+ new_configuration = response .json ["storage" ]["configuration" ]
278+ assert new_configuration is not None
279+ assert new_configuration ["provider" ] == "AWS"
280+ assert new_configuration ["type" ] == "s3"
281+ assert "region" not in new_configuration
282+ assert "access_key_id" not in new_configuration
283+ assert "secret_access_key" not in new_configuration
284+ assert len (response .json ["storage" ]["sensitive_fields" ]) == 0
285+
286+
251287@pytest .mark .asyncio
252288async def test_delete_data_connector (sanic_client : SanicASGITestClient , create_data_connector , user_headers ) -> None :
253289 await create_data_connector ("Data connector 1" )
0 commit comments