diff options
-rw-r--r-- | apps/updatenotification/lib/BackgroundJob/ResetToken.php | 4 | ||||
-rw-r--r-- | apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php | 16 |
2 files changed, 13 insertions, 7 deletions
diff --git a/apps/updatenotification/lib/BackgroundJob/ResetToken.php b/apps/updatenotification/lib/BackgroundJob/ResetToken.php index 9a72295821a..9e700bc93ac 100644 --- a/apps/updatenotification/lib/BackgroundJob/ResetToken.php +++ b/apps/updatenotification/lib/BackgroundJob/ResetToken.php @@ -43,8 +43,8 @@ class ResetToken extends TimedJob { return; } - $secretCreated = $this->appConfig->getValueInt('core', 'updater.secret.created', $this->time->getTime()); - // Delete old tokens after 2 days + $secretCreated = $this->appConfig->getValueInt('core', 'updater.secret.created'); + // Delete old tokens after 2 days and also tokens without any created date $secretCreatedDiff = $this->time->getTime() - $secretCreated; if ($secretCreatedDiff >= 172800) { $this->config->deleteSystemValue('updater.secret'); diff --git a/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php b/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php index 31efcd5a63d..7bb0fe337b0 100644 --- a/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php +++ b/apps/updatenotification/tests/BackgroundJob/ResetTokenTest.php @@ -38,7 +38,10 @@ class ResetTokenTest extends TestCase { ); } - public function testRunWithNotExpiredToken(): void { // Affirm if updater.secret.created <48 hours ago then `updater.secret` is left alone + /** + * Affirm if updater.secret.created <48 hours ago then `updater.secret` is left alone. + */ + public function testKeepSecretWhenCreatedRecently(): void { $this->timeFactory ->expects($this->atLeastOnce()) ->method('getTime') @@ -66,10 +69,13 @@ class ResetTokenTest extends TestCase { ->expects($this->once()) ->method('debug'); - $this->invokePrivate($this->resetTokenBackgroundJob, 'run', [null]); + static::invokePrivate($this->resetTokenBackgroundJob, 'run', [null]); } - public function testRunWithExpiredToken(): void { // Affirm if updater.secret.created >48 hours ago then `updater.secret` is removed + /** + * Affirm if updater.secret.created >48 hours ago then `updater.secret` is removed + */ + public function testSecretIsRemovedWhenOutdated(): void { $this->timeFactory ->expects($this->atLeastOnce()) ->method('getTime') @@ -104,8 +110,8 @@ class ResetTokenTest extends TestCase { public function testRunWithExpiredTokenAndReadOnlyConfigFile(): void { // Affirm if config_is_read_only is set that the secret is never reset $this->timeFactory - ->expects($this->never()) - ->method('getTime'); + ->expects($this->never()) + ->method('getTime'); $this->appConfig ->expects($this->never()) ->method('getValueInt'); |