chiark / gitweb /
index: ensure index.xml timestamp is in UTC, closes #481
[fdroidserver.git] / tests / run-tests
index af29f471eeb186a5480815658759b206b16afc5a..9ab5a9b6f714b3cf9a545a0c1d94c08f11df8f12 100755 (executable)
@@ -41,6 +41,17 @@ create_test_file() {
     TMPDIR=$WORKSPACE/.testfiles  mktemp
 }
 
+fdroid_init_with_prebuilt_keystore() {
+    if [ -z "$1" ]; then
+        keystore=$WORKSPACE/tests/keystore.jks
+    else
+        keystore="$1"
+    fi
+    $fdroid init --keystore $keystore --repo-keyalias=sova
+    echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+    echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+}
+
 # the < is reverse since 0 means success in exit codes
 have_git_2_3() {
     python3 -c "import sys; from distutils.version import LooseVersion as V; sys.exit(V(sys.argv[3]) < V('2.3'))" `git --version`
@@ -91,11 +102,6 @@ if [ -z $aapt ]; then
     aapt=`ls -1 $ANDROID_HOME/build-tools/*/aapt | sort | tail -1`
 fi
 
-# allow the location of python to be overridden
-if [ -z $python ]; then
-    python=python3
-fi
-
 # try to use GNU sed on OSX/BSD cuz BSD sed sucks
 if which gsed; then
     sed=gsed
@@ -119,7 +125,11 @@ cd $WORKSPACE/tests/getsig
 ./make.sh
 
 cd $WORKSPACE/tests
-for testcase in $WORKSPACE/tests/*.TestCase; do
+for testcase in $WORKSPACE/tests/i*.TestCase; do
+    if [ $testcase == $WORKSPACE/tests/install.TestCase ]; then
+        echo "skipping install.TestCase, its too troublesome in CI builds"
+        continue
+    fi
     $testcase
 done
 
@@ -165,7 +175,7 @@ echo_header "test UTF-8 metadata"
 REPOROOT=`create_test_dir`
 cd $REPOROOT
 
-$fdroid init
+fdroid_init_with_prebuilt_keystore
 $sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py
 echo "mirrors = ('https://foo.bar/fdroid', 'http://secret.onion/fdroid')" >> config.py
 mkdir metadata
@@ -219,11 +229,8 @@ echo_header "copy tests/repo, generate java/gpg keys, update, and gpgsign"
 
 REPOROOT=`create_test_dir`
 GNUPGHOME=$REPOROOT/gnupghome
-KEYSTORE=$WORKSPACE/tests/keystore.jks
 cd $REPOROOT
-$fdroid init --keystore $KEYSTORE --repo-keyalias=sova
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+fdroid_init_with_prebuilt_keystore
 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
 cp -a $WORKSPACE/tests/gnupghome $GNUPGHOME
 chmod 0700 $GNUPGHOME
@@ -251,6 +258,10 @@ if [ "$TRAVIS_OS_NAME" != "osx" ]; then
     ! test -e repo/index.xml.asc
 fi
 
+v0timestamp=`$sed -n -e 's,.*timestamp="\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)".*,\1,p' repo/index.xml`
+v1timestamp=`$sed -n -e 's,.*"timestamp": \([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*,\1,p' repo/index-v1.json`
+test $v0timestamp -eq $v1timestamp
+
 # we can't easily reproduce the timestamps for things, so just hardcode them
 $sed -i.tmp -e 's,timestamp="[0-9]*",timestamp="1480431575",' repo/index.xml
 diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml
@@ -263,10 +274,7 @@ echo_header 'test moving lots of APKs to the archive'
 
 REPOROOT=`create_test_dir`
 cd $REPOROOT
-cp $WORKSPACE/tests/keystore.jks $REPOROOT/
-$fdroid init --keystore keystore.jks --repo-keyalias=sova
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+fdroid_init_with_prebuilt_keystore
 echo "accepted_formats = ['txt']" >> config.py
 $sed -i.tmp '/allow_disabled_algorithms/d' config.py
 test -d metadata || mkdir metadata
@@ -293,10 +301,7 @@ echo_header 'test per-app "Archive Policy"'
 
 REPOROOT=`create_test_dir`
 cd $REPOROOT
-cp $WORKSPACE/tests/keystore.jks $REPOROOT/
-$fdroid init --keystore keystore.jks --repo-keyalias=sova
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+fdroid_init_with_prebuilt_keystore
 echo "accepted_formats = ['txt']" >> config.py
 test -d metadata || mkdir metadata
 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
@@ -367,10 +372,7 @@ echo_header 'test moving old APKs to and from the archive'
 
 REPOROOT=`create_test_dir`
 cd $REPOROOT
-cp $WORKSPACE/tests/keystore.jks $REPOROOT/
-$fdroid init --keystore keystore.jks --repo-keyalias=sova
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+fdroid_init_with_prebuilt_keystore
 echo "accepted_formats = ['txt']" >> config.py
 test -d metadata || mkdir metadata
 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
@@ -436,10 +438,7 @@ echo_header 'test allowing disabled signatures in repo and archive'
 
 REPOROOT=`create_test_dir`
 cd $REPOROOT
-cp $WORKSPACE/tests/keystore.jks $REPOROOT/
-$fdroid init --keystore keystore.jks --repo-keyalias=sova
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+fdroid_init_with_prebuilt_keystore
 echo "accepted_formats = ['txt']" >> config.py
 echo 'allow_disabled_algorithms = True' >> config.py
 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
@@ -507,10 +506,7 @@ echo_header 'rename apks with `fdroid update --rename-apks`, --nosign for speed'
 
 REPOROOT=`create_test_dir`
 cd $REPOROOT
-cp $WORKSPACE/tests/keystore.jks $REPOROOT/
-$fdroid init --keystore keystore.jks --repo-keyalias=sova
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+fdroid_init_with_prebuilt_keystore
 echo "accepted_formats = ['txt', 'yml']" >> config.py
 echo 'keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US"' >> config.py
 test -d metadata || mkdir metadata
@@ -595,7 +591,7 @@ LOCAL_COPY_DIR=`create_test_dir`/fdroid
 mkdir -p $LOCAL_COPY_DIR/repo
 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
 
-$fdroid checkupdates
+$fdroid checkupdates --allow-dirty
 $fdroid gpgsign
 $fdroid lint
 $fdroid readmeta
@@ -610,10 +606,10 @@ $fdroid install || true
 
 
 #------------------------------------------------------------------------------#
-echo_header "create a source tarball and use that to build a repo"
+echo_header "create a source tarball"
 
 cd $WORKSPACE
-$python setup.py sdist
+./setup.py compile_catalog sdist
 
 REPOROOT=`create_test_dir`
 cd $REPOROOT
@@ -665,7 +661,7 @@ echo_header "setup a new repo from scratch using ANDROID_HOME and do a local syn
 
 REPOROOT=`create_test_dir`
 cd $REPOROOT
-$fdroid init
+fdroid_init_with_prebuilt_keystore
 copy_apks_into_repo $REPOROOT
 $fdroid update --create-metadata --verbose
 $fdroid readmeta
@@ -675,7 +671,7 @@ LOCALCOPYDIR=`create_test_dir`/fdroid
 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
 NEWREPOROOT=`create_test_dir`
 cd $NEWREPOROOT
-$fdroid init
+fdroid_init_with_prebuilt_keystore
 echo "sync_from_local_copy_dir = True" >> config.py
 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
 
@@ -787,11 +783,8 @@ export ANDROID_HOME=$STORED_ANDROID_HOME
 echo_header "check duplicate files are properly handled by fdroid update"
 
 REPOROOT=`create_test_dir`
-KEYSTORE=$WORKSPACE/tests/keystore.jks
 cd $REPOROOT
-$fdroid init --keystore $KEYSTORE --repo-keyalias=sova
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
+fdroid_init_with_prebuilt_keystore
 mkdir $REPOROOT/metadata
 cp -a $WORKSPACE/tests/metadata/obb.mainpatch.current.txt $REPOROOT/metadata
 echo "accepted_formats = ['txt']" >> config.py
@@ -813,7 +806,7 @@ REPOROOT=`create_test_dir`
 cd $REPOROOT
 mkdir repo
 copy_apks_into_repo $REPOROOT
-$fdroid init
+fdroid_init_with_prebuilt_keystore
 $fdroid update --create-metadata --verbose
 $fdroid readmeta
 grep -F '<application id=' repo/index.xml > /dev/null
@@ -946,12 +939,9 @@ echo_header "copy tests/repo, update with binary transparency log"
 REPOROOT=`create_test_dir`
 GIT_REMOTE=`create_test_dir`
 GNUPGHOME=$REPOROOT/gnupghome
-KEYSTORE=$WORKSPACE/tests/keystore.jks
 cd $REPOROOT
-$fdroid init --keystore $KEYSTORE --repo-keyalias=sova
+fdroid_init_with_prebuilt_keystore
 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
 echo "binary_transparency_remote = '$GIT_REMOTE'" >> config.py
 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
 $fdroid update --verbose
@@ -976,7 +966,8 @@ echo_header "setup a new repo with keystore with APK, update, then without key"
 REPOROOT=`create_test_dir`
 KEYSTORE=$REPOROOT/keystore.jks
 cd $REPOROOT
-$fdroid init --keystore $KEYSTORE
+cp $WORKSPACE/tests/keystore.jks $KEYSTORE
+fdroid_init_with_prebuilt_keystore $KEYSTORE
 test -e $KEYSTORE
 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
 $fdroid update --create-metadata --verbose
@@ -1047,11 +1038,9 @@ if have_git_2_3; then
 fi
 
 cd $OFFLINE_ROOT
-$fdroid init --keystore $KEYSTORE --repo-keyalias=sova
+fdroid_init_with_prebuilt_keystore
 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $OFFLINE_ROOT/
 
-echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
-echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
 echo "mirrors = ['http://foo.bar/fdroid', 'http://asdflkdsfjafdsdfhkjh.onion/fdroid']" >> config.py
 echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py