mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2024-06-26 09:09:07 +02:00
fixed the tests
This commit is contained in:
parent
e5a56222a3
commit
b33ea3b77f
|
@ -9,9 +9,6 @@ env:
|
||||||
- OS=debian ARCH=amd64
|
- OS=debian ARCH=amd64
|
||||||
- OS=debian ARCH=armhf
|
- OS=debian ARCH=armhf
|
||||||
- OS=debian ARCH=aarch64
|
- OS=debian ARCH=aarch64
|
||||||
- OS=alpine ARCH=amd64
|
|
||||||
- OS=alpine ARCH=armhf
|
|
||||||
# - OS=alpine ARCH=aarch64 # Impossible combo :(
|
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
install:
|
install:
|
||||||
|
|
|
@ -48,18 +48,22 @@ def test_indecies_are_present(RunningPiHole):
|
||||||
File('/var/www/html/pihole/index.html').exists
|
File('/var/www/html/pihole/index.html').exists
|
||||||
File('/var/www/html/pihole/index.js').exists
|
File('/var/www/html/pihole/index.js').exists
|
||||||
|
|
||||||
|
def validate_curl(http_rc, expected_http_code, page_contents):
|
||||||
|
if int(http_rc.rc) != 0 or int(http_rc.stdout) != expected_http_code:
|
||||||
|
print 'CURL return code: {}'.format(http_rc.rc)
|
||||||
|
print 'CURL stdout: {}'.format(http_rc.stdout)
|
||||||
|
print 'CURL stderr:{}'.format(http_rc.stderr)
|
||||||
|
print 'CURL file:\n{}\n'.format(page_contents.encode('ascii'))
|
||||||
|
|
||||||
@pytest.mark.parametrize('addr', [ 'testblock.pi-hole.local' ])
|
@pytest.mark.parametrize('addr', [ 'testblock.pi-hole.local' ])
|
||||||
@pytest.mark.parametrize('url', [ '/', '/index.html', '/any.html' ] )
|
@pytest.mark.parametrize('url', [ '/', '/index.html', '/any.html' ] )
|
||||||
def test_html_index_requests_load_as_expected(RunningPiHole, Slow, addr, url):
|
def test_html_index_requests_load_as_expected(RunningPiHole, Slow, addr, url):
|
||||||
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
|
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
|
||||||
http_rc = RunningPiHole.run(command)
|
http_rc = RunningPiHole.run(command)
|
||||||
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
|
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
|
||||||
expeced_http_code = 200
|
expected_http_code = 200
|
||||||
|
|
||||||
if http_rc != 0 or http_rc.stdout != expected_http_code:
|
|
||||||
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
|
|
||||||
http_rc.stdout, http_rc.stderr, page_contents)
|
|
||||||
|
|
||||||
|
validate_curl(http_rc, expected_http_code, page_contents)
|
||||||
assert http_rc.rc == 0
|
assert http_rc.rc == 0
|
||||||
assert int(http_rc.stdout) == expected_http_code
|
assert int(http_rc.stdout) == expected_http_code
|
||||||
assert 'testblock.pi-hole.local' in page_contents
|
assert 'testblock.pi-hole.local' in page_contents
|
||||||
|
@ -70,12 +74,9 @@ def test_javascript_requests_load_as_expected(RunningPiHole, addr, url):
|
||||||
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
|
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
|
||||||
http_rc = RunningPiHole.run(command)
|
http_rc = RunningPiHole.run(command)
|
||||||
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
|
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
|
||||||
expeced_http_code = 200
|
expected_http_code = 200
|
||||||
|
|
||||||
if http_rc != 0 or http_rc.stdout != expected_http_code:
|
|
||||||
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
|
|
||||||
http_rc.stdout, http_rc.stderr, page_contents)
|
|
||||||
|
|
||||||
|
validate_curl(http_rc, expected_http_code, page_contents)
|
||||||
assert http_rc.rc == 0
|
assert http_rc.rc == 0
|
||||||
assert int(http_rc.stdout) == expected_http_code
|
assert int(http_rc.stdout) == expected_http_code
|
||||||
assert 'var x = "Pi-hole: A black hole for Internet advertisements."' in page_contents
|
assert 'var x = "Pi-hole: A black hole for Internet advertisements."' in page_contents
|
||||||
|
@ -87,12 +88,9 @@ def test_admin_requests_load_as_expected(RunningPiHole, addr, url):
|
||||||
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
|
command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url)
|
||||||
http_rc = RunningPiHole.run(command)
|
http_rc = RunningPiHole.run(command)
|
||||||
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
|
page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout
|
||||||
expeced_http_code = 200
|
expected_http_code = 200
|
||||||
|
|
||||||
if http_rc != 0 or http_rc.stdout != expected_http_code:
|
|
||||||
print 'CURL stdout: {}\nCURL stderr:{}\nCURL file:\n{}\n'.format(
|
|
||||||
http_rc.stdout, http_rc.stderr, page_contents)
|
|
||||||
|
|
||||||
|
validate_curl(http_rc, expected_http_code, page_contents)
|
||||||
assert http_rc.rc == 0
|
assert http_rc.rc == 0
|
||||||
assert int(http_rc.stdout) == expected_http_code
|
assert int(http_rc.stdout) == expected_http_code
|
||||||
for html_text in ['dns_queries_today', 'Content-Security-Policy', 'scripts/pi-hole/js/footer.js']:
|
for html_text in ['dns_queries_today', 'Content-Security-Policy', 'scripts/pi-hole/js/footer.js']:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user