Merge pull request #13473 from ChiragAgg5k/fix/flaky-proxy-verification

fix: isolate proxy DNS verification fixtures behind a recursive test resolver
This commit is contained in:
Chirag Aggarwal authored and GitHub committed 2026-09-04 07:08:33 -07:00
commit 5079264100
8 files changed
+84 -100

No files matched your search

+6 -8
View File
@@ -20,7 +20,7 @@ services:
- ./src:/usr/src/code/src
- ./dev:/usr/src/code/dev
depends_on:
- coredns
- dns
ports:
- 9501:80
dns:
@@ -301,23 +301,21 @@ services:
volumes:
- ./app:/usr/src/code/app
- ./src:/usr/src/code/src
coredns:
image: coredns/coredns:1.12.4
container_name: appwrite-coredns
dns:
image: alpinelinux/unbound:latest@sha256:8d2611fe8fcbd8e26b6f88e2eb0c3b803368195d50cfa0c30fdfaa5087076709
container_name: appwrite-dns
restart: unless-stopped
logging:
driver: json-file
options:
max-file: "5"
max-size: 10m
command:
- -conf
- /mnt/resources/Corefile
entrypoint: ["unbound", "-d", "-c", "/mnt/resources/unbound.conf"]
networks:
appwrite:
ipv4_address: 172.16.238.100
volumes:
- ./tests/resources/coredns:/mnt/resources:ro
- ./tests/resources/dns:/mnt/resources:ro
maildev:
image: appwrite/mailcatcher:1.1.1
container_name: appwrite-mailcatcher
+12 -12
View File
@@ -12,8 +12,7 @@ trait ProxyBase
protected function tearDown(): void
{
// Cleanup for testRuleVerification test
// Required as it uses static domain name
// Cleanup fixture rules left by failed verification tests
$rules = $this->listRules([
'queries' => [
Query::endsWith('domain', 'webapp.com')->toString(),
@@ -665,12 +664,13 @@ trait ProxyBase
public function testRuleVerification(): void
{
$fixture = \uniqid($this->getSide() . '-');
// 1. Site rule can verify
$site = $this->setupSite();
$siteId = $site['siteId'];
$rule = $this->createSiteRule('stage-site.webapp.com', $siteId);
$rule = $this->createSiteRule("{$fixture}.stage-site.webapp.com", $siteId);
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('verifying', $rule['body']['status']);
$this->assertEmpty($rule['body']['logs']);
@@ -690,13 +690,13 @@ trait ProxyBase
$function = $this->setupFunction();
$functionId = $function['functionId'];
$rule = $this->createFunctionRule('stage-function.webapp.com', $functionId);
$rule = $this->createFunctionRule("{$fixture}.stage-function.webapp.com", $functionId);
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('verifying', $rule['body']['status']);
$this->assertEmpty($rule['body']['logs']);
$this->cleanupRule($rule['body']['$id']);
$rule = $this->createAPIRule('stage-site.webapp.com');
$rule = $this->createAPIRule("{$fixture}.stage-site.webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('unverified', $rule['body']['status']);
$this->assertStringContainsString('has incorrect CNAME value', $rule['body']['logs']);
@@ -705,7 +705,7 @@ trait ProxyBase
$this->cleanupFunction($functionId);
// 3. Wrong A record fails to verify
$rule = $this->createAPIRule('wrong-a-webapp.com');
$rule = $this->createAPIRule("{$fixture}.wrong-a-webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('unverified', $rule['body']['status']);
$this->assertStringContainsString('is missing CNAME record', $rule['body']['logs']);
@@ -722,7 +722,7 @@ trait ProxyBase
$this->cleanupRule($ruleId);
// 4. Correct A record can verify
$rule = $this->createAPIRule('webapp.com');
$rule = $this->createAPIRule("{$fixture}.correct-a.webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('verifying', $rule['body']['status']);
$this->assertEmpty($rule['body']['logs']);
@@ -730,7 +730,7 @@ trait ProxyBase
$this->cleanupRule($rule['body']['$id']);
// 5. Correct CNAME record can verify (no CAA record)
$rule = $this->createAPIRule('stage.webapp.com');
$rule = $this->createAPIRule("{$fixture}.stage.webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('verifying', $rule['body']['status']);
$this->assertEmpty($rule['body']['logs']);
@@ -738,7 +738,7 @@ trait ProxyBase
$this->cleanupRule($rule['body']['$id']);
// 6. Missing CNAME record fails to verify
$rule = $this->createAPIRule('stage-missing-cname.webapp.com');
$rule = $this->createAPIRule("{$fixture}.stage-missing-cname.webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('unverified', $rule['body']['status']);
$this->assertStringContainsString('is missing CNAME record', $rule['body']['logs']);
@@ -755,7 +755,7 @@ trait ProxyBase
$this->cleanupRule($ruleId);
// 7. Wrong CNAME record fails to verify
$rule = $this->createAPIRule('stage-wrong-cname.webapp.com');
$rule = $this->createAPIRule("{$fixture}.stage-wrong-cname.webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('unverified', $rule['body']['status']);
$this->assertStringContainsString('has incorrect CNAME value', $rule['body']['logs']);
@@ -772,7 +772,7 @@ trait ProxyBase
$this->cleanupRule($ruleId);
// 8. Wrong CAA record fails to verify
$rule = $this->createAPIRule('stage-wrong-caa.webapp.com');
$rule = $this->createAPIRule("{$fixture}.stage-wrong-caa.webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('unverified', $rule['body']['status']);
$this->assertStringContainsString('has incorrect CAA value', $rule['body']['logs']);
@@ -789,7 +789,7 @@ trait ProxyBase
$this->cleanupRule($ruleId);
// 9. Correct CAA record can verify
$rule = $this->createAPIRule('stage-correct-caa.webapp.com');
$rule = $this->createAPIRule("{$fixture}.stage-correct-caa.webapp.com");
$this->assertEquals(201, $rule['headers']['status-code']);
$this->assertEquals('verifying', $rule['body']['status']);
$this->assertEmpty($rule['body']['logs']);
-78
View File
@@ -1,78 +0,0 @@
# Forward unknown queries to Docker's embedded DNS for service name resolution,
# with Cloudflare as fallback for external names.
# Bind to our static IP to avoid conflict with Docker's DNS proxy on 127.0.0.11.
. {
bind 172.16.238.100
forward . 127.0.0.11 1.1.1.1
}
# Zones configuration
webapp.com {
bind 172.16.238.100
template IN A {
match "^webapp\.com\.$"
answer "{{ .Name }} 60 IN A 203.0.0.1"
fallthrough
}
template IN CNAME {
match "^stage-site\.webapp\.com\.$"
answer "{{ .Name }} 60 IN CNAME sites.localhost."
fallthrough
}
template IN CNAME {
match "^stage-function\.webapp\.com\.$"
answer "{{ .Name }} 60 IN CNAME cname.localhost."
fallthrough
}
template IN CNAME {
match "^stage\.webapp\.com\.$"
answer "{{ .Name }} 60 IN CNAME cname.localhost."
fallthrough
}
template IN CNAME {
match "^stage-wrong-cname\.webapp\.com\.$"
answer "{{ .Name }} 60 IN CNAME cname-wrong.tests.appwrite.io."
fallthrough
}
template IN A {
match "^stage-wrong-caa\.webapp\.com\.$"
answer "{{ .Name }} 60 IN A 203.0.0.1"
fallthrough
}
template IN CAA {
match "^stage-wrong-caa\.webapp\.com\.$"
answer "{{ .Name }} 60 IN CAA 0 issue \"unknown-issuer.org\""
fallthrough
}
template IN A {
match "^stage-correct-caa\.webapp\.com\.$"
answer "{{ .Name }} 60 IN A 203.0.0.1"
fallthrough
}
template IN CAA {
match "^stage-correct-caa\.webapp\.com\.$"
answer "{{ .Name }} 60 IN CAA 0 issue \"digicert.com\""
fallthrough
}
forward . 1.1.1.1
}
# Zones configuration
wrong-a-webapp.com {
bind 172.16.238.100
template IN A {
match "^wrong-a-webapp\.com\.$"
answer "{{ .Name }} 60 IN A 203.0.0.5"
fallthrough
}
}
+7
View File
@@ -0,0 +1,7 @@
server:
do-not-query-localhost: no
forward-zone:
name: "."
forward-addr: 127.0.0.11
forward-addr: 1.1.1.1
+3
View File
@@ -0,0 +1,3 @@
$TTL 60
localhost. IN SOA ns.localhost. hostmaster.localhost. 1 3600 600 86400 60
localhost. IN NS ns.localhost.
+14
View File
@@ -0,0 +1,14 @@
server:
interface: 0.0.0.0
port: 53
do-ip6: no
access-control: 0.0.0.0/0 allow
verbosity: 1
log-queries: yes
cache-max-ttl: 60
cache-min-ttl: 0
val-permissive-mode: yes
include: "/mnt/resources/zones.conf"
include: "/mnt/resources/forward.conf"
+40
View File
@@ -0,0 +1,40 @@
local-zone: "webapp.com." static
local-data: "webapp.com. 60 IN SOA ns.webapp.com. hostmaster.webapp.com. 1 3600 600 86400 60"
local-data: "webapp.com. 60 IN A 203.0.0.1"
local-zone: "stage.webapp.com." redirect
local-data: "stage.webapp.com. 60 IN CNAME cname.localhost."
local-zone: "stage-site.webapp.com." redirect
local-data: "stage-site.webapp.com. 60 IN CNAME sites.localhost."
local-zone: "stage-function.webapp.com." redirect
local-data: "stage-function.webapp.com. 60 IN CNAME cname.localhost."
local-zone: "stage-wrong-cname.webapp.com." redirect
local-data: "stage-wrong-cname.webapp.com. 60 IN CNAME cname-wrong.localhost."
local-zone: "correct-a.webapp.com." redirect
local-data: "correct-a.webapp.com. 60 IN SOA ns.webapp.com. hostmaster.webapp.com. 1 3600 600 86400 60"
local-data: "correct-a.webapp.com. 60 IN A 203.0.0.1"
local-zone: "stage-wrong-caa.webapp.com." redirect
local-data: "stage-wrong-caa.webapp.com. 60 IN SOA ns.webapp.com. hostmaster.webapp.com. 1 3600 600 86400 60"
local-data: "stage-wrong-caa.webapp.com. 60 IN A 203.0.0.1"
local-data: 'stage-wrong-caa.webapp.com. 60 IN CAA 0 issue "unknown-issuer.org"'
local-zone: "stage-correct-caa.webapp.com." redirect
local-data: "stage-correct-caa.webapp.com. 60 IN SOA ns.webapp.com. hostmaster.webapp.com. 1 3600 600 86400 60"
local-data: "stage-correct-caa.webapp.com. 60 IN A 203.0.0.1"
local-data: 'stage-correct-caa.webapp.com. 60 IN CAA 0 issue "digicert.com"'
local-zone: "wrong-a-webapp.com." redirect
local-data: "wrong-a-webapp.com. 60 IN SOA ns.wrong-a-webapp.com. hostmaster.wrong-a-webapp.com. 1 3600 600 86400 60"
local-data: "wrong-a-webapp.com. 60 IN A 203.0.0.5"
auth-zone:
name: "localhost."
zonefile: "/mnt/resources/localhost.zone"
for-downstream: yes
for-upstream: yes
fallback-enabled: no
+2 -2
View File
@@ -38,9 +38,9 @@ final class DNSTest extends TestCase
$this->assertNotEmpty($validator->getDescription());
}
public function testCoreDNSFailure(): void
public function testFixtureResolverFailure(): void
{
// CoreDNS is configured to return cname.localhost. for stage.webapp.com
// The test resolver (tests/resources/dns) returns cname.localhost. for stage.webapp.com
$validator = new DNS('cname.localhost.', Record::TYPE_CNAME, ['172.16.238.100', '8.8.8.8']);
$result = $validator->isValid('stage.webapp.com');