From e508f049bfc7edec7df91cab236fa2d3ec189e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 12 Sep 2025 20:37:36 +0200 Subject: [PATCH] Prepare coreDNS for proxy tests --- .env | 4 ++-- docker-compose.yml | 22 +++++++++++++++++++ .../Services/Proxy/ProxyCustomServerTest.php | 11 ++++++++++ tests/resources/coredns/Corefile | 15 +++++++++++++ tests/resources/coredns/webapp.com.zone | 19 ++++++++++++++++ .../resources/coredns/wrong-a-webapp.com.zone | 8 +++++++ 6 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 tests/resources/coredns/Corefile create mode 100644 tests/resources/coredns/webapp.com.zone create mode 100644 tests/resources/coredns/wrong-a-webapp.com.zone diff --git a/.env b/.env index bb21aa50f2..c276540f41 100644 --- a/.env +++ b/.env @@ -26,8 +26,8 @@ _APP_DOMAIN=traefik _APP_CONSOLE_DOMAIN=localhost _APP_DOMAIN_FUNCTIONS=functions.localhost _APP_DOMAIN_SITES=sites.localhost -_APP_DOMAIN_TARGET_CNAME=test.l -_APP_DOMAIN_TARGET_A=127.0.0.1 +_APP_DOMAIN_TARGET_CNAME=cname.tests.appwrite.io +_APP_DOMAIN_TARGET_A=203.0.0.1 _APP_DOMAIN_TARGET_AAAA=::1 _APP_DOMAIN_TARGET_CAA=digicert.com _APP_RULES_FORMAT=md5 diff --git a/docker-compose.yml b/docker-compose.yml index 5e65122256..86c88a3b27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -89,9 +89,12 @@ services: - ./public:/usr/src/code/public - ./src:/usr/src/code/src - ./dev:/usr/src/code/dev + dns: + - 172.16.238.100 depends_on: - mariadb - redis + - coredns # - clamav entrypoint: - php @@ -524,9 +527,12 @@ services: image: appwrite-dev networks: - appwrite + dns: + - 172.16.238.100 depends_on: - redis - mariadb + - coredns volumes: - appwrite-config:/storage/config:rw - appwrite-certificates:/storage/certificates:rw @@ -1068,6 +1074,19 @@ services: - appwrite volumes: - appwrite-redis:/data:rw + + coredns: # DNS server for testing purposes (Proxy APIs) + image: coredns/coredns:1.12.4 + container_name: appwrite-coredns + <<: *x-logging + command: ["-conf", "/mnt/resources/Corefile"] + ports: + - "1053:1053" + networks: + appwrite: + ipv4_address: 172.16.238.100 + volumes: + - ./tests/resources/coredns:/mnt/resources:ro # Dev Tools Start ------------------------------------------------------------------------------------------ # @@ -1146,6 +1165,9 @@ networks: name: gateway appwrite: name: appwrite + ipam: + config: + - subnet: 172.16.238.0/24 runtimes: name: runtimes diff --git a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php index 5a1cd1dea6..4778e5e69f 100644 --- a/tests/e2e/Services/Proxy/ProxyCustomServerTest.php +++ b/tests/e2e/Services/Proxy/ProxyCustomServerTest.php @@ -540,4 +540,15 @@ class ProxyCustomServerTest extends Scope $this->assertEquals(0, $rules['body']['total']); $this->assertCount(0, $rules['body']['rules']); } + + public function testRuleVerification(): void + { + // TODO: Implement + // wrong-a-webapp.com + // webapp.com + // stage.webapp.com + // stage-wrong-cname.webapp.com + // stage-wrong-caa.webapp.com + // stage-correct-caa.webapp.com + } } diff --git a/tests/resources/coredns/Corefile b/tests/resources/coredns/Corefile new file mode 100644 index 0000000000..591291aed3 --- /dev/null +++ b/tests/resources/coredns/Corefile @@ -0,0 +1,15 @@ +# Re-use public resolver to answer unknown queries +. { + forward . 1.1.1.1 +} + +# Zones configuration +webapp.com { + file /mnt/resources/webapp.com.zone +} + +# Zones configuration +wrong-a-webapp.com { + file /mnt/resources/wrong-a-webapp.com.zone +} + diff --git a/tests/resources/coredns/webapp.com.zone b/tests/resources/coredns/webapp.com.zone new file mode 100644 index 0000000000..46ca9b65b2 --- /dev/null +++ b/tests/resources/coredns/webapp.com.zone @@ -0,0 +1,19 @@ +; Nessessary setup +$ORIGIN webapp.com. +@ IN SOA ns1.webapp.com. hostmaster.webapp.com. (2025091201 7200 3600 1209600 3600) +@ IN NS ns1.webapp.com. +ns1 IN A 127.0.0.1 + +; Custom DNS records +@ IN A 203.0.0.1 + +stage IN CNAME cname.tests.appwrite.io +; No CAA record intentionally + +stage-wrong-cname IN CNAME cname-wrong.tests.appwrite.io + +stage-wrong-caa IN CNAME cname.tests.appwrite.io +stage-wrong-caa IN CAA 0 issue "unknown-issuer.org" + +stage-correct-caa IN CNAME cname.tests.appwrite.io +stage-correct-caa IN CAA 0 issue "digicert.com" diff --git a/tests/resources/coredns/wrong-a-webapp.com.zone b/tests/resources/coredns/wrong-a-webapp.com.zone new file mode 100644 index 0000000000..d4997419b4 --- /dev/null +++ b/tests/resources/coredns/wrong-a-webapp.com.zone @@ -0,0 +1,8 @@ +; Nessessary setup +$ORIGIN wrong-a-webapp.com.zone. +@ IN SOA ns1.wrong-a-webapp.com.zone. hostmaster.wrong-a-webapp.com.zone. (2025091201 7200 3600 1209600 3600) +@ IN NS ns1.wrong-a-webapp.com.zone. +ns1 IN A 127.0.0.1 + +; Custom DNS records +@ IN A 203.0.0.5