chiark / gitweb /
Merge branch 'morebintrans' into 'master'
[fdroidserver.git] / tests / run-tests
1 #!/bin/bash
2
3 set -e # quit script on error
4
5 echo_header() {
6     { echo -e "==============================================================================\n$1"; } 2>/dev/null
7 }
8
9 copy_apks_into_repo() {
10     set +x
11     for f in `find $APKDIR -name '*.apk' | grep -F -v -e unaligned -e unsigned -e badsig -e badcert`; do
12         name=$(basename $(dirname `dirname $f`))
13         apk=`$aapt dump badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"`
14         test $f -nt repo/$apk && rm -f repo/$apk  # delete existing if $f is newer
15         if [ ! -e repo/$apk ] && [ ! -e archive/$apk ]; then
16             echo "$f --> repo/$apk"
17             ln $f $1/repo/$apk || \
18                 rsync -axv $f $1/repo/$apk # rsync if hard link is not possible
19         fi
20     done
21     set -x
22 }
23
24 # keep this as an old version to test the automatic parsing of build-tools
25 # verion numbers in `fdroid init`
26 create_fake_android_home() {
27     mkdir $1/tools
28     mkdir $1/platform-tools
29     mkdir $1/build-tools
30     mkdir $1/build-tools/19.0.2
31     touch $1/build-tools/19.0.2/aapt
32 }
33
34 create_test_dir() {
35     test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
36     mktemp -d $WORKSPACE/.testfiles/run-tests.XXXX
37 }
38
39 create_test_file() {
40     test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
41     TMPDIR=$WORKSPACE/.testfiles  mktemp
42 }
43
44 #------------------------------------------------------------------------------#
45 # "main"
46
47 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
48     set +x
49     echo "Usage: $0 '/path/to/folder/with/apks'"
50     exit 1
51 fi
52
53 if [ -z "$ANDROID_HOME" ]; then
54     echo "ANDROID_HOME must be set with the path to the Android SDK, i.e.: "
55     echo "  export ANDROID_HOME=/opt/android-sdk"
56     exit 1
57 fi
58
59 if [ -d tests ]; then
60     cd tests
61 fi
62
63 if [ -z "$1" ]; then
64     APKDIR=`pwd`
65 else
66     APKDIR=$1
67 fi
68
69 if [ -z $WORKSPACE ]; then
70     WORKSPACE=`dirname $(pwd)`
71     echo "Setting Workspace to $WORKSPACE"
72 fi
73
74 # allow the location of the script to be overridden
75 if [ -z $fdroid ]; then
76     fdroid="$WORKSPACE/fdroid"
77 fi
78
79 # allow the location of aapt to be overridden
80 if [ -z $aapt ]; then
81     aapt=`ls -1 $ANDROID_HOME/build-tools/*/aapt | sort | tail -1`
82 fi
83
84 # allow the location of python to be overridden
85 if [ -z $python ]; then
86     python=python3
87 fi
88
89 set -x # show each command as it is executed
90
91 #------------------------------------------------------------------------------#
92 echo_header "run commit hooks"
93
94 cd $WORKSPACE
95 ./hooks/pre-commit
96
97
98 #------------------------------------------------------------------------------#
99 echo_header "test python getsig replacement"
100
101 cd $WORKSPACE/tests/getsig
102 ./make.sh
103
104 cd $WORKSPACE/tests
105 for testcase in $WORKSPACE/tests/*.TestCase; do
106     $testcase
107 done
108
109
110 #------------------------------------------------------------------------------#
111 echo_header "print fdroid version"
112
113 $fdroid --version
114
115
116 #------------------------------------------------------------------------------#
117 echo_header 'run process when building and signing are on separate machines'
118
119 REPOROOT=`create_test_dir`
120 cd $REPOROOT
121 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
122 $fdroid init --keystore keystore.jks --repo-keyalias=sova
123 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
124 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
125 echo "accepted_formats = ['txt', 'yml']" >> config.py
126 echo 'keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US"' >> config.py
127 test -d archive || mkdir archive
128 test -d metadata || mkdir metadata
129 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
130 test -d repo || mkdir repo
131 test -d unsigned || mkdir unsigned
132 cp $WORKSPACE/tests/urzip-release-unsigned.apk unsigned/info.guardianproject.urzip_100.apk
133 $fdroid publish --verbose
134 $fdroid update --verbose --nosign
135 $fdroid signindex --verbose
136 test -e repo/index.xml
137 test -e repo/index.jar
138 test -e repo/index-v1.jar
139 test -L urzip.apk
140 grep -F '<application id=' repo/index.xml > /dev/null
141
142
143 #------------------------------------------------------------------------------#
144 echo_header "test UTF-8 metadata"
145
146 REPOROOT=`create_test_dir`
147 cd $REPOROOT
148
149 $fdroid init
150 sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py
151 echo "mirrors = ('https://foo.bar/fdroid', 'http://secret.onion/fdroid')" >> config.py
152 mkdir metadata
153 cp $WORKSPACE/tests/urzip.apk repo/
154 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
155
156 $fdroid readmeta
157 $fdroid update
158
159
160 #------------------------------------------------------------------------------#
161 echo_header 'run `fdroid build` in fresh git checkout from import.TestCase'
162
163 cd $WORKSPACE/tests/tmp/importer
164 git remote update -p
165 git clean -fdx
166 # stick with known working commit, in case future commits break things for this code
167 git reset --hard cecf00c08aec56ae7a5eba444150c4d1ae868814
168 if [ -d $ANDROID_HOME/platforms/android-23 ]; then
169     echo "build_tools = '`ls -1 $ANDROID_HOME/build-tools/ | sort -n | tail -1`'" > config.py
170     echo "force_build_tools = True" >> config.py
171     $fdroid build --verbose org.fdroid.ci.test.app:300
172 else
173     echo 'WARNING: Skipping `fdroid build` test since android-23 is missing!'
174 fi
175
176
177 #------------------------------------------------------------------------------#
178 echo_header "copy tests/repo, generate java/gpg keys, update, and gpgsign"
179
180 REPOROOT=`create_test_dir`
181 GNUPGHOME=$REPOROOT/gnupghome
182 KEYSTORE=$WORKSPACE/tests/keystore.jks
183 cd $REPOROOT
184 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
185 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
186 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
187 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
188 cp -a $WORKSPACE/tests/gnupghome $GNUPGHOME
189 chmod 0700 $GNUPGHOME
190 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
191 echo "install_list = 'org.adaway'" >> config.py
192 echo "uninstall_list = ('com.android.vending', 'com.facebook.orca',)" >> config.py
193 echo "gpghome = '$GNUPGHOME'" >> config.py
194 echo "gpgkey = 'CE71F7FB'" >> config.py
195 echo "mirrors = ('http://foobarfoobarfoobar.onion/fdroid','https://foo.bar/fdroid',)" >> config.py
196 $fdroid update --verbose --pretty
197 test -e repo/index.xml
198 test -e repo/index.jar
199 test -e repo/index-v1.jar
200 grep -F '<application id=' repo/index.xml > /dev/null
201 grep -F '<install packageName=' repo/index.xml > /dev/null
202 grep -F '<uninstall packageName=' repo/index.xml > /dev/null
203 $fdroid gpgsign --verbose
204 $fdroid gpgsign --verbose
205 test -e repo/obb.mainpatch.current_1619.apk.asc
206 test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc
207 ! test -e repo/obb.mainpatch.current_1619.apk.asc.asc
208 ! test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc.asc
209 ! test -e repo/index.xml.asc
210
211 # we can't easily reproduce the timestamps for things, so just hardcode them
212 sed -i --expression='s,timestamp="[0-9]*",timestamp="1480431575",' repo/index.xml
213 diff $WORKSPACE/tests/repo/index.xml repo/index.xml
214
215 #------------------------------------------------------------------------------#
216 echo_header "test metadata checks"
217
218 REPOROOT=`create_test_dir`
219 cd $REPOROOT
220
221 touch config.py
222 mkdir repo
223 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
224
225 set +e
226 $fdroid build
227 if [ $? -eq 0 ]; then
228     echo "This should have failed because there is no metadata!"
229     exit 1
230 else
231     echo "testing metadata checks passed"
232 fi
233 set -e
234
235 mkdir $REPOROOT/metadata/
236 cp $WORKSPACE/tests/metadata/org.smssecure.smssecure.txt $REPOROOT/metadata/
237 $fdroid readmeta
238
239 # now make a fake duplicate
240 touch $REPOROOT/metadata/org.smssecure.smssecure.yml
241
242 set +e
243 $fdroid readmeta
244 if [ $? -eq 0 ]; then
245     echo "This should have failed because there is a duplicate metadata file!"
246     exit 1
247 else
248     echo "testing duplicate metadata checks passed"
249 fi
250 set -e
251
252
253 #------------------------------------------------------------------------------#
254 echo_header "ensure commands that don't need the JDK work without a JDK configed"
255
256 REPOROOT=`create_test_dir`
257 cd $REPOROOT
258 mkdir repo
259 mkdir metadata
260 echo "License:GPL" >> metadata/fake.txt
261 echo "Summary:Yup still fake" >> metadata/fake.txt
262 echo "Categories:Internet" >> metadata/fake.txt
263 echo "Description:" >> metadata/fake.txt
264 echo "this is fake" >> metadata/fake.txt
265 echo "." >> metadata/fake.txt
266
267 # fake that no JDKs are available
268 echo 'java_paths = {}' > config.py
269
270 LOCAL_COPY_DIR=`create_test_dir`/fdroid
271 mkdir -p $LOCAL_COPY_DIR/repo
272 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
273
274 $fdroid checkupdates
275 $fdroid gpgsign
276 $fdroid lint
277 $fdroid readmeta
278 $fdroid rewritemeta fake
279 $fdroid server update
280 $fdroid scanner
281
282 # run these to get their output, but the are not setup, so don't fail
283 $fdroid build || true
284 $fdroid import || true
285 $fdroid install || true
286
287
288 #------------------------------------------------------------------------------#
289 echo_header "create a source tarball and use that to build a repo"
290
291 cd $WORKSPACE
292 $python setup.py sdist
293
294 REPOROOT=`create_test_dir`
295 cd $REPOROOT
296 tar xzf `ls -1 $WORKSPACE/dist/fdroidserver-*.tar.gz | sort -n | tail -1`
297 cd $REPOROOT
298 ./fdroidserver-*/fdroid init
299 copy_apks_into_repo $REPOROOT
300 ./fdroidserver-*/fdroid update --create-metadata --verbose
301
302
303 #------------------------------------------------------------------------------#
304 echo_header "test config checks of local_copy_dir"
305
306 REPOROOT=`create_test_dir`
307 cd $REPOROOT
308 $fdroid init
309 $fdroid update --create-metadata --verbose
310 $fdroid readmeta
311 $fdroid server update --local-copy-dir=/tmp/fdroid
312
313 # now test the errors work
314 set +e
315 $fdroid server update --local-copy-dir=thisisnotanabsolutepath
316 if [ $? -eq 0 ]; then
317     echo "This should have failed because thisisnotanabsolutepath is not an absolute path!"
318     exit 1
319 else
320     echo "testing absolute path checker passed"
321 fi
322 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf
323 if [ $? -eq 0 ]; then
324     echo "This should have failed because the path does not end with 'fdroid'!"
325     exit 1
326 else
327     echo "testing dirname exists checker passed"
328 fi
329 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid
330 if [ $? -eq 0 ]; then
331     echo "This should have failed because the dirname path does not exist!"
332     exit 1
333 else
334     echo "testing dirname exists checker passed"
335 fi
336 set -e
337
338
339 #------------------------------------------------------------------------------#
340 echo_header "setup a new repo from scratch using ANDROID_HOME and do a local sync"
341
342 REPOROOT=`create_test_dir`
343 cd $REPOROOT
344 $fdroid init
345 copy_apks_into_repo $REPOROOT
346 $fdroid update --create-metadata --verbose
347 $fdroid readmeta
348 grep -F '<application id=' repo/index.xml > /dev/null
349
350 LOCALCOPYDIR=`create_test_dir`/fdroid
351 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
352 NEWREPOROOT=`create_test_dir`
353 cd $NEWREPOROOT
354 $fdroid init
355 $fdroid server update --local-copy-dir=$LOCALCOPYDIR --sync-from-local-copy-dir
356
357
358 #------------------------------------------------------------------------------#
359 # check that --android-home fails when dir does not exist or is not a dir
360
361 REPOROOT=`create_test_dir`
362 KEYSTORE=$REPOROOT/keystore.jks
363 cd $REPOROOT
364 set +e
365 $fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
366 if [ $? -eq 0 ]; then
367     echo "This should have failed because /opt/fakeandroidhome does not exist!"
368     exit 1
369 else
370     echo "testing android-home path checker passed"
371 fi
372 TESTFILE=`create_test_file`
373 $fdroid init --keystore $KEYSTORE --android-home $TESTFILE
374 if [ $? -eq 0 ]; then
375     echo "This should have failed because $TESTFILE is a file not a dir!"
376     exit 1
377 else
378     echo "testing android-home not-dir checker passed"
379 fi
380 set -e
381
382
383 #------------------------------------------------------------------------------#
384 echo_header "check that fake android home passes 'fdroid init'"
385
386 REPOROOT=`create_test_dir`
387 FAKE_ANDROID_HOME=`create_test_dir`
388 create_fake_android_home $FAKE_ANDROID_HOME
389 KEYSTORE=$REPOROOT/keystore.jks
390 cd $REPOROOT
391 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
392
393
394 #------------------------------------------------------------------------------#
395 echo_header "check that 'fdroid init' fails when build-tools cannot be found"
396
397 if [ -e /usr/bin/aapt ]; then
398     echo "/usr/bin/aapt exists, not running test"
399 else
400     REPOROOT=`create_test_dir`
401     FAKE_ANDROID_HOME=`create_test_dir`
402     create_fake_android_home $FAKE_ANDROID_HOME
403     rm -f $FAKE_ANDROID_HOME/build-tools/*/aapt
404     KEYSTORE=$REPOROOT/keystore.jks
405     cd $REPOROOT
406     set +e
407     $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
408     [ $? -eq 0 ] && exit 1
409     set -e
410 fi
411
412
413 #------------------------------------------------------------------------------#
414 echo_header "check that --android-home overrides ANDROID_HOME"
415
416 REPOROOT=`create_test_dir`
417 FAKE_ANDROID_HOME=`create_test_dir`
418 create_fake_android_home $FAKE_ANDROID_HOME
419 KEYSTORE=$REPOROOT/keystore.jks
420 cd $REPOROOT
421 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
422 set +e
423 grep $FAKE_ANDROID_HOME $REPOROOT/config.py
424 if [ $? -ne 0 ]; then
425     echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
426     exit 1
427 fi
428 set -e
429
430
431 #------------------------------------------------------------------------------#
432 # In this case, ANDROID_HOME is set to a fake, non-working version that will
433 # be detected by fdroid as an Android SDK install.  It should use the path set
434 # by --android-home over the one in ANDROID_HOME, therefore if it uses the one
435 # in ANDROID_HOME, it won't work because it is a fake one.  Only
436 # --android-home provides a working one.
437 echo_header "setup a new repo from scratch with keystore and android-home set on cmd line"
438
439 REPOROOT=`create_test_dir`
440 KEYSTORE=$REPOROOT/keystore.jks
441 FAKE_ANDROID_HOME=`create_test_dir`
442 create_fake_android_home $FAKE_ANDROID_HOME
443 STORED_ANDROID_HOME=$ANDROID_HOME
444 unset ANDROID_HOME
445 echo "ANDROID_HOME: $ANDROID_HOME"
446 cd $REPOROOT
447 $fdroid init --keystore $KEYSTORE --android-home $STORED_ANDROID_HOME --no-prompt
448 test -e $KEYSTORE
449 copy_apks_into_repo $REPOROOT
450 $fdroid update --create-metadata --verbose
451 $fdroid readmeta
452 grep -F '<application id=' repo/index.xml > /dev/null
453 test -e repo/index.xml
454 test -e repo/index.jar
455 test -e repo/index-v1.jar
456 export ANDROID_HOME=$STORED_ANDROID_HOME
457
458
459 #------------------------------------------------------------------------------#
460 echo_header "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
461
462 REPOROOT=`create_test_dir`
463 cd $REPOROOT
464 mkdir repo
465 copy_apks_into_repo $REPOROOT
466 $fdroid init
467 $fdroid update --create-metadata --verbose
468 $fdroid readmeta
469 grep -F '<application id=' repo/index.xml > /dev/null
470
471
472 #------------------------------------------------------------------------------#
473 echo_header "setup a new repo from scratch and generate a keystore"
474
475 REPOROOT=`create_test_dir`
476 KEYSTORE=$REPOROOT/keystore.jks
477 cd $REPOROOT
478 $fdroid init --keystore $KEYSTORE
479 test -e $KEYSTORE
480 copy_apks_into_repo $REPOROOT
481 $fdroid update --create-metadata --verbose
482 $fdroid readmeta
483 test -e repo/index.xml
484 test -e repo/index.jar
485 test -e repo/index-v1.jar
486 grep -F '<application id=' repo/index.xml > /dev/null
487
488
489 #------------------------------------------------------------------------------#
490 echo_header "setup a new repo manually and generate a keystore"
491
492 REPOROOT=`create_test_dir`
493 KEYSTORE=$REPOROOT/keystore.jks
494 cd $REPOROOT
495 touch config.py
496 cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/
497 ! test -e $KEYSTORE
498 set +e
499 $fdroid update
500 if [ $? -eq 0 ]; then
501     echo "This should have failed because this repo has no keystore!"
502     exit 1
503 else
504     echo '`fdroid update` prompted to add keystore'
505 fi
506 set -e
507 $fdroid update --create-key
508 test -e $KEYSTORE
509 copy_apks_into_repo $REPOROOT
510 $fdroid update --create-metadata --verbose
511 $fdroid readmeta
512 test -e repo/index.xml
513 test -e repo/index.jar
514 test -e repo/index-v1.jar
515 grep -F '<application id=' repo/index.xml > /dev/null
516
517
518 #------------------------------------------------------------------------------#
519 echo_header "setup a new repo from scratch, generate a keystore, then add APK and update"
520
521 REPOROOT=`create_test_dir`
522 KEYSTORE=$REPOROOT/keystore.jks
523 cd $REPOROOT
524 $fdroid init --keystore $KEYSTORE
525 test -e $KEYSTORE
526 copy_apks_into_repo $REPOROOT
527 $fdroid update --create-metadata --verbose
528 $fdroid readmeta
529 test -e repo/index.xml
530 test -e repo/index.jar
531 test -e repo/index-v1.jar
532 grep -F '<application id=' repo/index.xml > /dev/null
533 test -e $REPOROOT/repo/info.guardianproject.urzip_100.apk || \
534     cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
535 $fdroid update --create-metadata --verbose
536 $fdroid readmeta
537 test -e repo/index.xml
538 test -e repo/index.jar
539 test -e repo/index-v1.jar
540 grep -F '<application id=' repo/index.xml > /dev/null
541
542
543 #------------------------------------------------------------------------------#
544 echo_header "setup a new repo from scratch with a HSM/smartcard"
545 REPOROOT=`create_test_dir`
546 cd $REPOROOT
547 $fdroid init --keystore NONE
548 test -e opensc-fdroid.cfg
549 test ! -e NONE
550
551
552 #------------------------------------------------------------------------------#
553 echo_header "setup a new repo with no keystore, add APK, and update"
554
555 REPOROOT=`create_test_dir`
556 KEYSTORE=$REPOROOT/keystore.jks
557 cd $REPOROOT
558 touch config.py
559 touch fdroid-icon.png
560 mkdir repo
561 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
562 set +e
563 $fdroid update --create-metadata --verbose
564 if [ $? -eq 0 ]; then
565     echo "This should have failed because this repo has no keystore!"
566     exit 1
567 else
568     echo '`fdroid update` prompted to add keystore'
569 fi
570 set -e
571
572 # now set up fake, non-working keystore setup
573 touch $KEYSTORE
574 echo "keystore = \"$KEYSTORE\"" >> config.py
575 echo 'repo_keyalias = "foo"' >> config.py
576 echo 'keystorepass = "foo"' >> config.py
577 echo 'keypass = "foo"' >> config.py
578 set +e
579 $fdroid update --create-metadata --verbose
580 if [ $? -eq 0 ]; then
581     echo "This should have failed because this repo has a bad/fake keystore!"
582     exit 1
583 else
584     echo '`fdroid update` prompted to add keystore'
585 fi
586 set -e
587
588
589 #------------------------------------------------------------------------------#
590 echo_header "copy tests/repo, update with binary transparency log"
591
592 REPOROOT=`create_test_dir`
593 GNUPGHOME=$REPOROOT/gnupghome
594 KEYSTORE=$WORKSPACE/tests/keystore.jks
595 mkdir $REPOROOT/git_remote
596 cd $REPOROOT/git_remote
597 git init --bare
598 cd $REPOROOT
599 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
600 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
601 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
602 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
603 echo "binary_transparency_remote = '$REPOROOT/git_remote'" >> config.py
604 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
605 $fdroid update --verbose --pretty
606 test -e repo/index.xml
607 test -e repo/index.jar
608 test -e repo/index-v1.jar
609 grep -F '<application id=' repo/index.xml > /dev/null
610 cd binary_transparency
611 [ `git rev-list --count HEAD` == "2" ]
612 cd $REPOROOT/git_remote
613 [ `git rev-list --count HEAD` == "2" ]
614
615
616 #------------------------------------------------------------------------------#
617 echo_header "setup a new repo with keystore with APK, update, then without key"
618
619 REPOROOT=`create_test_dir`
620 KEYSTORE=$REPOROOT/keystore.jks
621 cd $REPOROOT
622 $fdroid init --keystore $KEYSTORE
623 test -e $KEYSTORE
624 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
625 $fdroid update --create-metadata --verbose
626 $fdroid readmeta
627 test -e repo/index.xml
628 test -e repo/index.jar
629 test -e repo/index-v1.jar
630 grep -F '<application id=' repo/index.xml > /dev/null
631
632 # now set fake repo_keyalias
633 sed -i.tmp 's,^ *repo_keyalias.*,repo_keyalias = "fake",' $REPOROOT/config.py
634 set +e
635 $fdroid update
636 if [ $? -eq 0 ]; then
637     echo "This should have failed because this repo has a bad repo_keyalias!"
638     exit 1
639 else
640     echo '`fdroid update` prompted to add keystore'
641 fi
642 set -e
643
644 # try creating a new keystore, but fail because the old one is there
645 test -e $KEYSTORE
646 set +e
647 $fdroid update --create-key
648 if [ $? -eq 0 ]; then
649     echo "This should have failed because a keystore is already there!"
650     exit 1
651 else
652     echo '`fdroid update` complained about existing keystore'
653 fi
654 set -e
655
656 # now actually create the key with the existing settings
657 rm -f $KEYSTORE
658 ! test -e $KEYSTORE
659 $fdroid update --create-key
660 test -e $KEYSTORE
661
662
663 #------------------------------------------------------------------------------#
664
665 # remove this to prevent git conflicts and complaining
666 rm -rf $WORKSPACE/fdroidserver.egg-info/
667
668 echo SUCCESS