1111from renku_data_services .data_api .app import register_all_handlers
1212from renku_data_services .migrations .core import run_migrations_for_app
1313from renku_data_services .storage .rclone import RCloneValidator
14+ from renku_data_services .utils .core import get_openbis_session_token
1415from test .utils import SanicReusableASGITestClient
1516
1617_valid_storage : dict [str , Any ] = {
@@ -538,7 +539,7 @@ async def test_storage_validate_connection(storage_test_client) -> None:
538539 _ , res = await storage_test_client .post ("/api/data/storage_schema/test_connection" , data = json .dumps (body ))
539540 assert res .status_code == 422
540541
541- body = {"configuration" : {"type" : "s3" , "provider" : "AWS" }, "source_path" : "doesntexistatall /" }
542+ body = {"configuration" : {"type" : "s3" , "provider" : "AWS" }, "source_path" : "does_not_exist_at_all /" }
542543 _ , res = await storage_test_client .post ("/api/data/storage_schema/test_connection" , data = json .dumps (body ))
543544 assert res .status_code == 422
544545
@@ -547,6 +548,39 @@ async def test_storage_validate_connection(storage_test_client) -> None:
547548 assert res .status_code == 204
548549
549550
551+ @pytest .mark .myskip (1 == 1 , reason = "Depends on a remote openBIS host which may not always be available." )
552+ @pytest .mark .asyncio
553+ async def test_openbis_storage_validate_connection (storage_test_client ) -> None :
554+ openbis_session_token = await get_openbis_session_token (
555+ host = "openbis-eln-lims.ethz.ch" , # Public openBIS demo instance.
556+ username = "observer" ,
557+ password = "1234" ,
558+ )
559+ storage_test_client , _ = storage_test_client
560+
561+ body = {
562+ "configuration" : {
563+ "type" : "openbis" ,
564+ "host" : "openbis-eln-lims.ethz.ch" ,
565+ "session_token" : openbis_session_token ,
566+ },
567+ "source_path" : "does_not_exist_at_all/" ,
568+ }
569+ _ , res = await storage_test_client .post ("/api/data/storage_schema/test_connection" , data = json .dumps (body ))
570+ assert res .status_code == 422
571+
572+ body = {
573+ "configuration" : {
574+ "type" : "openbis" ,
575+ "host" : "openbis-eln-lims.ethz.ch" ,
576+ "session_token" : openbis_session_token ,
577+ },
578+ "source_path" : "/" ,
579+ }
580+ _ , res = await storage_test_client .post ("/api/data/storage_schema/test_connection" , data = json .dumps (body ))
581+ assert res .status_code == 204
582+
583+
550584@pytest .mark .asyncio
551585async def test_storage_validate_error (storage_test_client ) -> None :
552586 storage_test_client , _ = storage_test_client
0 commit comments