mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-24 04:18:43 +00:00
Persistent dig container running dns tests
* Sidekick to pi-hole links and queries DNS * Lookup the default pi.hole against what was fed in as ServerIP * Lookup a couple outside popular static DNS servers hostnames too * a little pre-optimized to persist the dig container since docker start adds half a second (no virtually nothing for digs)
This commit is contained in:
@@ -24,10 +24,20 @@ def test_ServerIP_missing_triggers_start_error(Docker):
|
||||
|
||||
@pytest.fixture
|
||||
def RunningPiHole(DockerPersist, Slow, persist_webserver):
|
||||
''' Persist a docker and provide some parameterized data for re-use '''
|
||||
Slow(lambda: DockerPersist.run( 'pgrep {}'.format(persist_webserver) ).rc == 0)
|
||||
''' Persist a working docker-pi-hole to help speed up subsequent tests '''
|
||||
Slow(lambda: DockerPersist.run('pgrep {}'.format(persist_webserver) ).rc == 0)
|
||||
return DockerPersist
|
||||
|
||||
@pytest.mark.parametrize('hostname,expected_ip', [
|
||||
('pi.hole', '192.168.100.2'),
|
||||
('google-public-dns-a.google.com', '8.8.8.8'),
|
||||
('b.resolvers.Level3.net', '4.2.2.2')
|
||||
])
|
||||
def test_dns_responses(RunningPiHole, hostname, expected_ip):
|
||||
dig_cmd = "dig +noall +answer {} @pihole | awk '{{ print $5 }}'".format(hostname)
|
||||
lookup = RunningPiHole.dig.run(dig_cmd).stdout.rstrip('\n')
|
||||
assert lookup == expected_ip
|
||||
|
||||
def test_indecies_are_present(RunningPiHole):
|
||||
File = RunningPiHole.get_module('File')
|
||||
File('/var/www/html/pihole/index.html').exists
|
||||
|
||||
Reference in New Issue
Block a user