diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php index 903eadd901..7267449a03 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php @@ -11,6 +11,7 @@ use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Response; use Utopia\Database\Database; +use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Validator\UID; use Utopia\Logger\Log; @@ -72,7 +73,6 @@ class Update extends Action Database $dbForPlatform, Log $log ) { - var_dump("entered update rule verification"); $rule = $dbForPlatform->getDocument('rules', $ruleId); if ($rule->isEmpty() || $rule->getAttribute('projectInternalId') !== $project->getSequence()) { @@ -91,15 +91,13 @@ class Update extends Action $this->verifyRule($rule, $log); $updates->setAttribute('verificationLogs', ''); } catch (Exception $err) { - var_dump("error in update rule verification, setting verification logs"); $dbForPlatform->updateDocument('rules', $rule->getId(), new Document([ + '$updatedAt' => DateTime::now(), 'verificationLogs' => $err->getMessage(), ])); - var_dump($dbForPlatform->getDocument('rules', $rule->getId())); throw $err; } - var_dump("setting status to generating certificate"); $updates->setAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), $updates); diff --git a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php index da7c161042..af700f4aa9 100644 --- a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php +++ b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php @@ -704,4 +704,37 @@ class ProxyCustomServerTest extends Scope $this->cleanupRule($rule['body']['$id']); } + + public function testUpdateRuleVerificationWithSameDataUpdatesTimestamp(): void + { + $domain = \uniqid() . '-timestamp-test.webapp.com'; + $rule = $this->createAPIRule($domain); + + $this->assertEquals(201, $rule['headers']['status-code']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); + $this->assertNotEmpty($rule['body']['verificationLogs']); + + $ruleId = $rule['body']['$id']; + $initialUpdatedAt = $rule['body']['$updatedAt']; + $initialVerificationLogs = $rule['body']['verificationLogs']; + + sleep(1); + + $updatedRule = $this->updateRuleVerification($ruleId); + + $this->assertEquals(400, $updatedRule['headers']['status-code']); + $this->assertStringContainsString($initialVerificationLogs, $updatedRule['body']['message']); + + $ruleAfterUpdate = $this->getRule($ruleId); + $this->assertEquals(200, $ruleAfterUpdate['headers']['status-code']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $ruleAfterUpdate['body']['status']); + $this->assertEquals($initialVerificationLogs, $ruleAfterUpdate['body']['verificationLogs']); + $this->assertNotEquals($initialUpdatedAt, $ruleAfterUpdate['body']['$updatedAt']); + + $initialTime = new \DateTime($initialUpdatedAt); + $updatedTime = new \DateTime($ruleAfterUpdate['body']['$updatedAt']); + $this->assertGreaterThan($initialTime, $updatedTime); + + $this->cleanupRule($ruleId); + } }