-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathtest_resolvers.py
37 lines (30 loc) · 1.2 KB
/
test_resolvers.py
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
"""Test internal resolvers."""
import pytest
import subprocess
from .conftest import ipv6_available
def docker_compose_exec(service, command, env="develop"):
cmd = f"docker compose --ansi=never --project-name=internetnl-{env} exec -ti {service} /bin/sh -c '{command}'"
print(cmd)
try:
output = subprocess.check_output(cmd, shell=True, universal_newlines=True, stderr=subprocess.STDOUT)
returncode = 0
except subprocess.CalledProcessError as e:
print(dir(e))
returncode = e.returncode
output = e.output
return returncode, output
@pytest.mark.skipif(not ipv6_available(), reason="IPv6 networking not available")
def test_validating_resolver():
returncode, output = docker_compose_exec(
"app", "ldns-dane -n -T verify internet.nl 443 -r $IPV4_IP_RESOLVER_INTERNAL_VALIDATING"
)
print(output)
assert "dane-validated successfully" in output
assert returncode == 0
def test_permissive_resolver():
returncode, output = docker_compose_exec(
"app", "ldns-dane -n -T verify internet.nl 443 -r $IPV4_IP_RESOLVER_INTERNAL_PERMISSIVE"
)
print(output)
assert "did not dane-validate" in output
assert returncode == 1