mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2026-11-20 23:43:26 +03:00
Fix password expiration handling and visibility on 4.x (#1110)
- port the password-expiration correction to `postfixadmin_4.0` - make password expiration optional and disabled by default - make 0 consistently mean that domain passwords do not expire - validate whole-day policies from 0 through 36500 - align password-change paths and preserve the existing Login fallback - show mailbox expiration states in lists and CSV output - add the new labels to every 4.x language file - document how to enable the feature in `config.local.php` thanks @TrapoSAMA
This commit is contained in:
1 parent
4ed71f0218
commit
6e93d57766
46 files changed
+416
-20
No files matched your search
@@ -2,6 +2,63 @@
|
||||
|
||||
class DomainHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider passwordExpiryValuesProvider
|
||||
*/
|
||||
public function testPasswordExpiryValidation($value, $expected): void
|
||||
{
|
||||
$_SESSION = [
|
||||
'sessid' => [
|
||||
'roles' => ['global-admin']
|
||||
]
|
||||
];
|
||||
|
||||
$domain = 'password-expiry-' . uniqid() . '.example';
|
||||
db_insert(
|
||||
'domain',
|
||||
['domain' => $domain, 'description' => 'test', 'transport' => '', 'password_expiry' => 365]
|
||||
);
|
||||
db_insert(
|
||||
'domain_admins',
|
||||
['username' => 'admin', 'domain' => $domain, 'active' => 1],
|
||||
['created'],
|
||||
true
|
||||
);
|
||||
|
||||
try {
|
||||
$handler = new DomainHandler(0, 'admin', true);
|
||||
$this->assertTrue($handler->init($domain));
|
||||
$this->assertSame($expected, $handler->set(['password_expiry' => $value]));
|
||||
|
||||
if ($expected) {
|
||||
$this->assertTrue($handler->save());
|
||||
$stored = db_query_one(
|
||||
'SELECT password_expiry FROM domain WHERE domain = :domain',
|
||||
['domain' => $domain]
|
||||
);
|
||||
$this->assertSame((int)$value, (int)$stored['password_expiry']);
|
||||
}
|
||||
} finally {
|
||||
db_delete('domain_admins', 'domain', $domain);
|
||||
db_delete('domain', 'domain', $domain);
|
||||
}
|
||||
}
|
||||
|
||||
public function passwordExpiryValuesProvider(): array
|
||||
{
|
||||
return [
|
||||
'no expiration' => [0, true],
|
||||
'positive integer' => [365, true],
|
||||
'maximum' => [PASSWORD_EXPIRATION_MAX_DAYS, true],
|
||||
'negative sentinel' => [-1, false],
|
||||
'negative value' => [-2, false],
|
||||
'decimal' => ['1.5', false],
|
||||
'scientific notation' => ['1e2', false],
|
||||
'above maximum' => [PASSWORD_EXPIRATION_MAX_DAYS + 1, false],
|
||||
'text' => ['invalid', false],
|
||||
];
|
||||
}
|
||||
|
||||
public function testBasic()
|
||||
{
|
||||
$x = new DomainHandler();
|
||||
|
||||
Reference in new issue
Block a user