summaryrefslogtreecommitdiff
path: root/ext/standard/tests/network/dns_get_record_caa.phpt
blob: 21286921e169a1ff14beaf005ff0c980a106722a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--TEST--
dns_get_record() CAA tests
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
?>
--FILE--
<?php
/* This must be domains which publish an RFC6844 CAA-type DNS record */
$domains = ["big.basic.caatestsuite.com", "google.com"];
foreach ($domains as $domain) {
    $match = false;
    $dns = dns_get_record($domain, DNS_CAA);
    if (count($dns) > 0) {
        if (array_key_exists("type", $dns[0])
        and $dns[0]["type"] == "CAA"
        and array_key_exists("flags", $dns[0])
        and array_key_exists("tag", $dns[0])
        and array_key_exists("value", $dns[0])
        ) {
            $chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.";
            if (strlen($dns[0]["value"]) == strspn($dns[0]["value"], $chars)) {
                $match = true;
            }
        }
    }
    if ($match) {
        echo "CAA record found\n";
    } else {
        echo "CAA lookup failed\n";
        var_dump($dns);
    }
}
?>
--EXPECT--
CAA record found
CAA record found