From 30fe0a3353926edf4d66c72d245a8b691f0e6da2 Mon Sep 17 00:00:00 2001 From: diginc Date: Sun, 28 Aug 2016 01:11:55 -0500 Subject: [PATCH] Added more http endpoint tests Forgot to uncomment these, revealed a flaw in the nginx config nginx now has parity with lighttpd for pages it returns and return codes --- alpine/nginx.conf | 13 +++++++------ test/conftest.py | 2 +- test/test_start.py | 6 ++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/alpine/nginx.conf b/alpine/nginx.conf index 70c0183..d111585 100644 --- a/alpine/nginx.conf +++ b/alpine/nginx.conf @@ -14,13 +14,17 @@ http { server { listen 80; listen [::]:80; - root /var/www/html/pihole; - index index.php index.html index.nginx-debian.html; + root /var/www/html; + index /pihole/index.html; + error_page 404 =200 /pihole/index.html; - error_page 404 /pihole/index.html; + location / { + add_header X-Pi-hole "A black hole for Internet advertisements." always; + } location ~ ^/admin/ { add_header X-Pi-hole "The Pi-hole Web interface is working!"; + add_header X-Frame-Options "DENY" always; location ~ .php$ { fastcgi_pass 127.0.0.1:9000; @@ -30,9 +34,6 @@ http { } } - location / { - add_header X-Pi-hole "A black hole for Internet advertisements." always; - } } } diff --git a/test/conftest.py b/test/conftest.py index 01c3330..aa51807 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -77,7 +77,7 @@ def Slow(): Run a slow check, check if the state is correct for `timeout` seconds. """ import time - def slow(check, timeout=15): + def slow(check, timeout=5): timeout_at = time.time() + timeout while True: try: diff --git a/test/test_start.py b/test/test_start.py index b3798d1..8cdefd3 100644 --- a/test/test_start.py +++ b/test/test_start.py @@ -33,8 +33,7 @@ def test_indecies_are_present(RunningPiHole): File('/var/www/html/pihole/index.html').exists File('/var/www/html/pihole/index.js').exists -@pytest.mark.parametrize('url', [ '/' ] ) -#@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, url): command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://127.0.0.1{}'.format(url) print command @@ -44,8 +43,7 @@ def test_html_index_requests_load_as_expected(RunningPiHole, url): assert RunningPiHole.run('md5sum /tmp/curled_file /var/www/html/pihole/index.html').rc == 0 assert int(http_rc.stdout) == 200 -@pytest.mark.parametrize('url', [ '/index.js' ] ) -#@pytest.mark.parametrize('url', [ '/index.js', '/any.js'] ) +@pytest.mark.parametrize('url', [ '/index.js', '/any.js'] ) def test_javascript_requests_load_as_expected(RunningPiHole, url): command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://127.0.0.1{}'.format(url) print command