chiark / gitweb /
tests: support running on platforms with old java
authorHans-Christoph Steiner <hans@eds.org>
Wed, 13 Sep 2017 14:00:51 +0000 (16:00 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Fri, 15 Sep 2017 09:37:24 +0000 (11:37 +0200)
In order to test on travis-ci's OSX setup, its easiest to support the old
version of Java that is installed there by default.  It is pretty old, so
it does not include the April 2017 update that disables MD5:

https://blogs.oracle.com/java-platform-group/oracle-jre-will-no-longer-trust-md5-signed-code-by-default
https://www.bleepingcomputer.com/news/security/oracle-to-block-jar-files-signed-with-md5-starting-with-april-2017
https://support.ca.com/us/knowledge-base-articles.TEC1691042.html

#292 #323

tests/update.TestCase

index 5d292f4b7e0dce25cf904193656af4282eb8c170..76a938027b6ab72c481c9629022ec14ace37fa0e 100755 (executable)
@@ -8,11 +8,13 @@ import logging
 import optparse
 import os
 import shutil
+import subprocess
 import sys
 import tempfile
 import unittest
 import yaml
 from binascii import unhexlify
+from distutils.version import LooseVersion
 
 localmodule = os.path.realpath(
     os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
@@ -397,8 +399,15 @@ class UpdateTest(unittest.TestCase):
             self.assertFalse(os.path.exists(os.path.join('archive', apkName)))
             self.assertTrue(os.path.exists(os.path.join('repo', apkName)))
 
+            javac = config['jarsigner'].replace('jarsigner', 'javac')
+            v = subprocess.check_output([javac, '-version'], stderr=subprocess.STDOUT)[6:-1].decode('utf-8')
+            if LooseVersion(v) < LooseVersion('1.8.0_132'):
+                print('SKIPPING: running tests with old Java (' + v + ')')
+                return
+
             # this test only works on systems with fully updated Java/jarsigner
             # that has MD5 listed in jdk.jar.disabledAlgorithms in java.security
+            # https://blogs.oracle.com/java-platform-group/oracle-jre-will-no-longer-trust-md5-signed-code-by-default
             skip, apk, cachechanged = fdroidserver.update.process_apk({}, apkName, 'repo',
                                                                       knownapks,
                                                                       allow_disabled_algorithms=False,