From 7b46197ffee2afc40fbf2613939bc3120d84d29a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 16 Sep 2025 11:57:45 +0200 Subject: [PATCH] consts for rule status --- app/controllers/api/vcs.php | 6 ++-- app/controllers/general.php | 2 +- app/init/constants.php | 6 +++- .../Platform/Modules/Compute/Action.php | 6 ++-- .../Functions/Http/Functions/Create.php | 2 +- .../Modules/Functions/Workers/Builds.php | 2 +- .../Modules/Proxy/Http/Rules/API/Create.php | 10 +++--- .../Proxy/Http/Rules/Function/Create.php | 10 +++--- .../Proxy/Http/Rules/Redirect/Create.php | 10 +++--- .../Modules/Proxy/Http/Rules/Site/Create.php | 10 +++--- .../Proxy/Http/Rules/Verification/Update.php | 2 +- .../Modules/Sites/Http/Deployments/Create.php | 4 +-- .../Http/Deployments/Duplicate/Create.php | 2 +- .../Http/Deployments/Template/Create.php | 2 +- src/Appwrite/Platform/Tasks/Maintenance.php | 2 +- .../Platform/Workers/Certificates.php | 10 +++--- src/Appwrite/Utopia/Response/Model/Rule.php | 4 +-- .../Services/Proxy/ProxyCustomServerTest.php | 36 +++++++++---------- 18 files changed, 65 insertions(+), 61 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index 5bda9961f3..cef391e5d4 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -344,7 +344,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'deploymentResourceId' => $resourceId, 'deploymentResourceInternalId' => $resourceInternalId, 'deploymentVcsProviderBranch' => $providerBranch, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', @@ -377,7 +377,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'deploymentResourceId' => $resourceId, 'deploymentResourceInternalId' => $resourceInternalId, 'deploymentVcsProviderBranch' => $providerBranch, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', @@ -408,7 +408,7 @@ $createGitDeployments = function (GitHub $github, string $providerInstallationId 'deploymentResourceId' => $resourceId, 'deploymentResourceInternalId' => $resourceInternalId, 'deploymentVcsProviderBranch' => $providerBranch, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', diff --git a/app/controllers/general.php b/app/controllers/general.php index 8abca96742..1dbecd8a8a 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -969,7 +969,7 @@ App::init() '$id' => $ruleId, 'domain' => $domain->get(), 'type' => 'api', - 'status' => 'verifying', + 'status' => RULE_STATUS_GENERATING_CERTIFICATE, 'projectId' => $console->getId(), 'projectInternalId' => $console->getSequence(), 'search' => implode(' ', [$ruleId, $domain->get()]), diff --git a/app/init/constants.php b/app/init/constants.php index 28cf8a4052..1aaf683e62 100644 --- a/app/init/constants.php +++ b/app/init/constants.php @@ -129,7 +129,11 @@ const DELETE_TYPE_TARGET = 'target'; const DELETE_TYPE_EXPIRED_TARGETS = 'invalid_targets'; const DELETE_TYPE_SESSION_TARGETS = 'session_targets'; const DELETE_TYPE_MAINTENANCE = 'maintenance'; - +// Rule types +const RULE_STATUS_VERIFICATION_FAILED = 'created'; +const RULE_STATUS_GENERATING_CERTIFICATE = 'verifying'; +const RULE_STATUS_GENERATION_FAILED = 'unverified'; +const RULE_STATUS_SUCCESSFUL = 'verified'; // Message types const MESSAGE_SEND_TYPE_INTERNAL = 'internal'; const MESSAGE_SEND_TYPE_EXTERNAL = 'external'; diff --git a/src/Appwrite/Platform/Modules/Compute/Action.php b/src/Appwrite/Platform/Modules/Compute/Action.php index 5c9208ec24..cf55950647 100644 --- a/src/Appwrite/Platform/Modules/Compute/Action.php +++ b/src/Appwrite/Platform/Modules/Compute/Action.php @@ -219,7 +219,7 @@ class Action extends PlatformAction 'deploymentResourceId' => $site->getId(), 'deploymentResourceInternalId' => $site->getSequence(), 'deploymentVcsProviderBranch' => $providerBranch, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', @@ -245,7 +245,7 @@ class Action extends PlatformAction 'deploymentResourceId' => $site->getId(), 'deploymentResourceInternalId' => $site->getSequence(), 'deploymentVcsProviderBranch' => $providerBranch, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', @@ -282,7 +282,7 @@ class Action extends PlatformAction 'deploymentResourceId' => $site->getId(), 'deploymentResourceInternalId' => $site->getSequence(), 'deploymentVcsProviderBranch' => $providerBranch, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', diff --git a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php index cfb291bf8c..3ebbb63c2f 100644 --- a/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php +++ b/src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php @@ -365,7 +365,7 @@ class Create extends Action 'projectId' => $project->getId(), 'projectInternalId' => $project->getSequence(), 'domain' => $domain, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'type' => 'deployment', 'trigger' => 'manual', 'deploymentId' => !isset($deployment) || $deployment->isEmpty() ? '' : $deployment->getId(), diff --git a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php index 44b21a9457..90c746c295 100644 --- a/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php +++ b/src/Appwrite/Platform/Modules/Functions/Workers/Builds.php @@ -1216,7 +1216,7 @@ class Builds extends Action 'deploymentResourceId' => $deployment->getId(), 'deploymentResourceInternalId' => $deployment->getSequence(), 'deploymentVcsProviderBranch' => $branchName, - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php index 87c0ca3a02..2d5e1ecda2 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/API/Create.php @@ -133,9 +133,9 @@ class Create extends Action // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain->get()) : ID::unique(); - $status = 'created'; + $status = RULE_STATUS_VERIFICATION_FAILED; if (\str_ends_with($domain->get(), $functionsDomain) || \str_ends_with($domain->get(), $sitesDomain)) { - $status = 'verified'; + $status = RULE_STATUS_SUCCESSFUL; } $owner = ''; @@ -160,10 +160,10 @@ class Create extends Action 'region' => $project->getAttribute('region') ]); - if ($rule->getAttribute('status', '') === 'created') { + if ($rule->getAttribute('status', '') === RULE_STATUS_VERIFICATION_FAILED) { try { self::verifyRule($rule, $log); - $rule->setAttribute('status', 'verifying'); + $rule->setAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } @@ -175,7 +175,7 @@ class Create extends Action throw new Exception(Exception::RULE_ALREADY_EXISTS); } - if ($rule->getAttribute('status', '') === 'verifying') { + if ($rule->getAttribute('status', '') === RULE_STATUS_GENERATING_CERTIFICATE) { $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php index c0e0388692..ed1b70203b 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Function/Create.php @@ -148,9 +148,9 @@ class Create extends Action // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain->get()) : ID::unique(); - $status = 'created'; + $status = RULE_STATUS_VERIFICATION_FAILED; if (\str_ends_with($domain->get(), $functionsDomain) || \str_ends_with($domain->get(), $sitesDomain)) { - $status = 'verified'; + $status = RULE_STATUS_SUCCESSFUL; } $owner = ''; @@ -181,10 +181,10 @@ class Create extends Action 'region' => $project->getAttribute('region') ]); - if ($rule->getAttribute('status', '') === 'created') { + if ($rule->getAttribute('status', '') === RULE_STATUS_VERIFICATION_FAILED) { try { self::verifyRule($rule, $log); - $rule->setAttribute('status', 'verifying'); + $rule->setAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } @@ -196,7 +196,7 @@ class Create extends Action throw new Exception(Exception::RULE_ALREADY_EXISTS); } - if ($rule->getAttribute('status', '') === 'verifying') { + if ($rule->getAttribute('status', '') === RULE_STATUS_GENERATING_CERTIFICATE) { $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php index 3d9a566d2b..ebc3475cdc 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Redirect/Create.php @@ -155,9 +155,9 @@ class Create extends Action // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain->get()) : ID::unique(); - $status = 'created'; + $status = RULE_STATUS_VERIFICATION_FAILED; if (\str_ends_with($domain->get(), $functionsDomain) || \str_ends_with($domain->get(), $sitesDomain)) { - $status = 'verified'; + $status = RULE_STATUS_SUCCESSFUL; } $owner = ''; @@ -187,10 +187,10 @@ class Create extends Action 'region' => $project->getAttribute('region') ]); - if ($rule->getAttribute('status', '') === 'created') { + if ($rule->getAttribute('status', '') === RULE_STATUS_VERIFICATION_FAILED) { try { self::verifyRule($rule, $log); - $rule->setAttribute('status', 'verifying'); + $rule->setAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } @@ -202,7 +202,7 @@ class Create extends Action throw new Exception(Exception::RULE_ALREADY_EXISTS); } - if ($rule->getAttribute('status', '') === 'verifying') { + if ($rule->getAttribute('status', '') === RULE_STATUS_GENERATING_CERTIFICATE) { $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), diff --git a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php index f390254380..25d21065b0 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Site/Create.php @@ -148,9 +148,9 @@ class Create extends Action // TODO: @christyjacob remove once we migrate the rules in 1.7.x $ruleId = System::getEnv('_APP_RULES_FORMAT') === 'md5' ? md5($domain->get()) : ID::unique(); - $status = 'created'; + $status = RULE_STATUS_VERIFICATION_FAILED; if (\str_ends_with($domain->get(), $functionsDomain) || \str_ends_with($domain->get(), $sitesDomain)) { - $status = 'verified'; + $status = RULE_STATUS_SUCCESSFUL; } $owner = ''; @@ -181,10 +181,10 @@ class Create extends Action 'region' => $project->getAttribute('region') ]); - if ($rule->getAttribute('status', '') === 'created') { + if ($rule->getAttribute('status', '') === RULE_STATUS_VERIFICATION_FAILED) { try { self::verifyRule($rule, $log); - $rule->setAttribute('status', 'verifying'); + $rule->setAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); } catch (Exception $err) { $rule->setAttribute('verificationLogs', $err->getMessage()); } @@ -196,7 +196,7 @@ class Create extends Action throw new Exception(Exception::RULE_ALREADY_EXISTS); } - if ($rule->getAttribute('status', '') === 'verifying') { + if ($rule->getAttribute('status', '') === RULE_STATUS_GENERATING_CERTIFICATE) { $queueForCertificates ->setDomain(new Document([ 'domain' => $rule->getAttribute('domain'), 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 55138b49d7..b95e528420 100644 --- a/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php +++ b/src/Appwrite/Platform/Modules/Proxy/Http/Rules/Verification/Update.php @@ -92,7 +92,7 @@ class Update extends Action throw $err; } - $updates->setAttribute('status', 'verifying'); + $updates->setAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); $rule = $dbForPlatform->updateDocument('rules', $rule->getId(), $updates); diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php index 02ae493433..b909f1f66b 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Create.php @@ -287,7 +287,7 @@ class Create extends Action 'deploymentResourceType' => 'site', 'deploymentResourceId' => $site->getId(), 'deploymentResourceInternalId' => $site->getSequence(), - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', @@ -352,7 +352,7 @@ class Create extends Action 'deploymentResourceType' => 'site', 'deploymentResourceId' => $site->getId(), 'deploymentResourceInternalId' => $site->getSequence(), - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'search' => implode(' ', [$ruleId, $domain]), 'owner' => 'Appwrite', diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php index 638664673b..9c424fff33 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Duplicate/Create.php @@ -159,7 +159,7 @@ class Create extends Action 'deploymentResourceType' => 'site', 'deploymentResourceId' => $site->getId(), 'deploymentResourceInternalId' => $site->getSequence(), - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'owner' => 'Appwrite', 'region' => $project->getAttribute('region') diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php index aef19eebf7..b9c7f5bed4 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Deployments/Template/Create.php @@ -188,7 +188,7 @@ class Create extends Action 'deploymentResourceType' => 'site', 'deploymentResourceId' => $site->getId(), 'deploymentResourceInternalId' => $site->getSequence(), - 'status' => 'verified', + 'status' => RULE_STATUS_SUCCESSFUL, 'certificateId' => '', 'owner' => 'Appwrite', 'region' => $project->getAttribute('region') diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index df3c787eae..bad3f7a866 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -124,7 +124,7 @@ class Maintenance extends Action $rules = $dbForPlatform->find('rules', [ Query::createdAfter(DatabaseDateTime::format($oldestToCheck)), // max 3 days old - Query::equal('status', ['created']), // not verified yet + Query::equal('status', [RULE_STATUS_VERIFICATION_FAILED]), // not verified yet Query::orderAsc('$updatedAt'), // Pick the ones waiting for another attempt for longest Query::limit(30), // Reasonable pagination limit, processable within a minute ]); diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index e6970c774b..29b2241b3a 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -138,7 +138,7 @@ class Certificates extends Action } // Skip if verification not needed - if ($rule->getAttribute('status', '') !== 'created') { + if ($rule->getAttribute('status', '') !== RULE_STATUS_VERIFICATION_FAILED) { Console::warning('Verification for ' . $rule->getAttribute('domain', '') . ' is not needed.'); return; } @@ -156,7 +156,7 @@ class Certificates extends Action $this->validateDomain($rule, $isMainDomain, $log, $verificationDomainAPI, $verificationDomainFunction); $updates ->setAttribute('verificationLogs', '') - ->setAttribute('status', 'verifying'); + ->setAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); Console::success('Verification succeeded.'); $success = true; @@ -251,7 +251,7 @@ class Certificates extends Action $certificate->setAttribute('domain', $domain->get()); } - $status = $certificate->getAttribute('status', 'verifying'); + $status = $certificate->getAttribute('status', RULE_STATUS_GENERATING_CERTIFICATE); try { // Clean-up logs from previous attempt @@ -304,7 +304,7 @@ class Certificates extends Action // This is useful when cert provider does extra work in background // For example, verification, or example certificate distribution to all edges if ($certificates->isIssueInstant($domain->get(), $domainType)) { - $status = 'verified'; + $status = RULE_STATUS_SUCCESSFUL; } // Command succeeded, store all data into document @@ -315,7 +315,7 @@ class Certificates extends Action $certificate->setAttribute('attempts', 0); $certificate->setAttribute('issueDate', DateTime::now()); } catch (Throwable $e) { - $status = 'unverified'; + $status = RULE_STATUS_GENERATION_FAILED; $logs = $e->getMessage(); $currentLogs = $certificate->getAttribute('logs', ''); diff --git a/src/Appwrite/Utopia/Response/Model/Rule.php b/src/Appwrite/Utopia/Response/Model/Rule.php index 33416ad3bb..958cd2dd45 100644 --- a/src/Appwrite/Utopia/Response/Model/Rule.php +++ b/src/Appwrite/Utopia/Response/Model/Rule.php @@ -84,9 +84,9 @@ class Rule extends Model ]) ->addRule('status', [ 'type' => self::TYPE_STRING, - 'description' => 'Domain verification status. Possible values are "created", "verifying", "verified" and "unverified"', + 'description' => 'Domain verification status. Possible values are "' . RULE_STATUS_VERIFICATION_FAILED . '", "' . RULE_STATUS_GENERATING_CERTIFICATE . '", "' . RULE_STATUS_SUCCESSFUL . '" and "' . RULE_STATUS_GENERATION_FAILED . '"', 'default' => false, - 'example' => 'verified', + 'example' => RULE_STATUS_SUCCESSFUL, ]) ->addRule('verificationLogs', [ 'type' => self::TYPE_STRING, diff --git a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php index 50d978902f..522547e837 100644 --- a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php +++ b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php @@ -86,7 +86,7 @@ class ProxyCustomServerTest extends Scope $domain = \uniqid() . '.com'; $rule = $this->createAPIRule($domain); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); } public function testCreateRuleVcs(): void @@ -389,7 +389,7 @@ class ProxyCustomServerTest extends Scope $rule = $this->createAPIRule($domain); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('verified', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_SUCCESSFUL, $rule['body']['status']); $this->cleanupRule($rule['body']['$id']); @@ -398,7 +398,7 @@ class ProxyCustomServerTest extends Scope $rule = $this->createAPIRule($domain); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('verified', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_SUCCESSFUL, $rule['body']['status']); $this->cleanupRule($rule['body']['$id']); @@ -407,7 +407,7 @@ class ProxyCustomServerTest extends Scope $rule = $this->createAPIRule($domain); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $ruleId = $rule['body']['$id']; @@ -580,7 +580,7 @@ class ProxyCustomServerTest extends Scope $rule = $this->createSiteRule('stage-site.webapp.com', $siteId); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('verifying', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_GENERATING_CERTIFICATE, $rule['body']['status']); $this->assertEmpty($rule['body']['verificationLogs']); $this->cleanupRule($rule['body']['$id']); @@ -592,13 +592,13 @@ class ProxyCustomServerTest extends Scope $rule = $this->createFunctionRule('stage-function.webapp.com', $functionId); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('verifying', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_GENERATING_CERTIFICATE, $rule['body']['status']); $this->assertEmpty($rule['body']['verificationLogs']); $this->cleanupRule($rule['body']['$id']); $rule = $this->createAPIRule('stage-site.webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->assertStringContainsString('has incorrect CNAME value', $rule['body']['verificationLogs']); $this->cleanupRule($rule['body']['$id']); @@ -607,7 +607,7 @@ class ProxyCustomServerTest extends Scope // 3. Wrong A record fails to verify $rule = $this->createAPIRule('wrong-a-webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->assertStringContainsString('is missing CNAME record', $rule['body']['verificationLogs']); $ruleId = $rule['body']['$id']; @@ -617,14 +617,14 @@ class ProxyCustomServerTest extends Scope $rule = $this->getRule($ruleId); $this->assertEquals(200, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->cleanupRule($ruleId); // 4. Correct A record can verify $rule = $this->createAPIRule('webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('verifying', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_GENERATING_CERTIFICATE, $rule['body']['status']); $this->assertEmpty($rule['body']['verificationLogs']); $this->cleanupRule($rule['body']['$id']); @@ -632,7 +632,7 @@ class ProxyCustomServerTest extends Scope // 5. Correct CNAME record can verify (no CAA record) $rule = $this->createAPIRule('stage.webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('verifying', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_GENERATING_CERTIFICATE, $rule['body']['status']); $this->assertEmpty($rule['body']['verificationLogs']); $this->cleanupRule($rule['body']['$id']); @@ -640,7 +640,7 @@ class ProxyCustomServerTest extends Scope // 6. Missing CNAME record fails to verify $rule = $this->createAPIRule('stage-missing-cname.webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->assertStringContainsString('is missing CNAME record', $rule['body']['verificationLogs']); $ruleId = $rule['body']['$id']; @@ -650,14 +650,14 @@ class ProxyCustomServerTest extends Scope $rule = $this->getRule($ruleId); $this->assertEquals(200, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->cleanupRule($ruleId); // 7. Wrong CNAME record fails to verify $rule = $this->createAPIRule('stage-wrong-cname.webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->assertStringContainsString('has incorrect CNAME value', $rule['body']['verificationLogs']); $ruleId = $rule['body']['$id']; @@ -667,14 +667,14 @@ class ProxyCustomServerTest extends Scope $rule = $this->getRule($ruleId); $this->assertEquals(200, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->cleanupRule($ruleId); // 8. Wrong CAA record fails to verify $rule = $this->createAPIRule('stage-wrong-caa.webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->assertStringContainsString('has incorrect CAA value', $rule['body']['verificationLogs']); $ruleId = $rule['body']['$id']; @@ -684,14 +684,14 @@ class ProxyCustomServerTest extends Scope $rule = $this->getRule($ruleId); $this->assertEquals(200, $rule['headers']['status-code']); - $this->assertEquals('created', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_VERIFICATION_FAILED, $rule['body']['status']); $this->cleanupRule($ruleId); // 9. Correct CAA record can verify $rule = $this->createAPIRule('stage-correct-caa.webapp.com'); $this->assertEquals(201, $rule['headers']['status-code']); - $this->assertEquals('verifying', $rule['body']['status']); + $this->assertEquals(RULE_STATUS_GENERATING_CERTIFICATE, $rule['body']['status']); $this->assertEmpty($rule['body']['verificationLogs']); $this->cleanupRule($rule['body']['$id']);