From d3309ebb1a0aaed7606ed16411659e3f00353b54 Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Mon, 21 Jan 2019 22:43:38 -0600 Subject: [PATCH] remove old blocking page setup/test Signed-off-by: Adam Hill --- bash_functions.sh | 20 +------------------- test/conftest.py | 2 -- test/test_start.py | 33 ++++----------------------------- 3 files changed, 5 insertions(+), 50 deletions(-) diff --git a/bash_functions.sh b/bash_functions.sh index 68d0caa..ee1060a 100644 --- a/bash_functions.sh +++ b/bash_functions.sh @@ -334,28 +334,10 @@ setup_blocklists() { return fi - # 3. If we're running tests, use a small list of fake tests to speed everything up - if [ -n "$PYTEST" ]; then - echo ":::::: Tests are being ran - stub out ad list fetching and add a fake ad block ${exit_string}" - sed -i 's/^gravity_spinup$/#gravity_spinup # DISABLED FOR PYTEST/g' "$(which gravity.sh)" - echo '123.123.123.123 testblock.pi-hole.local' > "/var/www/html/fake.list" - echo 'file:///var/www/html/fake.list' > "${adlistFile}" - echo 'http://localhost/fake.list' >> "${adlistFile}" - return - fi - echo "::: ${FUNCNAME[0]} now setting default blocklists up: " echo "::: TIP: Use a docker volume for ${adlistFile} if you want to customize for first boot" > "${adlistFile}" - # Just copied outa the choices for now - # https://github.com/pi-hole/pi-hole/blob/FTLDNS/automated%20install/basic-install.sh#L1014 - echo "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" >> "${adlistFile}" - echo "https://mirror1.malwaredomains.com/files/justdomains" >> "${adlistFile}" - echo "http://sysctl.org/cameleon/hosts" >> "${adlistFile}" - echo "https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist" >> "${adlistFile}" - echo "https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt" >> "${adlistFile}" - echo "https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt" >> "${adlistFile}" - echo "https://hosts-file.net/ad_servers.txt" >> "${adlistFile}" + installDefaultBlocklists echo "::: Blocklists (${adlistFile}) now set to:" cat "${adlistFile}" diff --git a/test/conftest.py b/test/conftest.py index 87b3df6..2cf9adc 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -96,7 +96,6 @@ def arch(request): @pytest.fixture() def version(request): - ''' TODO: include from external .py that can be shared with Dockerfile.py / Tests / deploy scripts ''' return __version__ @pytest.fixture() @@ -124,7 +123,6 @@ def persist_arch(request): @pytest.fixture(scope='module') def persist_version(request): - ''' TODO: include from external .py that can be shared with Dockerfile.py / Tests / deploy scripts ''' return __version__ @pytest.fixture(scope='module') diff --git a/test/test_start.py b/test/test_start.py index 9a51043..bfbdb14 100644 --- a/test/test_start.py +++ b/test/test_start.py @@ -48,38 +48,12 @@ def validate_curl(http_rc, expected_http_code, page_contents): 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')) + print 'CURL file:\n{}\n'.format(page_contents.encode('utf-8')) -@pytest.mark.parametrize('addr', [ 'testblock.pi-hole.local' ]) -@pytest.mark.parametrize('url', [ '/', '/index.html', '/any.html' ] ) -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) - http_rc = RunningPiHole.run(command) - page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout - expected_http_code = 200 - validate_curl(http_rc, expected_http_code, page_contents) - assert http_rc.rc == 0 - assert int(http_rc.stdout) == expected_http_code - assert 'testblock.pi-hole.local' in page_contents - -@pytest.mark.parametrize('addr', [ 'testblock.pi-hole.local' ]) -@pytest.mark.parametrize('url', [ '/index.js', '/any.js'] ) -def test_javascript_requests_load_as_expected(RunningPiHole, addr, url): - command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url) - http_rc = RunningPiHole.run(command) - page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout - expected_http_code = 200 - - validate_curl(http_rc, expected_http_code, page_contents) - assert http_rc.rc == 0 - assert int(http_rc.stdout) == expected_http_code - assert 'var x = "Pi-hole: A black hole for Internet advertisements."' in page_contents - -# IPv6 checks aren't passing CORS, removed :( @pytest.mark.parametrize('addr', [ 'localhost' ] ) @pytest.mark.parametrize('url', [ '/admin/', '/admin/index.php' ] ) -def test_admin_requests_load_as_expected(RunningPiHole, addr, url): +def test_admin_requests_load_as_expected(RunningPiHole, version, addr, url): command = 'curl -s -o /tmp/curled_file -w "%{{http_code}}" http://{}{}'.format(addr, url) http_rc = RunningPiHole.run(command) page_contents = RunningPiHole.run('cat /tmp/curled_file ').stdout @@ -88,6 +62,7 @@ def test_admin_requests_load_as_expected(RunningPiHole, addr, url): validate_curl(http_rc, expected_http_code, page_contents) assert http_rc.rc == 0 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', version]: assert html_text in page_contents