Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/UserTest.php
Show First 20 Lines • Show All 369 Lines • ▼ Show 20 Lines | */ | ||||
$userId = TestCase::getObjectProperty($job, 'userId'); | $userId = TestCase::getObjectProperty($job, 'userId'); | ||||
return $userEmail === $user->email | return $userEmail === $user->email | ||||
&& $userId === $user->id; | && $userId === $user->id; | ||||
} | } | ||||
); | ); | ||||
// Update the user, test the password change | // Update the user, test the password change | ||||
$user->setSetting('password_expiration_warning', '2020-10-10 10:10:10'); | |||||
$oldPassword = $user->password; | $oldPassword = $user->password; | ||||
$user->password = 'test123'; | $user->password = 'test123'; | ||||
$user->save(); | $user->save(); | ||||
$this->assertNotEquals($oldPassword, $user->password); | $this->assertNotEquals($oldPassword, $user->password); | ||||
$this->assertSame(0, $user->passwords()->count()); | $this->assertSame(0, $user->passwords()->count()); | ||||
$this->assertNull($user->getSetting('password_expiration_warning')); | |||||
$this->assertMatchesRegularExpression( | |||||
'/^' . now()->format('Y-m-d') . ' [0-9]{2}:[0-9]{2}:[0-9]{2}$/', | |||||
$user->getSetting('password_update') | |||||
); | |||||
Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1); | Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1); | ||||
Queue::assertPushed( | Queue::assertPushed( | ||||
\App\Jobs\User\UpdateJob::class, | \App\Jobs\User\UpdateJob::class, | ||||
function ($job) use ($user) { | function ($job) use ($user) { | ||||
$userEmail = TestCase::getObjectProperty($job, 'userEmail'); | $userEmail = TestCase::getObjectProperty($job, 'userEmail'); | ||||
$userId = TestCase::getObjectProperty($job, 'userId'); | $userId = TestCase::getObjectProperty($job, 'userId'); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | */ | ||||
/** | /** | ||||
* Test User::getConfig() and setConfig() methods | * Test User::getConfig() and setConfig() methods | ||||
*/ | */ | ||||
public function testConfigTrait(): void | public function testConfigTrait(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$john->setSetting('greylist_enabled', null); | $john->setSetting('greylist_enabled', null); | ||||
$john->setSetting('password_policy', null); | $john->setSetting('password_policy', null); | ||||
$john->setSetting('max_password_age', null); | |||||
// Greylist_enabled | // greylist_enabled | ||||
$this->assertSame(true, $john->getConfig()['greylist_enabled']); | $this->assertSame(true, $john->getConfig()['greylist_enabled']); | ||||
$result = $john->setConfig(['greylist_enabled' => false, 'unknown' => false]); | $result = $john->setConfig(['greylist_enabled' => false, 'unknown' => false]); | ||||
$this->assertSame(['unknown' => "The requested configuration parameter is not supported."], $result); | $this->assertSame(['unknown' => "The requested configuration parameter is not supported."], $result); | ||||
$this->assertSame(false, $john->getConfig()['greylist_enabled']); | $this->assertSame(false, $john->getConfig()['greylist_enabled']); | ||||
$this->assertSame('false', $john->getSetting('greylist_enabled')); | $this->assertSame('false', $john->getSetting('greylist_enabled')); | ||||
$result = $john->setConfig(['greylist_enabled' => true]); | $result = $john->setConfig(['greylist_enabled' => true]); | ||||
$this->assertSame([], $result); | $this->assertSame([], $result); | ||||
$this->assertSame(true, $john->getConfig()['greylist_enabled']); | $this->assertSame(true, $john->getConfig()['greylist_enabled']); | ||||
$this->assertSame('true', $john->getSetting('greylist_enabled')); | $this->assertSame('true', $john->getSetting('greylist_enabled')); | ||||
// Password_policy | // max_apssword_age | ||||
$this->assertSame(null, $john->getConfig()['max_password_age']); | |||||
$result = $john->setConfig(['max_password_age' => -1]); | |||||
$this->assertSame([], $result); | |||||
$this->assertSame(null, $john->getConfig()['max_password_age']); | |||||
$this->assertSame(null, $john->getSetting('max_password_age')); | |||||
$result = $john->setConfig(['max_password_age' => 12]); | |||||
$this->assertSame([], $result); | |||||
$this->assertSame('12', $john->getConfig()['max_password_age']); | |||||
$this->assertSame('12', $john->getSetting('max_password_age')); | |||||
// password_policy | |||||
$result = $john->setConfig(['password_policy' => true]); | $result = $john->setConfig(['password_policy' => true]); | ||||
$this->assertSame(['password_policy' => "Specified password policy is invalid."], $result); | $this->assertSame(['password_policy' => "Specified password policy is invalid."], $result); | ||||
$this->assertSame(null, $john->getConfig()['password_policy']); | $this->assertSame(null, $john->getConfig()['password_policy']); | ||||
$this->assertSame(null, $john->getSetting('password_policy')); | $this->assertSame(null, $john->getSetting('password_policy')); | ||||
$result = $john->setConfig(['password_policy' => 'min:-1']); | $result = $john->setConfig(['password_policy' => 'min:-1']); | ||||
▲ Show 20 Lines • Show All 842 Lines • Show Last 20 Lines |