From 70e876ee1335bd8d9147bb7137d32df0b2ec7a67 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 20 Feb 2017 09:36:24 -0800 Subject: [PATCH] Download tests. Make sure we download a binary and not just get the GitHub page. Signed-off-by: Dan Schaper --- automated install/basic-install.sh | 22 ++++++++++++---------- test/test_automated_install.py | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 98322cb7..7499336b 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1164,17 +1164,19 @@ FTLinstall() { echo "::: failed (error in getting latest release location from GitHub)" return 1 fi - if curl -sSL --fail "${latestURL}${binary}" -o "/tmp/pihole-FTL"; then - echo "::: done" - install -m 0755 /tmp/pihole-FTL /usr/bin - touch /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port - chmod 0666 /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port - return 0 - else - echo "::: failed (download of binary from Github failed)" - return 1 + if curl -sSL --fail "${latestURL%$'\r'}/${binary}" -o "/tmp/pihole-FTL"; then + if [[ -f /tmp/pihole-FTL ]]; then + echo "::: done" + install -m 0755 /tmp/pihole-FTL /usr/bin + touch /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port + chmod 0666 /var/log/pihole-FTL.log /var/run/pihole-FTL.pid /var/run/pihole-FTL.port + return 0 + else + echo "::: failed (download of binary from Github failed)" + return 1 + fi + echo "done" fi - echo "done" } FTLdetect() { diff --git a/test/test_automated_install.py b/test/test_automated_install.py index b0dded5c..40e0000b 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -355,6 +355,29 @@ def test_FTL_detect_unknown_no_errors(Pihole): ''') expected_stdout = 'Not able to detect architecture (unknown: mips)' assert expected_stdout in detectPlatform.stdout + +def test_FTL_download_aarch64_no_errors(Pihole): + ''' confirms only aarch64 package is downloaded for FTL engine ''' + # mock uname to return generic platform + download_binary = Pihole.run(''' + source /opt/pihole/basic-install.sh + FTLinstall pihole-FTL-aarch64-linux-gnu + ''') + expected_stdout = 'done' + assert expected_stdout in download_binary.stdout + assert 'failed' not in download_binary.stdout + +def test_FTL_download_unknown_fails_no_errors(Pihole): + ''' confirms unknown binary is not downloaded for FTL engine ''' + # mock uname to return generic platform + download_binary = Pihole.run(''' + source /opt/pihole/basic-install.sh + FTLinstall pihole-FTL-mips + ''') + expected_stdout = 'failed' + assert expected_stdout in download_binary.stdout + assert 'done' not in download_binary.stdout + # Helper functions def mock_command(script, args, container): ''' Allows for setup of commands we don't really want to have to run for real in unit tests '''