2222from  playwright .sync_api  import  APIRequestContext , BrowserContext , Page , WebSocket 
2323from  playwright .sync_api ._generated  import  Playwright 
2424from  pydantic  import  AnyUrl , TypeAdapter 
25- from  pytest  import  Item 
25+ from  pytest_simcore . helpers . faker_factories  import  DEFAULT_TEST_PASSWORD 
2626from  pytest_simcore .helpers .logging_tools  import  log_context 
2727from  pytest_simcore .helpers .playwright  import  (
2828    MINUTE ,
3636    decode_socketio_42_message ,
3737    web_socket_default_log_handler ,
3838)
39+ from  pytest_simcore .helpers .pydantic_extension  import  Secret4TestsStr 
3940
4041_PROJECT_CLOSING_TIMEOUT : Final [int ] =  10  *  MINUTE 
4142_OPENING_NEW_EMPTY_PROJECT_MAX_WAIT_TIME : Final [int ] =  30  *  SECOND 
@@ -79,6 +80,12 @@ def pytest_addoption(parser: pytest.Parser) -> None:
7980        default = False ,
8081        help = "Whether product is billable or not" ,
8182    )
83+     group .addoption (
84+         "--product-lite" ,
85+         action = "store_true" ,
86+         default = False ,
87+         help = "Whether product is lite version or not" ,
88+     )
8289    group .addoption (
8390        "--autoscaled" ,
8491        action = "store_true" ,
@@ -116,7 +123,7 @@ def pytest_addoption(parser: pytest.Parser) -> None:
116123
117124
118125# Dictionary to store start times of tests 
119- _test_start_times  =  {}
126+ _test_start_times :  dict [ str ,  datetime . datetime ]  =  {}
120127
121128
122129def  pytest_runtest_setup (item ):
@@ -144,7 +151,7 @@ def _construct_graylog_url(
144151    return  f"{ monitoring_url }  /graylog/search?{ query }  " 
145152
146153
147- def  pytest_runtest_makereport (item : Item , call ):
154+ def  pytest_runtest_makereport (item : pytest . Item , call ):
148155    """ 
149156    Hook to add extra information when a test fails. 
150157    """ 
@@ -171,7 +178,6 @@ def pytest_runtest_makereport(item: Item, call):
171178            )
172179            diagnostics ["duration" ] =  str (end_time  -  start_time )
173180
174-         # Print the diagnostics report 
175181        with  log_context (
176182            logging .WARNING ,
177183            f"ℹ️ Diagnostics report for { test_name }   ---" ,  # noqa: RUF001 
@@ -217,23 +223,29 @@ def user_name(request: pytest.FixtureRequest, auto_register: bool, faker: Faker)
217223@pytest .fixture  
218224def  user_password (
219225    request : pytest .FixtureRequest , auto_register : bool , faker : Faker 
220- ) ->  str :
226+ ) ->  Secret4TestsStr :
221227    if  auto_register :
222-         return  faker . password ( length = 12 )
228+         return  Secret4TestsStr ( DEFAULT_TEST_PASSWORD )
223229    if  osparc_password  :=  request .config .getoption ("--password" ):
224230        assert  isinstance (osparc_password , str )
225-         return  osparc_password 
226-     return  os .environ ["USER_PASSWORD" ]
231+         return  Secret4TestsStr ( osparc_password ) 
232+     return  Secret4TestsStr ( os .environ ["USER_PASSWORD" ]) 
227233
228234
229235@pytest .fixture (scope = "session" ) 
230- def  product_billable (request : pytest .FixtureRequest ) ->  bool :
236+ def  is_product_billable (request : pytest .FixtureRequest ) ->  bool :
231237    billable  =  request .config .getoption ("--product-billable" )
232238    return  TypeAdapter (bool ).validate_python (billable )
233239
234240
235241@pytest .fixture (scope = "session" ) 
236- def  autoscaled (request : pytest .FixtureRequest ) ->  bool :
242+ def  is_product_lite (request : pytest .FixtureRequest ) ->  bool :
243+     enabled  =  request .config .getoption ("--product-lite" )
244+     return  TypeAdapter (bool ).validate_python (enabled )
245+ 
246+ 
247+ @pytest .fixture (scope = "session" ) 
248+ def  is_autoscaled (request : pytest .FixtureRequest ) ->  bool :
237249    autoscaled  =  request .config .getoption ("--autoscaled" )
238250    return  TypeAdapter (bool ).validate_python (autoscaled )
239251
@@ -280,7 +292,7 @@ def register(
280292    page : Page ,
281293    product_url : AnyUrl ,
282294    user_name : str ,
283-     user_password : str ,
295+     user_password : Secret4TestsStr ,
284296) ->  Callable [[], AutoRegisteredUser ]:
285297    def  _do () ->  AutoRegisteredUser :
286298        with  log_context (
@@ -297,11 +309,13 @@ def _do() -> AutoRegisteredUser:
297309            for  pass_id  in  ["registrationPass1Fld" , "registrationPass2Fld" ]:
298310                user_password_box  =  page .get_by_test_id (pass_id )
299311                user_password_box .click ()
300-                 user_password_box .fill (user_password )
312+                 user_password_box .fill (user_password . get_secret_value () )
301313            with  page .expect_response (re .compile (r"/auth/register" )) as  response_info :
302314                page .get_by_test_id ("registrationSubmitBtn" ).click ()
303315            assert  response_info .value .ok , response_info .value .json ()
304-             return  AutoRegisteredUser (user_email = user_name , password = user_password )
316+             return  AutoRegisteredUser (
317+                 user_email = user_name , password = user_password .get_secret_value ()
318+             )
305319
306320    return  _do 
307321
@@ -311,7 +325,7 @@ def log_in_and_out(
311325    page : Page ,
312326    product_url : AnyUrl ,
313327    user_name : str ,
314-     user_password : str ,
328+     user_password : Secret4TestsStr ,
315329    auto_register : bool ,
316330    register : Callable [[], AutoRegisteredUser ],
317331) ->  Iterator [WebSocket ]:
@@ -352,7 +366,7 @@ def log_in_and_out(
352366                _user_email_box .fill (user_name )
353367                _user_password_box  =  page .get_by_test_id ("loginPasswordFld" )
354368                _user_password_box .click ()
355-                 _user_password_box .fill (user_password )
369+                 _user_password_box .fill (user_password . get_secret_value () )
356370                with  page .expect_response (re .compile (r"/login" )) as  response_info :
357371                    page .get_by_test_id ("loginSubmitBtn" ).click ()
358372                assert  response_info .value .ok , f"{ response_info .value .json ()}  " 
@@ -392,7 +406,7 @@ def log_in_and_out(
392406def  create_new_project_and_delete (
393407    page : Page ,
394408    log_in_and_out : WebSocket ,
395-     product_billable : bool ,
409+     is_product_billable : bool ,
396410    api_request_context : APIRequestContext ,
397411    product_url : AnyUrl ,
398412) ->  Iterator [Callable [[tuple [RunningState ], bool ], dict [str , Any ]]]:
@@ -411,7 +425,7 @@ def _(
411425        ), "misuse of this fixture! only 1 study can be opened at a time. Otherwise please modify the fixture" 
412426        with  log_context (
413427            logging .INFO ,
414-             f"Open project in { product_url = }   as { product_billable = }  " ,
428+             f"Open project in { product_url = }   as { is_product_billable = }  " ,
415429        ) as  ctx :
416430            waiter  =  SocketIOProjectStateUpdatedWaiter (expected_states = expected_states )
417431            timeout  =  (
@@ -473,7 +487,7 @@ def wait_for_done(response):
473487                                ...
474488                    else :
475489                        open_button .click ()
476-                 if  product_billable :
490+                 if  is_product_billable :
477491                    # Open project with default resources 
478492                    page .get_by_test_id ("openWithResources" ).click ()
479493            project_data  =  response_info .value .json ()
@@ -512,7 +526,7 @@ def wait_for_done(response):
512526    for  project_uuid  in  created_project_uuids :
513527        with  log_context (
514528            logging .INFO ,
515-             f"Delete project with { project_uuid = }   in { product_url = }   as { product_billable = }  " ,
529+             f"Delete project with { project_uuid = }   in { product_url = }   as { is_product_billable = }  " ,
516530        ):
517531            response  =  api_request_context .delete (
518532                f"{ product_url }  v0/projects/{ project_uuid }  " 
0 commit comments