1313use OxidEsales \Eshop \Core \Exception \InputException ;
1414use OxidEsales \Eshop \Core \Exception \UserException ;
1515use OxidEsales \Eshop \Core \Registry ;
16+ use OxidEsales \EshopCommunity \Internal \Container \ContainerFactory ;
1617use OxidEsales \EshopCommunity \Tests \Integration \IntegrationTestCase ;
18+ use OxidEsales \SecurityModule \PasswordPolicy \Service \ModuleSettingsServiceInterface ;
1719use OxidEsales \SecurityModule \Shared \Core \InputValidator ;
1820use PHPUnit \Framework \Attributes \DataProvider ;
1921
@@ -22,6 +24,8 @@ class InputValidatorTest extends IntegrationTestCase
2224 #[DataProvider('dataProviderPasswordError ' )]
2325 public function testInputValidationError ($ password , $ expectedException ): void
2426 {
27+ $ this ->setPasswordState (true );
28+
2529 $ userModelMock = $ this ->createMock (User::class);
2630
2731 $ validator = oxNew (InputValidator::class);
@@ -86,4 +90,26 @@ public function testShopPasswordCheck(): void
8690 $ exception ->getMessage ()
8791 );
8892 }
93+
94+ public function testInputValidatorPasswordConstrainsAreSkipped (): void
95+ {
96+ $ this ->setPasswordState ();
97+
98+ $ userModelMock = $ this ->createMock (User::class);
99+
100+ $ password = '12345678 ' ;
101+
102+ $ validator = oxNew (InputValidator::class);
103+ $ result = $ validator ->checkPassword ($ userModelMock , $ password , $ password );
104+
105+ $ this ->assertNull ($ result );
106+ }
107+
108+ private function setPasswordState (bool $ state = false )
109+ {
110+ return ContainerFactory::getInstance ()
111+ ->getContainer ()
112+ ->get (ModuleSettingsServiceInterface::class)
113+ ->saveIsPasswordPolicyEnabled ($ state );
114+ }
89115}
0 commit comments