Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
language: python
python:
- "2.7"
cache: pip
cache:
directories:
- $HOME/.cache/pip
addons:
apt:
packages:
Expand Down
2 changes: 1 addition & 1 deletion install-dev-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pip install --user --no-allow-insecure --no-allow-external -r requirements.txt
cd https-everywhere-checker
pip install --user -r requirements.txt
cd -
cd test/chrome
cd test/chromium
pip install --user -r requirements.txt
cd -

Expand Down
12 changes: 9 additions & 3 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@

# Get into the project-root. This script may be executed as `test.sh`
# or as .git/hooks/pre-push, so we need to find the directory containing
# test.sh before we can proceed. If $0 is not a symlink, `readlink` will
# print nothing; if it is a symlink it will print the link target.
# test.sh before we can proceed.

cd $(dirname $0)/$(dirname $(readlink $0))
if [ -n "$GIT_DIR" ]
then
# $GIT_DIR is set, so we're running as a hook.
cd $GIT_DIR
else
# Git command exists? Cool, let's CD to the right place.
git rev-parse && cd "$(git rev-parse --show-toplevel)"
fi

./test/rules.sh
./test/firefox.sh $@
Expand Down
19 changes: 10 additions & 9 deletions test/chromium.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#!/bin/bash
#!/bin/bash -ex
# Run Chromium tests for HTTPS Everywhere
#
# Get into the project-root. This script may be executed as `chromium.sh`
# or as ./test/chromium.sh, so we need to find the directory
# containing firefox.sh before we can proceed. If $0 is not a symlink,
# `readlink` will print nothing; if it is a symlink it will print the
# link target.

set -o errexit -o xtrace
# Get to the repo root directory, even when we're symlinked as a hook.
if [ -n "$GIT_DIR" ]
then
# $GIT_DIR is set, so we're running as a hook.
cd $GIT_DIR
else
# Git command exists? Cool, let's CD to the right place.
git rev-parse && cd "$(git rev-parse --show-toplevel)"
fi

cd $(dirname $0)/$(dirname $(readlink $0))../

# If you just want to run Chromium with the latest code:
if [ "$1" == "--justrun" ]; then
Expand Down
67 changes: 38 additions & 29 deletions test/chromium/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,61 @@
from selenium.common.exceptions import WebDriverException

class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'


chromeOps = webdriver.ChromeOptions()
chromeOps.add_extension(sys.argv[1])
chromeOps.add_argument("--disable-setuid-sandbox")

chromdriver_path = "chromedriver"
if 'TRAVIS' in os.environ.keys():
# For TravisCI, we manually copy chromedriver to the local path.
chromedriver_path = os.path.abspath("test/chromium/chromedriver")

if 'TRAVIS' in os.environ:
chromeOps.add_argument('--no-sandbox')
chromdriver_path = os.path.abspath("test/chromium/chromedriver")
# Travis has setuid restrictions. I think this becomes unnecessary in M42+?
chromeOps.add_argument('--disable-setuid-sandbox')
elif sys.platform.startswith("linux"):
chromedriver_path = "/usr/lib/chromium-browser/chromedriver"
else:
# Let's hope it's in the user's path.
chromedriver_path = "chromedriver"

# First argument is optional, if not specified will search path.

try:
driver = webdriver.Chrome(chromdriver_path, chrome_options=chromeOps)
# First argument is optional, if not specified will search path.
driver = webdriver.Chrome(chromedriver_path, chrome_options=chromeOps)
except WebDriverException as e:
error = e.__str__()
error = e.__str__()

if "executable needs to be in PATH" in e.__str__():
print "ChromeDriver isn't installed. Check test/chrome/README.md\
for instructions on how to install ChromeDriver"
if "executable needs to be in PATH" in e.__str__():
print "ChromeDriver isn't installed. Check test/chrome/README.md " \
"for instructions on how to install ChromeDriver"

sys.exit(2)
else:
raise e
sys.exit(2)
else:
raise e

print '' #New line
print ''

driver.get('http://libssh.org/robots.txt')

#Page Loaded

test_failed = False
if driver.current_url.startswith('https'):
print bcolors.OKGREEN + "HTTP to HTTPS redirection successful" + bcolors.ENDC
print bcolors.OKGREEN + "Chromium: HTTP to HTTPS redirection successful" + bcolors.ENDC
elif driver.current_url.startswith('http'):
print bcolors.FAIL + "HTTP to HTTPS redirection failed" + bcolors.ENDC
sys.exit(1)
print bcolors.FAIL + "Chromium: HTTP to HTTPS redirection failed" + bcolors.ENDC
test_failed = True

print '' #New line
print ''

driver.quit()


if test_failed:
sys.exit(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is unreachable. You probably need to remove sys.exit(1) at line 68.

16 changes: 10 additions & 6 deletions test/firefox.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/bash -ex
# Run Firefox tests for HTTPS Everywhere
#
# Get into the project-root. This script may be executed as `firefox.sh`
# or as ./test/firefox.sh, so we need to find the directory containing
# firefox.sh before we can proceed. If $0 is not a symlink, `readlink`
# will print nothing; if it is a symlink it will print the link target.

cd $(dirname $0)/$(dirname $(readlink $0))../
# Get to the repo root directory, even when we're symlinked as a hook.
if [ -n "$GIT_DIR" ]
then
# $GIT_DIR is set, so we're running as a hook.
cd $GIT_DIR
else
# Git command exists? Cool, let's CD to the right place.
git rev-parse && cd "$(git rev-parse --show-toplevel)"
fi


source utils/mktemp.sh

Expand Down
12 changes: 10 additions & 2 deletions test/rules.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash
#!/bin/bash -ex
#
# Test that all rulesets modified after a certain date have sufficient test
# coverage, according to the ruleset checker.
#

cd $(dirname $0)/$(dirname $(readlink $0))../
# Get to the repo root directory, even when we're symlinked as a hook.
if [ -n "$GIT_DIR" ]
then
# $GIT_DIR is set, so we're running as a hook.
cd $GIT_DIR
else
# Git command exists? Cool, let's CD to the right place.
git rev-parse && cd "$(git rev-parse --show-toplevel)"
fi

source utils/mktemp.sh

Expand Down