chiark / gitweb /
server: remove unused --sync-from-local-copy-dir
[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 echo "sync_from_local_copy_dir = True" >> config.py
356 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
357
358
359 #------------------------------------------------------------------------------#
360 # check that --android-home fails when dir does not exist or is not a dir
361
362 REPOROOT=`create_test_dir`
363 KEYSTORE=$REPOROOT/keystore.jks
364 cd $REPOROOT
365 set +e
366 $fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
367 if [ $? -eq 0 ]; then
368     echo "This should have failed because /opt/fakeandroidhome does not exist!"
369     exit 1
370 else
371     echo "testing android-home path checker passed"
372 fi
373 TESTFILE=`create_test_file`
374 $fdroid init --keystore $KEYSTORE --android-home $TESTFILE
375 if [ $? -eq 0 ]; then
376     echo "This should have failed because $TESTFILE is a file not a dir!"
377     exit 1
378 else
379     echo "testing android-home not-dir checker passed"
380 fi
381 set -e
382
383
384 #------------------------------------------------------------------------------#
385 echo_header "check that fake android home passes 'fdroid init'"
386
387 REPOROOT=`create_test_dir`
388 FAKE_ANDROID_HOME=`create_test_dir`
389 create_fake_android_home $FAKE_ANDROID_HOME
390 KEYSTORE=$REPOROOT/keystore.jks
391 cd $REPOROOT
392 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
393
394
395 #------------------------------------------------------------------------------#
396 echo_header "check that 'fdroid init' fails when build-tools cannot be found"
397
398 if [ -e /usr/bin/aapt ]; then
399     echo "/usr/bin/aapt exists, not running test"
400 else
401     REPOROOT=`create_test_dir`
402     FAKE_ANDROID_HOME=`create_test_dir`
403     create_fake_android_home $FAKE_ANDROID_HOME
404     rm -f $FAKE_ANDROID_HOME/build-tools/*/aapt
405     KEYSTORE=$REPOROOT/keystore.jks
406     cd $REPOROOT
407     set +e
408     $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
409     [ $? -eq 0 ] && exit 1
410     set -e
411 fi
412
413
414 #------------------------------------------------------------------------------#
415 echo_header "check that --android-home overrides ANDROID_HOME"
416
417 REPOROOT=`create_test_dir`
418 FAKE_ANDROID_HOME=`create_test_dir`
419 create_fake_android_home $FAKE_ANDROID_HOME
420 KEYSTORE=$REPOROOT/keystore.jks
421 cd $REPOROOT
422 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
423 set +e
424 grep $FAKE_ANDROID_HOME $REPOROOT/config.py
425 if [ $? -ne 0 ]; then
426     echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
427     exit 1
428 fi
429 set -e
430
431
432 #------------------------------------------------------------------------------#
433 # In this case, ANDROID_HOME is set to a fake, non-working version that will
434 # be detected by fdroid as an Android SDK install.  It should use the path set
435 # by --android-home over the one in ANDROID_HOME, therefore if it uses the one
436 # in ANDROID_HOME, it won't work because it is a fake one.  Only
437 # --android-home provides a working one.
438 echo_header "setup a new repo from scratch with keystore and android-home set on cmd line"
439
440 REPOROOT=`create_test_dir`
441 KEYSTORE=$REPOROOT/keystore.jks
442 FAKE_ANDROID_HOME=`create_test_dir`
443 create_fake_android_home $FAKE_ANDROID_HOME
444 STORED_ANDROID_HOME=$ANDROID_HOME
445 unset ANDROID_HOME
446 echo "ANDROID_HOME: $ANDROID_HOME"
447 cd $REPOROOT
448 $fdroid init --keystore $KEYSTORE --android-home $STORED_ANDROID_HOME --no-prompt
449 test -e $KEYSTORE
450 copy_apks_into_repo $REPOROOT
451 $fdroid update --create-metadata --verbose
452 $fdroid readmeta
453 grep -F '<application id=' repo/index.xml > /dev/null
454 test -e repo/index.xml
455 test -e repo/index.jar
456 test -e repo/index-v1.jar
457 export ANDROID_HOME=$STORED_ANDROID_HOME
458
459
460 #------------------------------------------------------------------------------#
461 echo_header "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
462
463 REPOROOT=`create_test_dir`
464 cd $REPOROOT
465 mkdir repo
466 copy_apks_into_repo $REPOROOT
467 $fdroid init
468 $fdroid update --create-metadata --verbose
469 $fdroid readmeta
470 grep -F '<application id=' repo/index.xml > /dev/null
471
472
473 #------------------------------------------------------------------------------#
474 echo_header "setup a new repo from scratch and generate a keystore"
475
476 REPOROOT=`create_test_dir`
477 KEYSTORE=$REPOROOT/keystore.jks
478 cd $REPOROOT
479 $fdroid init --keystore $KEYSTORE
480 test -e $KEYSTORE
481 copy_apks_into_repo $REPOROOT
482 $fdroid update --create-metadata --verbose
483 $fdroid readmeta
484 test -e repo/index.xml
485 test -e repo/index.jar
486 test -e repo/index-v1.jar
487 grep -F '<application id=' repo/index.xml > /dev/null
488
489
490 #------------------------------------------------------------------------------#
491 echo_header "setup a new repo manually and generate a keystore"
492
493 REPOROOT=`create_test_dir`
494 KEYSTORE=$REPOROOT/keystore.jks
495 cd $REPOROOT
496 touch config.py
497 cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/
498 ! test -e $KEYSTORE
499 set +e
500 $fdroid update
501 if [ $? -eq 0 ]; then
502     echo "This should have failed because this repo has no keystore!"
503     exit 1
504 else
505     echo '`fdroid update` prompted to add keystore'
506 fi
507 set -e
508 $fdroid update --create-key
509 test -e $KEYSTORE
510 copy_apks_into_repo $REPOROOT
511 $fdroid update --create-metadata --verbose
512 $fdroid readmeta
513 test -e repo/index.xml
514 test -e repo/index.jar
515 test -e repo/index-v1.jar
516 grep -F '<application id=' repo/index.xml > /dev/null
517
518
519 #------------------------------------------------------------------------------#
520 echo_header "setup a new repo from scratch, generate a keystore, then add APK and update"
521
522 REPOROOT=`create_test_dir`
523 KEYSTORE=$REPOROOT/keystore.jks
524 cd $REPOROOT
525 $fdroid init --keystore $KEYSTORE
526 test -e $KEYSTORE
527 copy_apks_into_repo $REPOROOT
528 $fdroid update --create-metadata --verbose
529 $fdroid readmeta
530 test -e repo/index.xml
531 test -e repo/index.jar
532 test -e repo/index-v1.jar
533 grep -F '<application id=' repo/index.xml > /dev/null
534 test -e $REPOROOT/repo/info.guardianproject.urzip_100.apk || \
535     cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
536 $fdroid update --create-metadata --verbose
537 $fdroid readmeta
538 test -e repo/index.xml
539 test -e repo/index.jar
540 test -e repo/index-v1.jar
541 grep -F '<application id=' repo/index.xml > /dev/null
542
543
544 #------------------------------------------------------------------------------#
545 echo_header "setup a new repo from scratch with a HSM/smartcard"
546 REPOROOT=`create_test_dir`
547 cd $REPOROOT
548 $fdroid init --keystore NONE
549 test -e opensc-fdroid.cfg
550 test ! -e NONE
551
552
553 #------------------------------------------------------------------------------#
554 echo_header "setup a new repo with no keystore, add APK, and update"
555
556 REPOROOT=`create_test_dir`
557 KEYSTORE=$REPOROOT/keystore.jks
558 cd $REPOROOT
559 touch config.py
560 touch fdroid-icon.png
561 mkdir repo
562 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
563 set +e
564 $fdroid update --create-metadata --verbose
565 if [ $? -eq 0 ]; then
566     echo "This should have failed because this repo has no keystore!"
567     exit 1
568 else
569     echo '`fdroid update` prompted to add keystore'
570 fi
571 set -e
572
573 # now set up fake, non-working keystore setup
574 touch $KEYSTORE
575 echo "keystore = \"$KEYSTORE\"" >> config.py
576 echo 'repo_keyalias = "foo"' >> config.py
577 echo 'keystorepass = "foo"' >> config.py
578 echo 'keypass = "foo"' >> config.py
579 set +e
580 $fdroid update --create-metadata --verbose
581 if [ $? -eq 0 ]; then
582     echo "This should have failed because this repo has a bad/fake keystore!"
583     exit 1
584 else
585     echo '`fdroid update` prompted to add keystore'
586 fi
587 set -e
588
589
590 #------------------------------------------------------------------------------#
591 echo_header "copy tests/repo, update with binary transparency log"
592
593 REPOROOT=`create_test_dir`
594 GNUPGHOME=$REPOROOT/gnupghome
595 KEYSTORE=$WORKSPACE/tests/keystore.jks
596 mkdir $REPOROOT/git_remote
597 cd $REPOROOT/git_remote
598 git init --bare
599 cd $REPOROOT
600 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
601 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
602 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
603 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
604 echo "binary_transparency_remote = '$REPOROOT/git_remote'" >> config.py
605 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
606 $fdroid update --verbose
607 $fdroid server update --verbose
608 test -e repo/index.xml
609 test -e repo/index.jar
610 test -e repo/index-v1.jar
611 grep -F '<application id=' repo/index.xml > /dev/null
612 cd binary_transparency
613 [ `git rev-list --count HEAD` == "2" ]
614 cd $REPOROOT/git_remote
615 [ `git rev-list --count HEAD` == "2" ]
616
617
618 #------------------------------------------------------------------------------#
619 echo_header "setup a new repo with keystore with APK, update, then without key"
620
621 REPOROOT=`create_test_dir`
622 KEYSTORE=$REPOROOT/keystore.jks
623 cd $REPOROOT
624 $fdroid init --keystore $KEYSTORE
625 test -e $KEYSTORE
626 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
627 $fdroid update --create-metadata --verbose
628 $fdroid readmeta
629 test -e repo/index.xml
630 test -e repo/index.jar
631 test -e repo/index-v1.jar
632 grep -F '<application id=' repo/index.xml > /dev/null
633
634 # now set fake repo_keyalias
635 sed -i.tmp 's,^ *repo_keyalias.*,repo_keyalias = "fake",' $REPOROOT/config.py
636 set +e
637 $fdroid update
638 if [ $? -eq 0 ]; then
639     echo "This should have failed because this repo has a bad repo_keyalias!"
640     exit 1
641 else
642     echo '`fdroid update` prompted to add keystore'
643 fi
644 set -e
645
646 # try creating a new keystore, but fail because the old one is there
647 test -e $KEYSTORE
648 set +e
649 $fdroid update --create-key
650 if [ $? -eq 0 ]; then
651     echo "This should have failed because a keystore is already there!"
652     exit 1
653 else
654     echo '`fdroid update` complained about existing keystore'
655 fi
656 set -e
657
658 # now actually create the key with the existing settings
659 rm -f $KEYSTORE
660 ! test -e $KEYSTORE
661 $fdroid update --create-key
662 test -e $KEYSTORE
663
664
665 #------------------------------------------------------------------------------#
666
667 # remove this to prevent git conflicts and complaining
668 rm -rf $WORKSPACE/fdroidserver.egg-info/
669
670 echo SUCCESS