Skip to content

Commit 19ea99a

Browse files
OXDEV-9216 Fix password constraints usage
1 parent 8df89b9 commit 19ea99a

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Honeypot Captcha to detect and block bots without disrupting user experience.
1313
- Support of PHP 8.4
1414

15+
### Fixed
16+
- Password validators are no longer used when password policy is disabled
17+
1518
## [1.0.0] - 2024-11-27
1619
This is the stable release of v1.0.0. No changes have been made since v1.0.0-rc.1.
1720

src/Shared/Core/InputValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function checkPassword($user, $newPassword, $confirmationPassword, $shoul
2929
{
3030
$settingsService = $this->getService(ModuleSettingsServiceInterface::class);
3131
if (!$settingsService->isPasswordPolicyEnabled()) {
32-
parent::checkPassword($user, $newPassword, $confirmationPassword, $shouldCheckPasswordLength);
32+
return parent::checkPassword($user, $newPassword, $confirmationPassword, $shouldCheckPasswordLength);
3333
}
3434

3535
$passwordValidator = $this->getService(PasswordValidatorChainInterface::class);

tests/Integration/Shared/Core/InputValidatorTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
use OxidEsales\Eshop\Core\Exception\InputException;
1414
use OxidEsales\Eshop\Core\Exception\UserException;
1515
use OxidEsales\Eshop\Core\Registry;
16+
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
1617
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
18+
use OxidEsales\SecurityModule\PasswordPolicy\Service\ModuleSettingsServiceInterface;
1719
use OxidEsales\SecurityModule\Shared\Core\InputValidator;
1820
use 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

Comments
 (0)