mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Update when verification is re-attempted
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user