From d5a7cc652c1d9837be03b4b43671ef26b4775482 Mon Sep 17 00:00:00 2001 From: William Budington Date: Thu, 8 Feb 2018 20:12:43 -0800 Subject: [PATCH 1/7] Convert securecookie validation to py3.6 --- test/validations.sh | 2 +- test/validations/securecookie/run.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/validations.sh b/test/validations.sh index c13a127c5e9f..2b81ac30a3f8 100755 --- a/test/validations.sh +++ b/test/validations.sh @@ -4,7 +4,7 @@ utils/remove-obsolete-references.sh test/validations/path/run.sh test/validations/test-coverage/run.sh -python2.7 test/validations/securecookie/run.py +python3.6 test/validations/securecookie/run.py python2.7 test/validations/filename/run.py python2.7 test/validations/relaxng/run.py python2.7 test/validations/special/run.py --quiet diff --git a/test/validations/securecookie/run.py b/test/validations/securecookie/run.py index cad8361a3094..da315dd52428 100644 --- a/test/validations/securecookie/run.py +++ b/test/validations/securecookie/run.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3.6 # This python utility check for wildcard securecookies which -# can be normalized, warn and exit with non-zero when such -# rulesets exist. +# can be normalized, warn and exit with non-zero when such +# rulesets exist. # This is create in attempt to fix the issues on # https://github.com/EFForg/https-everywhere/pull/13840 @@ -16,10 +16,10 @@ def normalize_fn(fn): """ - OSX and Linux filesystems encode composite characters differently in + OSX and Linux filesystems encode composite characters differently in filenames. We should normalize to NFC: https://unicode.org/reports/tr15/ """ - fn = unicodedata.normalize("NFC", unicode(fn, "utf-8")).encode() + fn = unicodedata.normalize("NFC", fn) return fn def should_normalize_securecookie(host, name): @@ -50,8 +50,8 @@ def should_normalize_securecookie(host, name): name = branch.attrib["name"] if should_normalize_securecookie(host, name): - print ("ERROR %s: contains wildcard securecookies "\ - "which can be normalized." % filename) + print ("ERROR {}: contains wildcard securecookies "\ + "which can be normalized.".format(filename)) exit_with_non_zero = True break From 061c4e9a62f1af2dbd8a3a196107427b77e5a78a Mon Sep 17 00:00:00 2001 From: William Budington Date: Thu, 8 Feb 2018 20:17:38 -0800 Subject: [PATCH 2/7] Convert filename validation to py3.6 --- test/validations.sh | 2 +- test/validations/filename/run.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/validations.sh b/test/validations.sh index 2b81ac30a3f8..8d9bd285f6d8 100755 --- a/test/validations.sh +++ b/test/validations.sh @@ -5,6 +5,6 @@ utils/remove-obsolete-references.sh test/validations/path/run.sh test/validations/test-coverage/run.sh python3.6 test/validations/securecookie/run.py -python2.7 test/validations/filename/run.py +python3.6 test/validations/filename/run.py python2.7 test/validations/relaxng/run.py python2.7 test/validations/special/run.py --quiet diff --git a/test/validations/filename/run.py b/test/validations/filename/run.py index 0f288e3a126e..37c0bdaedd3c 100755 --- a/test/validations/filename/run.py +++ b/test/validations/filename/run.py @@ -1,5 +1,5 @@ -#!/usr/bin/env python2.7 -# +#!/usr/bin/env python3.6 +# # Validates and provides a generator for ruleset filenames # @@ -18,7 +18,7 @@ def validate_filenames(): most_common_entry = counted_lowercase_names.most_common(1)[0] if most_common_entry[1] > 1: dupe_filename = re.compile(re.escape(most_common_entry[0]), re.IGNORECASE) - print("%s failed case-insensitivity testing." % filter(dupe_filename.match, filenames)) + print("{} failed case-insensitivity testing.".format(list(filter(dupe_filename.match, filenames)))) print("Rules exist with identical case-insensitive names, which breaks some filesystems.") sys.exit(1) @@ -28,10 +28,10 @@ def validate_filenames(): continue if " " in fi: - print("%s failed validity: Rule filenames cannot contain spaces" % (fi)) + print("{} failed validity: Rule filenames cannot contain spaces".format(fi)) sys.exit(1) if not fi.endswith('.xml'): - print("%s failed validity: Rule filenames must end in .xml" % (fi)) + print("{} failed validity: Rule filenames must end in .xml".format(fi)) sys.exit(1) yield fi From 1224c42890b14336c853613e4af7d69b825764fe Mon Sep 17 00:00:00 2001 From: William Budington Date: Thu, 8 Feb 2018 20:21:32 -0800 Subject: [PATCH 3/7] Convert relaxng validation to py3.6 --- test/validations.sh | 2 +- test/validations/relaxng/run.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/validations.sh b/test/validations.sh index 8d9bd285f6d8..76ac1e95c381 100755 --- a/test/validations.sh +++ b/test/validations.sh @@ -6,5 +6,5 @@ test/validations/path/run.sh test/validations/test-coverage/run.sh python3.6 test/validations/securecookie/run.py python3.6 test/validations/filename/run.py -python2.7 test/validations/relaxng/run.py +python3.6 test/validations/relaxng/run.py python2.7 test/validations/special/run.py --quiet diff --git a/test/validations/relaxng/run.py b/test/validations/relaxng/run.py index 32503a58c22f..97e730934c35 100644 --- a/test/validations/relaxng/run.py +++ b/test/validations/relaxng/run.py @@ -1,10 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/env python3.6 # -*- encoding: utf-8 -*- import argparse import glob import os -import unicodedata from lxml import etree @@ -31,7 +30,7 @@ if not relaxng.validate(tree): exit_code = 1 e = relaxng.error_log.last_error - print(("%s %s:%s:%s: %s" % (e.level_name, e.filename, e.line, e.column, e.message))) + print("{} {}:{}:{}: {}".format(e.level_name, e.filename, e.line, e.column, e.message)) if exit_code == 0: message = "Validation of rulesets against relaxng schema.xml succeeded." From 14124227df17c7dfaa3aca04b258b14dd63ef696 Mon Sep 17 00:00:00 2001 From: William Budington Date: Thu, 8 Feb 2018 21:53:58 -0800 Subject: [PATCH 4/7] Convert special validation to py3.6 --- test/validations.sh | 2 +- test/validations/special/run.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/validations.sh b/test/validations.sh index 76ac1e95c381..50d328a6155c 100755 --- a/test/validations.sh +++ b/test/validations.sh @@ -7,4 +7,4 @@ test/validations/test-coverage/run.sh python3.6 test/validations/securecookie/run.py python3.6 test/validations/filename/run.py python3.6 test/validations/relaxng/run.py -python2.7 test/validations/special/run.py --quiet +python3.6 test/validations/special/run.py --quiet diff --git a/test/validations/special/run.py b/test/validations/special/run.py index b9733b42a13d..737fea1001ba 100755 --- a/test/validations/special/run.py +++ b/test/validations/special/run.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python3.6 import glob import argparse @@ -163,7 +163,7 @@ def nomes_all(where=sys.argv[1:]): try: tree = etree.parse(filename, xml_parser) except Exception as oops: - print("%s failed XML validity: %s\n" % (filename, oops)) + print("{} failed XML validity: {}\n".format(filename, oops)) sys.exit(1) if not xpath_ruleset(tree): From 7da6db04c7c5ff25aa260806411cb3d4dc267a86 Mon Sep 17 00:00:00 2001 From: William Budington Date: Tue, 13 Feb 2018 14:05:02 -0800 Subject: [PATCH 5/7] Convert test/script.py to py3.6 --- test/chromium.sh | 4 ++-- test/firefox.sh | 4 ++-- test/script.py | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/chromium.sh b/test/chromium.sh index 7724dcbc865a..efc134dba48d 100755 --- a/test/chromium.sh +++ b/test/chromium.sh @@ -25,7 +25,7 @@ if [ "$1" == "--justrun" ]; then PROFILE_DIRECTORY="$(mktemp -d)" trap 'rm -r "$PROFILE_DIRECTORY"' EXIT - + # Chromium package name is 'chromium' in Debian 7 (wheezy) and other distros like Arch BROWSER="chromium-browser" which $BROWSER || BROWSER="chromium" @@ -37,5 +37,5 @@ else ./make.sh echo "running tests" CRX_NAME="`ls -tr pkg/*.crx | tail -1`" - $XVFB_RUN python2.7 test/script.py Chrome $CRX_NAME + $XVFB_RUN python3.6 test/script.py Chrome $CRX_NAME fi diff --git a/test/firefox.sh b/test/firefox.sh index de60bfb4b376..56ec5720ef59 100755 --- a/test/firefox.sh +++ b/test/firefox.sh @@ -58,8 +58,8 @@ else PATH=/home/user/geckodriver:$PATH if [ -n "$FIREFOX" ]; then - $XVFB_RUN python2.7 test/script.py Firefox "$PROFILE_DIRECTORY" $FIREFOX + $XVFB_RUN python3.6 test/script.py Firefox "$PROFILE_DIRECTORY" $FIREFOX else - $XVFB_RUN python2.7 test/script.py Firefox "$PROFILE_DIRECTORY" + $XVFB_RUN python3.6 test/script.py Firefox "$PROFILE_DIRECTORY" fi fi diff --git a/test/script.py b/test/script.py index ec53abd71554..219e3c7945ae 100644 --- a/test/script.py +++ b/test/script.py @@ -49,8 +49,8 @@ class bcolors: error = e.__str__() if "executable needs to be in PATH" in e.__str__(): - print "ChromeDriver isn't installed. Check test/chromium/README.md " \ - "for instructions on how to install ChromeDriver" + print("ChromeDriver isn't installed. Check test/chromium/README.md " \ + "for instructions on how to install ChromeDriver") sys.exit(2) else: @@ -68,8 +68,8 @@ class bcolors: error = e.__str__() if "executable needs to be in PATH" in e.__str__(): - print "GeckoDriver isn't installed. Check test/firefox/README.md " \ - "for instructions on how to install GeckoDriver" + print("GeckoDriver isn't installed. Check test/firefox/README.md " \ + "for instructions on how to install GeckoDriver") sys.exit(2) else: @@ -78,18 +78,18 @@ class bcolors: # Allow the extension time to load time.sleep(1) -print '' +print('') driver.get('http://freerangekitten.com') test_failed = False if driver.current_url.startswith('https'): - print bcolors.OKGREEN + sys.argv[1] + ": HTTP to HTTPS redirection successful" + bcolors.ENDC + print(bcolors.OKGREEN + sys.argv[1] + ": HTTP to HTTPS redirection successful" + bcolors.ENDC) elif driver.current_url.startswith('http'): - print bcolors.FAIL + sys.argv[1] + ": HTTP to HTTPS redirection failed" + bcolors.ENDC + print(bcolors.FAIL + sys.argv[1] + ": HTTP to HTTPS redirection failed" + bcolors.ENDC) test_failed = True -print '' +print('') driver.quit() From 257cf2ca9683eb2aedd0d03e0283642aef5a54fe Mon Sep 17 00:00:00 2001 From: William Budington Date: Thu, 15 Feb 2018 22:04:48 -0800 Subject: [PATCH 6/7] Install pip modules for 3.6 as well --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6ffee8e42419..eaf31bb4a93d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,6 @@ MAINTAINER William Budington "bill@eff.org" WORKDIR /opt COPY test/rules/requirements.txt /tmp/ -RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt +RUN pip3 install -r /tmp/requirements.txt +RUN rm /tmp/requirements.txt From a7b7ebcd38c61c7c83c48b21fbda67005ee36e2b Mon Sep 17 00:00:00 2001 From: William Budington Date: Thu, 15 Feb 2018 22:58:32 -0800 Subject: [PATCH 7/7] Delay popup for longer after initial page display --- test/selenium/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/selenium/util.py b/test/selenium/util.py index ba5cd448fb8c..35c1618f1289 100644 --- a/test/selenium/util.py +++ b/test/selenium/util.py @@ -81,7 +81,7 @@ def load_popup_for(self, url='about:blank'): chrome.tabs.create({url: '%s'}, function(tab) { setTimeout( () => chrome.tabs.create({url: '%s' + '?tabId=' + String(tab.id)}, done), - 250 + 500 ); }); })(arguments[0]);