2121from faker import Faker
2222from playwright .sync_api import APIRequestContext , BrowserContext , Page , WebSocket
2323from playwright .sync_api ._generated import Playwright
24- from pydantic import AnyUrl , TypeAdapter
24+ from pydantic import AnyUrl , SecretStr , TypeAdapter
2525from pytest import Item
26+ from pytest_simcore .helpers .faker_factories import DEFAULT_TEST_PASSWORD
2627from pytest_simcore .helpers .logging_tools import log_context
2728from pytest_simcore .helpers .playwright import (
2829 MINUTE ,
@@ -220,13 +221,13 @@ def user_name(request: pytest.FixtureRequest, auto_register: bool, faker: Faker)
220221@pytest .fixture
221222def user_password (
222223 request : pytest .FixtureRequest , auto_register : bool , faker : Faker
223- ) -> str :
224+ ) -> SecretStr :
224225 if auto_register :
225- return faker . password ( length = 12 )
226+ return SecretStr ( DEFAULT_TEST_PASSWORD )
226227 if osparc_password := request .config .getoption ("--password" ):
227228 assert isinstance (osparc_password , str )
228- return osparc_password
229- return os .environ ["USER_PASSWORD" ]
229+ return SecretStr ( osparc_password )
230+ return SecretStr ( os .environ ["USER_PASSWORD" ])
230231
231232
232233@pytest .fixture (scope = "session" )
@@ -289,7 +290,7 @@ def register(
289290 page : Page ,
290291 product_url : AnyUrl ,
291292 user_name : str ,
292- user_password : str ,
293+ user_password : SecretStr ,
293294) -> Callable [[], AutoRegisteredUser ]:
294295 def _do () -> AutoRegisteredUser :
295296 with log_context (
@@ -306,11 +307,13 @@ def _do() -> AutoRegisteredUser:
306307 for pass_id in ["registrationPass1Fld" , "registrationPass2Fld" ]:
307308 user_password_box = page .get_by_test_id (pass_id )
308309 user_password_box .click ()
309- user_password_box .fill (user_password )
310+ user_password_box .fill (user_password . get_secret_value () )
310311 with page .expect_response (re .compile (r"/auth/register" )) as response_info :
311312 page .get_by_test_id ("registrationSubmitBtn" ).click ()
312313 assert response_info .value .ok , response_info .value .json ()
313- return AutoRegisteredUser (user_email = user_name , password = user_password )
314+ return AutoRegisteredUser (
315+ user_email = user_name , password = user_password .get_secret_value ()
316+ )
314317
315318 return _do
316319
@@ -320,7 +323,7 @@ def log_in_and_out(
320323 page : Page ,
321324 product_url : AnyUrl ,
322325 user_name : str ,
323- user_password : str ,
326+ user_password : SecretStr ,
324327 auto_register : bool ,
325328 register : Callable [[], AutoRegisteredUser ],
326329) -> Iterator [WebSocket ]:
@@ -361,7 +364,7 @@ def log_in_and_out(
361364 _user_email_box .fill (user_name )
362365 _user_password_box = page .get_by_test_id ("loginPasswordFld" )
363366 _user_password_box .click ()
364- _user_password_box .fill (user_password )
367+ _user_password_box .fill (user_password . get_secret_value () )
365368 with page .expect_response (re .compile (r"/login" )) as response_info :
366369 page .get_by_test_id ("loginSubmitBtn" ).click ()
367370 assert response_info .value .ok , f"{ response_info .value .json ()} "
0 commit comments