chiark / gitweb /
tests: checkupdates now requires a clean git repo state
[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     find $APKDIR -type f -name '*.apk' -print0 | while IFS= read -r -d '' f; do
12         echo $f | grep -F -v -e unaligned -e unsigned -e badsig -e badcert -e bad-unicode -e janus.apk || continue
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 fdroid_init_with_prebuilt_keystore() {
45     if [ -z "$1" ]; then
46         keystore=$WORKSPACE/tests/keystore.jks
47     else
48         keystore="$1"
49     fi
50     $fdroid init --keystore $keystore --repo-keyalias=sova
51     echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
52     echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
53 }
54
55 # the < is reverse since 0 means success in exit codes
56 have_git_2_3() {
57     python3 -c "import sys; from distutils.version import LooseVersion as V; sys.exit(V(sys.argv[3]) < V('2.3'))" `git --version`
58 }
59
60 is_MD5_disabled() {
61     javac $WORKSPACE/tests/IsMD5Disabled.java && java -cp $WORKSPACE/tests IsMD5Disabled
62     return $?
63 }
64
65 #------------------------------------------------------------------------------#
66 # "main"
67
68 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
69     set +x
70     echo "Usage: $0 '/path/to/folder/with/apks'"
71     exit 1
72 fi
73
74 if [ -z "$ANDROID_HOME" ]; then
75     echo "ANDROID_HOME must be set with the path to the Android SDK, i.e.: "
76     echo "  export ANDROID_HOME=/opt/android-sdk"
77     exit 1
78 fi
79
80 if [ -d tests ]; then
81     cd tests
82 fi
83
84 if [ -z "$1" ]; then
85     APKDIR=`pwd`
86 else
87     APKDIR=$1
88 fi
89
90 if [ -z $WORKSPACE ]; then
91     WORKSPACE=`dirname $(pwd)`
92     echo "Setting Workspace to $WORKSPACE"
93 fi
94
95 # allow the location of the script to be overridden
96 if [ -z $fdroid ]; then
97     fdroid="$WORKSPACE/fdroid"
98 fi
99
100 # allow the location of aapt to be overridden
101 if [ -z $aapt ]; then
102     aapt=`ls -1 $ANDROID_HOME/build-tools/*/aapt | sort | tail -1`
103 fi
104
105 # try to use GNU sed on OSX/BSD cuz BSD sed sucks
106 if which gsed; then
107     sed=gsed
108 else
109     sed=sed
110 fi
111
112 set -x # show each command as it is executed
113
114 #------------------------------------------------------------------------------#
115 echo_header "run commit hooks"
116
117 cd $WORKSPACE
118 ./hooks/pre-commit
119
120
121 #------------------------------------------------------------------------------#
122 echo_header "test python getsig replacement"
123
124 cd $WORKSPACE/tests/getsig
125 ./make.sh
126
127 cd $WORKSPACE/tests
128 for testcase in $WORKSPACE/tests/i*.TestCase; do
129     if [ $testcase == $WORKSPACE/tests/install.TestCase ]; then
130         echo "skipping install.TestCase, its too troublesome in CI builds"
131         continue
132     fi
133     $testcase
134 done
135
136
137 #------------------------------------------------------------------------------#
138 echo_header "print fdroid version"
139
140 $fdroid --version
141
142
143 #------------------------------------------------------------------------------#
144 echo_header 'run process when building and signing are on separate machines'
145
146 REPOROOT=`create_test_dir`
147 cd $REPOROOT
148 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
149 $fdroid init --keystore keystore.jks --repo-keyalias=sova
150 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
151 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
152 echo "accepted_formats = ['txt', 'yml']" >> config.py
153 echo 'keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US"' >> config.py
154 test -d archive || mkdir archive
155 test -d metadata || mkdir metadata
156 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
157 test -d repo || mkdir repo
158 test -d unsigned || mkdir unsigned
159 cp $WORKSPACE/tests/urzip-release-unsigned.apk unsigned/info.guardianproject.urzip_100.apk
160 $fdroid publish --verbose
161 $fdroid update --verbose --nosign
162 $fdroid signindex --verbose
163 test -e repo/index.xml
164 test -e repo/index.jar
165 test -e repo/index-v1.jar
166 test -e tmp/apkcache
167 ! test -z tmp/apkcache
168 test -L urzip.apk
169 grep -F '<application id=' repo/index.xml > /dev/null
170
171
172 #------------------------------------------------------------------------------#
173 echo_header "test UTF-8 metadata"
174
175 REPOROOT=`create_test_dir`
176 cd $REPOROOT
177
178 fdroid_init_with_prebuilt_keystore
179 $sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py
180 echo "mirrors = ('https://foo.bar/fdroid', 'http://secret.onion/fdroid')" >> config.py
181 mkdir metadata
182 cp $WORKSPACE/tests/urzip.apk $WORKSPACE/tests/bad-unicode*.apk repo/
183 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
184
185 $fdroid readmeta
186 $fdroid update
187
188
189 #------------------------------------------------------------------------------#
190 echo_header 'run "fdroid build" in fresh git checkout from import.TestCase'
191
192 cd $WORKSPACE/tests/tmp/importer
193 git remote update -p
194 git clean -fdx
195 # stick with known working commit, in case future commits break things for this code
196 git reset --hard fea54e1161d5eb9eb1a54e26253ef84d3ab63705
197 if [ -d $ANDROID_HOME/platforms/android-23 && -d $ANDROID_HOME/build-tools/23.0.3 ]; then
198     echo "build_tools = '`ls -1 $ANDROID_HOME/build-tools/ | sort -n | tail -1`'" > config.py
199     echo "force_build_tools = True" >> config.py
200     $fdroid build --verbose org.fdroid.ci.test.app:300
201 else
202     echo 'WARNING: Skipping "fdroid build" test since android-23 is missing!'
203 fi
204
205 #------------------------------------------------------------------------------#
206 echo_header 'copy git import and run "fdroid scanner" on it'
207
208 REPOROOT=`create_test_dir`
209 cd $REPOROOT
210 cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/
211 mkdir metadata
212 echo "Auto Name:Just A Test" > metadata/org.fdroid.ci.test.app.txt
213 echo "Web Site:" >> metadata/org.fdroid.ci.test.app.txt
214 echo "Build:0.3,300" >> metadata/org.fdroid.ci.test.app.txt
215 echo "    commit=0.3" >> metadata/org.fdroid.ci.test.app.txt
216 echo "    subdir=app" >> metadata/org.fdroid.ci.test.app.txt
217 echo "    gradle=yes" >> metadata/org.fdroid.ci.test.app.txt
218 echo "" >> metadata/org.fdroid.ci.test.app.txt
219 echo "Repo:https://gitlab.com/fdroid/ci-test-app.git" >> metadata/org.fdroid.ci.test.app.txt
220 echo "Repo Type:git" >> metadata/org.fdroid.ci.test.app.txt
221 mkdir build
222 cp -a $WORKSPACE/tests/tmp/importer build/org.fdroid.ci.test.app
223 ls -l build/org.fdroid.ci.test.app
224 $fdroid scanner org.fdroid.ci.test.app --verbose
225
226
227 #------------------------------------------------------------------------------#
228 echo_header "copy tests/repo, generate java/gpg keys, update, and gpgsign"
229
230 REPOROOT=`create_test_dir`
231 GNUPGHOME=$REPOROOT/gnupghome
232 cd $REPOROOT
233 fdroid_init_with_prebuilt_keystore
234 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
235 cp -a $WORKSPACE/tests/gnupghome $GNUPGHOME
236 chmod 0700 $GNUPGHOME
237 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
238 echo "install_list = 'org.adaway'" >> config.py
239 echo "uninstall_list = ('com.android.vending', 'com.facebook.orca',)" >> config.py
240 echo "gpghome = '$GNUPGHOME'" >> config.py
241 echo "gpgkey = 'CE71F7FB'" >> config.py
242 echo "mirrors = ('http://foobarfoobarfoobar.onion/fdroid','https://foo.bar/fdroid',)" >> config.py
243 $fdroid update --verbose --pretty
244 test -e repo/index.xml
245 test -e repo/index.jar
246 test -e repo/index-v1.jar
247 grep -F '<application id=' repo/index.xml > /dev/null
248 grep -F '<install packageName=' repo/index.xml > /dev/null
249 grep -F '<uninstall packageName=' repo/index.xml > /dev/null
250 # OSX tests are run on Travis-CI, and gpg fails to launch gpg-agent there
251 if [ "$TRAVIS_OS_NAME" != "osx" ]; then
252     $fdroid gpgsign --verbose
253     $fdroid gpgsign --verbose
254     test -e repo/obb.mainpatch.current_1619.apk.asc
255     test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc
256     ! test -e repo/obb.mainpatch.current_1619.apk.asc.asc
257     ! test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc.asc
258     ! test -e repo/index.xml.asc
259 fi
260
261 # we can't easily reproduce the timestamps for things, so just hardcode them
262 $sed -i.tmp -e 's,timestamp="[0-9]*",timestamp="1480431575",' repo/index.xml
263 diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml
264 sed -i --expression='s,"timestamp": [0-9]*,"timestamp": 1502845383782,' repo/index-v1.json
265 diff -uw $WORKSPACE/tests/repo/index-v1.json repo/index-v1.json
266
267
268 #------------------------------------------------------------------------------#
269 echo_header 'test moving lots of APKs to the archive'
270
271 REPOROOT=`create_test_dir`
272 cd $REPOROOT
273 fdroid_init_with_prebuilt_keystore
274 echo "accepted_formats = ['txt']" >> config.py
275 $sed -i.tmp '/allow_disabled_algorithms/d' config.py
276 test -d metadata || mkdir metadata
277 cp $WORKSPACE/tests/metadata/*.txt metadata/
278 echo 'Summary:good test version of urzip' > metadata/info.guardianproject.urzip.txt
279 echo 'Summary:good MD5 sig, which is disabled algorithm' > metadata/org.bitbucket.tickytacky.mirrormirror.txt
280 $sed -i.tmp '/Archive Policy:/d' metadata/*.txt
281 test -d repo || mkdir repo
282 cp $WORKSPACE/tests/urzip.apk \
283    $WORKSPACE/tests/org.bitbucket.tickytacky.mirrormirror_[0-9].apk \
284    $WORKSPACE/tests/repo/com.politedroid_[0-9].apk \
285    $WORKSPACE/tests/repo/obb.main.twoversions_110161[357].apk \
286    repo/
287 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
288
289 $fdroid update --pretty --nosign
290 echo "This will fail when jarsigner allows MD5 for APK signatures"
291 test `grep '<package>' archive/index.xml | wc -l` -eq 5
292 test `grep '<package>' repo/index.xml | wc -l` -eq 7
293
294
295 #------------------------------------------------------------------------------#
296 echo_header 'test per-app "Archive Policy"'
297
298 REPOROOT=`create_test_dir`
299 cd $REPOROOT
300 fdroid_init_with_prebuilt_keystore
301 echo "accepted_formats = ['txt']" >> config.py
302 test -d metadata || mkdir metadata
303 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
304 test -d repo || mkdir repo
305 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
306 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
307
308 $fdroid update --pretty --nosign
309 test `grep '<package>' archive/index.xml | wc -l` -eq 0
310 test `grep '<package>' repo/index.xml | wc -l` -eq 4
311 grep -F com.politedroid_3.apk repo/index.xml
312 grep -F com.politedroid_4.apk repo/index.xml
313 grep -F com.politedroid_5.apk repo/index.xml
314 grep -F com.politedroid_6.apk repo/index.xml
315 test -e repo/com.politedroid_3.apk
316 test -e repo/com.politedroid_4.apk
317 test -e repo/com.politedroid_5.apk
318 test -e repo/com.politedroid_6.apk
319
320 echo "enable one app in the repo"
321 $sed -i.tmp 's,^Archive Policy:4,Archive Policy:1,' metadata/com.politedroid.txt
322 $fdroid update --pretty --nosign
323 test `grep '<package>' archive/index.xml | wc -l` -eq 3
324 test `grep '<package>' repo/index.xml | wc -l` -eq 1
325 grep -F com.politedroid_3.apk archive/index.xml
326 grep -F com.politedroid_4.apk archive/index.xml
327 grep -F com.politedroid_5.apk archive/index.xml
328 grep -F com.politedroid_6.apk repo/index.xml
329 test -e archive/com.politedroid_3.apk
330 test -e archive/com.politedroid_4.apk
331 test -e archive/com.politedroid_5.apk
332 test -e repo/com.politedroid_6.apk
333
334 echo "remove all apps from the repo"
335 $sed -i.tmp 's,^Archive Policy:1,Archive Policy:0,' metadata/com.politedroid.txt
336 $fdroid update --pretty --nosign
337 test `grep '<package>' archive/index.xml | wc -l` -eq 4
338 test `grep '<package>' repo/index.xml | wc -l` -eq 0
339 grep -F com.politedroid_3.apk archive/index.xml
340 grep -F com.politedroid_4.apk archive/index.xml
341 grep -F com.politedroid_5.apk archive/index.xml
342 grep -F com.politedroid_6.apk archive/index.xml
343 test -e archive/com.politedroid_3.apk
344 test -e archive/com.politedroid_4.apk
345 test -e archive/com.politedroid_5.apk
346 test -e archive/com.politedroid_6.apk
347 ! test -e repo/com.politedroid_6.apk
348
349 echo "move back one from archive to the repo"
350 $sed -i.tmp 's,^Archive Policy:0,Archive Policy:1,' metadata/com.politedroid.txt
351 $fdroid update --pretty --nosign
352 test `grep '<package>' archive/index.xml | wc -l` -eq 3
353 test `grep '<package>' repo/index.xml | wc -l` -eq 1
354 grep -F com.politedroid_3.apk archive/index.xml
355 grep -F com.politedroid_4.apk archive/index.xml
356 grep -F com.politedroid_5.apk archive/index.xml
357 grep -F com.politedroid_6.apk repo/index.xml
358 test -e archive/com.politedroid_3.apk
359 test -e archive/com.politedroid_4.apk
360 test -e archive/com.politedroid_5.apk
361 ! test -e archive/com.politedroid_6.apk
362 test -e repo/com.politedroid_6.apk
363
364
365
366 #------------------------------------------------------------------------------#
367 echo_header 'test moving old APKs to and from the archive'
368
369 REPOROOT=`create_test_dir`
370 cd $REPOROOT
371 fdroid_init_with_prebuilt_keystore
372 echo "accepted_formats = ['txt']" >> config.py
373 test -d metadata || mkdir metadata
374 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
375 $sed -i.tmp '/Archive Policy:/d' metadata/com.politedroid.txt
376 test -d repo || mkdir repo
377 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
378 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
379
380 $fdroid update --pretty --nosign
381 test `grep '<package>' archive/index.xml | wc -l` -eq 1
382 test `grep '<package>' repo/index.xml | wc -l` -eq 3
383 grep -F com.politedroid_3.apk archive/index.xml
384 grep -F com.politedroid_4.apk repo/index.xml
385 grep -F com.politedroid_5.apk repo/index.xml
386 grep -F com.politedroid_6.apk repo/index.xml
387 test -e archive/com.politedroid_3.apk
388 test -e repo/com.politedroid_4.apk
389 test -e repo/com.politedroid_5.apk
390 test -e repo/com.politedroid_6.apk
391
392 $sed -i.tmp 's,archive_older = 3,archive_older = 1,' config.py
393 $fdroid update --pretty --nosign
394 test `grep '<package>' archive/index.xml | wc -l` -eq 3
395 test `grep '<package>' repo/index.xml | wc -l` -eq 1
396 grep -F com.politedroid_3.apk archive/index.xml
397 grep -F com.politedroid_4.apk archive/index.xml
398 grep -F com.politedroid_5.apk archive/index.xml
399 grep -F com.politedroid_6.apk repo/index.xml
400 test -e archive/com.politedroid_3.apk
401 test -e archive/com.politedroid_4.apk
402 test -e archive/com.politedroid_5.apk
403 test -e repo/com.politedroid_6.apk
404
405 # disabling deletes from the archive
406 $sed -i.tmp 's/Build:1.3,4/Build:1.3,4\n    disable=testing deletion/' metadata/com.politedroid.txt
407 $fdroid update --pretty --nosign
408 test `grep '<package>' archive/index.xml | wc -l` -eq 2
409 test `grep '<package>' repo/index.xml | wc -l` -eq 1
410 grep -F com.politedroid_3.apk archive/index.xml
411 ! grep -F com.politedroid_4.apk archive/index.xml
412 grep -F com.politedroid_5.apk archive/index.xml
413 grep -F com.politedroid_6.apk repo/index.xml
414 test -e archive/com.politedroid_3.apk
415 ! test -e archive/com.politedroid_4.apk
416 test -e archive/com.politedroid_5.apk
417 test -e repo/com.politedroid_6.apk
418
419 # disabling deletes from the repo, and promotes one from the archive
420 $sed -i.tmp 's/Build:1.5,6/Build:1.5,6\n    disable=testing deletion/' metadata/com.politedroid.txt
421 $fdroid update --pretty --nosign
422 test `grep '<package>' archive/index.xml | wc -l` -eq 1
423 test `grep '<package>' repo/index.xml | wc -l` -eq 1
424 grep -F com.politedroid_3.apk archive/index.xml
425 grep -F com.politedroid_5.apk repo/index.xml
426 ! grep -F com.politedroid_6.apk repo/index.xml
427 test -e archive/com.politedroid_3.apk
428 test -e repo/com.politedroid_5.apk
429 ! test -e repo/com.politedroid_6.apk
430
431
432 #------------------------------------------------------------------------------#
433 echo_header 'test allowing disabled signatures in repo and archive'
434
435 REPOROOT=`create_test_dir`
436 cd $REPOROOT
437 fdroid_init_with_prebuilt_keystore
438 echo "accepted_formats = ['txt']" >> config.py
439 echo 'allow_disabled_algorithms = True' >> config.py
440 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
441 test -d metadata || mkdir metadata
442 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
443 echo 'Summary:good test version of urzip' > metadata/info.guardianproject.urzip.txt
444 echo 'Summary:good MD5 sig, disabled algorithm' > metadata/org.bitbucket.tickytacky.mirrormirror.txt
445 $sed -i.tmp '/Archive Policy:/d' metadata/*.txt
446 test -d repo || mkdir repo
447 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk \
448    $WORKSPACE/tests/org.bitbucket.tickytacky.mirrormirror_[0-9].apk \
449    $WORKSPACE/tests/urzip-badsig.apk \
450    repo/
451
452 $fdroid update --pretty --nosign
453 test `grep '<package>' archive/index.xml | wc -l` -eq 2
454 test `grep '<package>' repo/index.xml | wc -l` -eq 6
455 grep -F com.politedroid_3.apk archive/index.xml
456 grep -F com.politedroid_4.apk repo/index.xml
457 grep -F com.politedroid_5.apk repo/index.xml
458 grep -F com.politedroid_6.apk repo/index.xml
459 grep -F org.bitbucket.tickytacky.mirrormirror_1.apk archive/index.xml
460 grep -F org.bitbucket.tickytacky.mirrormirror_2.apk repo/index.xml
461 grep -F org.bitbucket.tickytacky.mirrormirror_3.apk repo/index.xml
462 grep -F org.bitbucket.tickytacky.mirrormirror_4.apk repo/index.xml
463 ! grep -F urzip-badsig.apk repo/index.xml
464 ! grep -F urzip-badsig.apk archive/index.xml
465 test -e archive/com.politedroid_3.apk
466 test -e repo/com.politedroid_4.apk
467 test -e repo/com.politedroid_5.apk
468 test -e repo/com.politedroid_6.apk
469 test -e archive/org.bitbucket.tickytacky.mirrormirror_1.apk
470 test -e repo/org.bitbucket.tickytacky.mirrormirror_2.apk
471 test -e repo/org.bitbucket.tickytacky.mirrormirror_3.apk
472 test -e repo/org.bitbucket.tickytacky.mirrormirror_4.apk
473 test -e archive/urzip-badsig.apk
474
475 $sed -i.tmp '/allow_disabled_algorithms/d' config.py
476 $fdroid update --pretty --nosign
477 test `grep '<package>' archive/index.xml | wc -l` -eq 5
478 test `grep '<package>' repo/index.xml | wc -l` -eq 3
479 grep -F org.bitbucket.tickytacky.mirrormirror_1.apk archive/index.xml
480 grep -F org.bitbucket.tickytacky.mirrormirror_2.apk archive/index.xml
481 grep -F org.bitbucket.tickytacky.mirrormirror_3.apk archive/index.xml
482 grep -F org.bitbucket.tickytacky.mirrormirror_4.apk archive/index.xml
483 grep -F com.politedroid_3.apk archive/index.xml
484 grep -F com.politedroid_4.apk repo/index.xml
485 grep -F com.politedroid_5.apk repo/index.xml
486 grep -F com.politedroid_6.apk repo/index.xml
487 ! grep -F urzip-badsig.apk repo/index.xml
488 ! grep -F urzip-badsig.apk archive/index.xml
489 test -e archive/org.bitbucket.tickytacky.mirrormirror_1.apk
490 test -e archive/org.bitbucket.tickytacky.mirrormirror_2.apk
491 test -e archive/org.bitbucket.tickytacky.mirrormirror_3.apk
492 test -e archive/org.bitbucket.tickytacky.mirrormirror_4.apk
493 test -e archive/com.politedroid_3.apk
494 test -e archive/urzip-badsig.apk
495 test -e repo/com.politedroid_4.apk
496 test -e repo/com.politedroid_5.apk
497 test -e repo/com.politedroid_6.apk
498
499
500 #------------------------------------------------------------------------------#
501 echo_header 'rename apks with `fdroid update --rename-apks`, --nosign for speed'
502
503 REPOROOT=`create_test_dir`
504 cd $REPOROOT
505 fdroid_init_with_prebuilt_keystore
506 echo "accepted_formats = ['txt', 'yml']" >> config.py
507 echo 'keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US"' >> config.py
508 test -d metadata || mkdir metadata
509 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
510 test -d repo || mkdir repo
511 cp $WORKSPACE/tests/urzip.apk "repo/asdfiuhk urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234 ö.apk"
512 $fdroid update --rename-apks --pretty --nosign
513 test -e repo/info.guardianproject.urzip_100.apk
514 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
515 cp $WORKSPACE/tests/urzip-release.apk repo/
516 $fdroid update --rename-apks --pretty --nosign
517 test -e repo/info.guardianproject.urzip_100.apk
518 test -e repo/info.guardianproject.urzip_100_b4964fd.apk
519 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
520 grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index-v1.json
521 ! grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index.xml
522 cp $WORKSPACE/tests/urzip-release.apk repo/
523 $fdroid update --rename-apks --pretty --nosign
524 test -e repo/info.guardianproject.urzip_100.apk
525 test -e repo/info.guardianproject.urzip_100_b4964fd.apk
526 test -e duplicates/repo/info.guardianproject.urzip_100_b4964fd.apk
527 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
528 grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index-v1.json
529 ! grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index.xml
530
531
532 #------------------------------------------------------------------------------#
533 echo_header "test metadata checks"
534
535 REPOROOT=`create_test_dir`
536 cd $REPOROOT
537
538 mkdir repo
539 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
540
541 set +e
542 $fdroid build
543 if [ $? -eq 0 ]; then
544     echo "This should have failed because there is no metadata!"
545     exit 1
546 else
547     echo "testing metadata checks passed"
548 fi
549 set -e
550
551 mkdir $REPOROOT/metadata/
552 cp $WORKSPACE/tests/metadata/org.smssecure.smssecure.txt $REPOROOT/metadata/
553 $fdroid readmeta
554
555 # now make a fake duplicate
556 touch $REPOROOT/metadata/org.smssecure.smssecure.yml
557
558 set +e
559 $fdroid readmeta
560 if [ $? -eq 0 ]; then
561     echo "This should have failed because there is a duplicate metadata file!"
562     exit 1
563 else
564     echo "testing duplicate metadata checks passed"
565 fi
566 set -e
567
568
569 #------------------------------------------------------------------------------#
570 echo_header "ensure commands that don't need the JDK work without a JDK configed"
571
572 REPOROOT=`create_test_dir`
573 cd $REPOROOT
574 mkdir repo
575 mkdir metadata
576 echo "License:GPL-2.0" >> metadata/fake.txt
577 echo "Summary:Yup still fake" >> metadata/fake.txt
578 echo "Categories:Internet" >> metadata/fake.txt
579 echo "Description:" >> metadata/fake.txt
580 echo "this is fake" >> metadata/fake.txt
581 echo "." >> metadata/fake.txt
582
583 # fake that no JDKs are available
584 echo 'java_paths = {}' > config.py
585
586 LOCAL_COPY_DIR=`create_test_dir`/fdroid
587 mkdir -p $LOCAL_COPY_DIR/repo
588 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
589
590 $fdroid checkupdates --allow-dirty
591 $fdroid gpgsign
592 $fdroid lint
593 $fdroid readmeta
594 $fdroid rewritemeta fake
595 $fdroid server update
596 $fdroid scanner
597
598 # run these to get their output, but the are not setup, so don't fail
599 $fdroid build || true
600 $fdroid import || true
601 $fdroid install || true
602
603
604 #------------------------------------------------------------------------------#
605 echo_header "create a source tarball"
606
607 cd $WORKSPACE
608 ./setup.py compile_catalog sdist
609
610 REPOROOT=`create_test_dir`
611 cd $REPOROOT
612 tar xzf `ls -1 $WORKSPACE/dist/fdroidserver-*.tar.gz | sort -n | tail -1`
613 cd $REPOROOT
614 ./fdroidserver-*/fdroid init
615 copy_apks_into_repo $REPOROOT
616 ./fdroidserver-*/fdroid update --create-metadata --verbose
617
618
619 #------------------------------------------------------------------------------#
620 echo_header "test config checks of local_copy_dir"
621
622 REPOROOT=`create_test_dir`
623 cd $REPOROOT
624 $fdroid init
625 $fdroid update --create-metadata --verbose
626 $fdroid readmeta
627 $fdroid server update --local-copy-dir=/tmp/fdroid
628
629 # now test the errors work
630 set +e
631 $fdroid server update --local-copy-dir=thisisnotanabsolutepath
632 if [ $? -eq 0 ]; then
633     echo "This should have failed because thisisnotanabsolutepath is not an absolute path!"
634     exit 1
635 else
636     echo "testing absolute path checker passed"
637 fi
638 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf
639 if [ $? -eq 0 ]; then
640     echo "This should have failed because the path does not end with 'fdroid'!"
641     exit 1
642 else
643     echo "testing dirname exists checker passed"
644 fi
645 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid
646 if [ $? -eq 0 ]; then
647     echo "This should have failed because the dirname path does not exist!"
648     exit 1
649 else
650     echo "testing dirname exists checker passed"
651 fi
652 set -e
653
654
655 #------------------------------------------------------------------------------#
656 echo_header "setup a new repo from scratch using ANDROID_HOME and do a local sync"
657
658 REPOROOT=`create_test_dir`
659 cd $REPOROOT
660 fdroid_init_with_prebuilt_keystore
661 copy_apks_into_repo $REPOROOT
662 $fdroid update --create-metadata --verbose
663 $fdroid readmeta
664 grep -F '<application id=' repo/index.xml > /dev/null
665
666 LOCALCOPYDIR=`create_test_dir`/fdroid
667 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
668 NEWREPOROOT=`create_test_dir`
669 cd $NEWREPOROOT
670 fdroid_init_with_prebuilt_keystore
671 echo "sync_from_local_copy_dir = True" >> config.py
672 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
673
674
675 #------------------------------------------------------------------------------#
676 # check that --android-home fails when dir does not exist or is not a dir
677
678 REPOROOT=`create_test_dir`
679 KEYSTORE=$REPOROOT/keystore.jks
680 cd $REPOROOT
681 set +e
682 $fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
683 if [ $? -eq 0 ]; then
684     echo "This should have failed because /opt/fakeandroidhome does not exist!"
685     exit 1
686 else
687     echo "testing android-home path checker passed"
688 fi
689 TESTFILE=`create_test_file`
690 $fdroid init --keystore $KEYSTORE --android-home $TESTFILE
691 if [ $? -eq 0 ]; then
692     echo "This should have failed because $TESTFILE is a file not a dir!"
693     exit 1
694 else
695     echo "testing android-home not-dir checker passed"
696 fi
697 set -e
698
699
700 #------------------------------------------------------------------------------#
701 echo_header "check that fake android home passes 'fdroid init'"
702
703 REPOROOT=`create_test_dir`
704 FAKE_ANDROID_HOME=`create_test_dir`
705 create_fake_android_home $FAKE_ANDROID_HOME
706 KEYSTORE=$REPOROOT/keystore.jks
707 cd $REPOROOT
708 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
709
710
711 #------------------------------------------------------------------------------#
712 echo_header "check that 'fdroid init' fails when build-tools cannot be found"
713
714 if [ -e /usr/bin/aapt ]; then
715     echo "/usr/bin/aapt exists, not running test"
716 else
717     REPOROOT=`create_test_dir`
718     FAKE_ANDROID_HOME=`create_test_dir`
719     create_fake_android_home $FAKE_ANDROID_HOME
720     rm -f $FAKE_ANDROID_HOME/build-tools/*/aapt
721     KEYSTORE=$REPOROOT/keystore.jks
722     cd $REPOROOT
723     set +e
724     $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
725     [ $? -eq 0 ] && exit 1
726     set -e
727 fi
728
729
730 #------------------------------------------------------------------------------#
731 echo_header "check that --android-home overrides ANDROID_HOME"
732
733 REPOROOT=`create_test_dir`
734 FAKE_ANDROID_HOME=`create_test_dir`
735 create_fake_android_home $FAKE_ANDROID_HOME
736 KEYSTORE=$REPOROOT/keystore.jks
737 cd $REPOROOT
738 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
739 set +e
740 grep $FAKE_ANDROID_HOME $REPOROOT/config.py
741 if [ $? -ne 0 ]; then
742     echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
743     exit 1
744 fi
745 set -e
746
747
748 #------------------------------------------------------------------------------#
749 # In this case, ANDROID_HOME is set to a fake, non-working version that will
750 # be detected by fdroid as an Android SDK install.  It should use the path set
751 # by --android-home over the one in ANDROID_HOME, therefore if it uses the one
752 # in ANDROID_HOME, it won't work because it is a fake one.  Only
753 # --android-home provides a working one.
754 echo_header "setup a new repo from scratch with keystore and android-home set on cmd line"
755
756 REPOROOT=`create_test_dir`
757 KEYSTORE=$REPOROOT/keystore.jks
758 FAKE_ANDROID_HOME=`create_test_dir`
759 create_fake_android_home $FAKE_ANDROID_HOME
760 STORED_ANDROID_HOME=$ANDROID_HOME
761 unset ANDROID_HOME
762 echo "ANDROID_HOME: $ANDROID_HOME"
763 cd $REPOROOT
764 $fdroid init --keystore $KEYSTORE --android-home $STORED_ANDROID_HOME --no-prompt
765 test -e $KEYSTORE
766 copy_apks_into_repo $REPOROOT
767 $fdroid update --create-metadata --verbose
768 $fdroid readmeta
769 grep -F '<application id=' repo/index.xml > /dev/null
770 test -e repo/index.xml
771 test -e repo/index.jar
772 test -e repo/index-v1.jar
773 test -e tmp/apkcache
774 ! test -z tmp/apkcache
775 export ANDROID_HOME=$STORED_ANDROID_HOME
776
777
778 #------------------------------------------------------------------------------#
779 echo_header "check duplicate files are properly handled by fdroid update"
780
781 REPOROOT=`create_test_dir`
782 cd $REPOROOT
783 fdroid_init_with_prebuilt_keystore
784 mkdir $REPOROOT/metadata
785 cp -a $WORKSPACE/tests/metadata/obb.mainpatch.current.txt $REPOROOT/metadata
786 echo "accepted_formats = ['txt']" >> config.py
787 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619.apk $REPOROOT/repo/
788 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619_another-release-key.apk $REPOROOT/repo/
789 $fdroid update --pretty
790 grep -F 'obb.mainpatch.current_1619.apk' repo/index.xml repo/index-v1.json
791 grep -F 'obb.mainpatch.current_1619_another-release-key.apk' repo/index-v1.json
792 ! grep -F 'obb.mainpatch.current_1619_another-release-key.apk' repo/index.xml
793 # die if there are exact duplicates
794 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619.apk $REPOROOT/repo/duplicate.apk
795 ! $fdroid update
796
797
798 #------------------------------------------------------------------------------#
799 echo_header "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
800
801 REPOROOT=`create_test_dir`
802 cd $REPOROOT
803 mkdir repo
804 copy_apks_into_repo $REPOROOT
805 fdroid_init_with_prebuilt_keystore
806 $fdroid update --create-metadata --verbose
807 $fdroid readmeta
808 grep -F '<application id=' repo/index.xml > /dev/null
809
810
811 #------------------------------------------------------------------------------#
812 echo_header "setup a new repo from scratch and generate a keystore"
813
814 REPOROOT=`create_test_dir`
815 KEYSTORE=$REPOROOT/keystore.jks
816 cd $REPOROOT
817 $fdroid init --keystore $KEYSTORE
818 test -e $KEYSTORE
819 copy_apks_into_repo $REPOROOT
820 $fdroid update --create-metadata --verbose
821 $fdroid readmeta
822 test -e repo/index.xml
823 test -e repo/index.jar
824 test -e repo/index-v1.jar
825 test -e tmp/apkcache
826 ! test -z tmp/apkcache
827 grep -F '<application id=' repo/index.xml > /dev/null
828
829
830 #------------------------------------------------------------------------------#
831 echo_header "setup a new repo manually and generate a keystore"
832
833 REPOROOT=`create_test_dir`
834 KEYSTORE=$REPOROOT/keystore.jks
835 cd $REPOROOT
836 cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/
837 ! test -e $KEYSTORE
838 set +e
839 $fdroid update
840 if [ $? -eq 0 ]; then
841     echo "This should have failed because this repo has no keystore!"
842     exit 1
843 else
844     echo '`fdroid update` prompted to add keystore'
845 fi
846 set -e
847 $fdroid update --create-key
848 test -e $KEYSTORE
849 copy_apks_into_repo $REPOROOT
850 $fdroid update --create-metadata --verbose
851 $fdroid readmeta
852 test -e repo/index.xml
853 test -e repo/index.jar
854 test -e repo/index-v1.jar
855 test -e tmp/apkcache
856 ! test -z tmp/apkcache
857 grep -F '<application id=' repo/index.xml > /dev/null
858
859
860 #------------------------------------------------------------------------------#
861 echo_header "setup a new repo from scratch, generate a keystore, then add APK and update"
862
863 REPOROOT=`create_test_dir`
864 KEYSTORE=$REPOROOT/keystore.jks
865 cd $REPOROOT
866 $fdroid init --keystore $KEYSTORE
867 test -e $KEYSTORE
868 copy_apks_into_repo $REPOROOT
869 $fdroid update --create-metadata --verbose
870 $fdroid readmeta
871 test -e repo/index.xml
872 test -e repo/index.jar
873 test -e repo/index-v1.jar
874 grep -F '<application id=' repo/index.xml > /dev/null
875 test -e $REPOROOT/repo/info.guardianproject.urzip_100.apk || \
876     cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
877 $fdroid update --create-metadata --verbose
878 $fdroid readmeta
879 test -e repo/index.xml
880 test -e repo/index.jar
881 test -e repo/index-v1.jar
882 test -e tmp/apkcache
883 ! test -z tmp/apkcache
884 grep -F '<application id=' repo/index.xml > /dev/null
885
886
887 #------------------------------------------------------------------------------#
888 echo_header "setup a new repo from scratch with a HSM/smartcard"
889 REPOROOT=`create_test_dir`
890 cd $REPOROOT
891 $fdroid init --keystore NONE
892 test -e opensc-fdroid.cfg
893 test ! -e NONE
894
895
896 #------------------------------------------------------------------------------#
897 echo_header "setup a new repo with no keystore, add APK, and update"
898
899 REPOROOT=`create_test_dir`
900 KEYSTORE=$REPOROOT/keystore.jks
901 cd $REPOROOT
902 touch fdroid-icon.png
903 mkdir repo
904 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
905 set +e
906 $fdroid update --create-metadata --verbose
907 if [ $? -eq 0 ]; then
908     echo "This should have failed because this repo has no keystore!"
909     exit 1
910 else
911     echo '`fdroid update` prompted to add keystore'
912 fi
913 set -e
914
915 # now set up fake, non-working keystore setup
916 touch $KEYSTORE
917 echo "keystore = \"$KEYSTORE\"" >> config.py
918 echo 'repo_keyalias = "foo"' >> config.py
919 echo 'keystorepass = "foo"' >> config.py
920 echo 'keypass = "foo"' >> config.py
921 set +e
922 $fdroid update --create-metadata --verbose
923 if [ $? -eq 0 ]; then
924     echo "This should have failed because this repo has a bad/fake keystore!"
925     exit 1
926 else
927     echo '`fdroid update` prompted to add keystore'
928 fi
929 set -e
930
931
932 #------------------------------------------------------------------------------#
933 echo_header "copy tests/repo, update with binary transparency log"
934
935 REPOROOT=`create_test_dir`
936 GIT_REMOTE=`create_test_dir`
937 GNUPGHOME=$REPOROOT/gnupghome
938 cd $REPOROOT
939 fdroid_init_with_prebuilt_keystore
940 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
941 echo "binary_transparency_remote = '$GIT_REMOTE'" >> config.py
942 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
943 $fdroid update --verbose
944 if have_git_2_3; then
945     $fdroid server update --verbose
946     test -e repo/index.xml
947     test -e repo/index.jar
948     test -e repo/index-v1.jar
949     grep -F '<application id=' repo/index.xml > /dev/null
950     cd binary_transparency
951     [ `git rev-list --count HEAD` == "2" ]
952     cd $GIT_REMOTE
953     [ `git rev-list --count HEAD` == "2" ]
954 else
955     echo "Skipping test, `git --version` older than 2.3"
956 fi
957
958
959 #------------------------------------------------------------------------------#
960 echo_header "setup a new repo with keystore with APK, update, then without key"
961
962 REPOROOT=`create_test_dir`
963 KEYSTORE=$REPOROOT/keystore.jks
964 cd $REPOROOT
965 cp $WORKSPACE/tests/keystore.jks $KEYSTORE
966 fdroid_init_with_prebuilt_keystore $KEYSTORE
967 test -e $KEYSTORE
968 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
969 $fdroid update --create-metadata --verbose
970 $fdroid readmeta
971 test -e repo/index.xml
972 test -e repo/index.jar
973 test -e repo/index-v1.jar
974 test -e tmp/apkcache
975 ! test -z tmp/apkcache
976 grep -F '<application id=' repo/index.xml > /dev/null
977
978 # now set fake repo_keyalias
979 $sed -i.tmp 's,^ *repo_keyalias.*,repo_keyalias = "fake",' $REPOROOT/config.py
980 set +e
981 $fdroid update
982 if [ $? -eq 0 ]; then
983     echo "This should have failed because this repo has a bad repo_keyalias!"
984     exit 1
985 else
986     echo '`fdroid update` prompted to add keystore'
987 fi
988 set -e
989
990 # try creating a new keystore, but fail because the old one is there
991 test -e $KEYSTORE
992 set +e
993 $fdroid update --create-key
994 if [ $? -eq 0 ]; then
995     echo "This should have failed because a keystore is already there!"
996     exit 1
997 else
998     echo '`fdroid update` complained about existing keystore'
999 fi
1000 set -e
1001
1002 # now actually create the key with the existing settings
1003 rm -f $KEYSTORE
1004 ! test -e $KEYSTORE
1005 $fdroid update --create-key
1006 test -e $KEYSTORE
1007
1008
1009 #------------------------------------------------------------------------------#
1010 echo_header "sign binary repo in offline box, then publishing from online box"
1011
1012 OFFLINE_ROOT=`create_test_dir`
1013 KEYSTORE=$WORKSPACE/tests/keystore.jks
1014 LOCAL_COPY_DIR=`create_test_dir`/fdroid
1015 mkdir $LOCAL_COPY_DIR
1016 ONLINE_ROOT=`create_test_dir`
1017 SERVERWEBROOT=`create_test_dir`
1018
1019 # create offline binary transparency log
1020 cd $OFFLINE_ROOT
1021 mkdir binary_transparency
1022 cd binary_transparency
1023 git init
1024
1025 # fake git remote server for binary transparency log
1026 BINARY_TRANSPARENCY_REMOTE=`create_test_dir`
1027
1028 # fake git remote server for repo mirror
1029 SERVER_GIT_MIRROR=`create_test_dir`
1030 cd $SERVER_GIT_MIRROR
1031 git init
1032 if have_git_2_3; then
1033     git config receive.denyCurrentBranch updateInstead
1034 fi
1035
1036 cd $OFFLINE_ROOT
1037 fdroid_init_with_prebuilt_keystore
1038 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $OFFLINE_ROOT/
1039
1040 echo "mirrors = ['http://foo.bar/fdroid', 'http://asdflkdsfjafdsdfhkjh.onion/fdroid']" >> config.py
1041 echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
1042 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1043 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
1044 $fdroid update --pretty
1045 grep -F '<application id=' repo/index.xml > /dev/null
1046 grep -F '/fdroid/repo</mirror>' repo/index.xml
1047 grep -F '/fdroid/archive</mirror>' archive/index.xml
1048 test `grep '<mirror>' repo/index.xml | wc -l` -eq 2
1049 test `grep '<mirror>' archive/index.xml | wc -l` -eq 2
1050 cd binary_transparency
1051 [ `git rev-list --count HEAD` == "1" ]
1052 cd ..
1053 $fdroid server update --verbose
1054 grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
1055 cd $ONLINE_ROOT
1056 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1057 echo "sync_from_local_copy_dir = True" >> config.py
1058 echo "serverwebroots = '$SERVERWEBROOT'" >> config.py
1059 echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
1060 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1061 echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
1062 $fdroid server update --verbose
1063 cd $BINARY_TRANSPARENCY_REMOTE
1064 [ `git rev-list --count HEAD` == "1" ]
1065 cd $SERVER_GIT_MIRROR
1066 [ `git rev-list --count HEAD` == "1" ]
1067
1068
1069 #------------------------------------------------------------------------------#
1070
1071 # remove this to prevent git conflicts and complaining
1072 rm -rf $WORKSPACE/fdroidserver.egg-info/
1073
1074 echo SUCCESS