1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00

tests: test moving files to and from the archive

#166
This commit is contained in:
Hans-Christoph Steiner 2017-06-27 23:33:24 +02:00
parent 0d3f4547a9
commit be2926ffc8
10 changed files with 228 additions and 2 deletions

View File

@ -0,0 +1,36 @@
Categories:Time
License:GPL-3.0
Web Site:
Source Code:https://github.com/miguelvps/PoliteDroid
Issue Tracker:https://github.com/miguelvps/PoliteDroid/issues
Auto Name:Polite Droid
Summary:Calendar tool
Description:
Activates silent mode during calendar events.
.
Repo Type:git
Repo:https://github.com/miguelvps/PoliteDroid.git
Build:1.2,3
commit=6a548e4b19
target=android-10
Build:1.3,4
commit=ad865b57bf3ac59580f38485608a9b1dda4fa7dc
target=android-15
Build:1.4,5
commit=456bd615f3fbe6dff06433928cf7ea20073601fb
target=android-10
Build:1.5,6
commit=v1.5
gradle=yes
Archive Policy:4 versions
Auto Update Mode:Version v%v
Update Check Mode:Tags
Current Version:1.5
Current Version Code:6

View File

@ -7,3 +7,4 @@ None
Phone & SMS
Security
System
Time

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -159,6 +159,71 @@
<sig>b4964fd759edaa54e65bb476d0276880</sig>
</package>
</application>
<application id="com.politedroid">
<id>com.politedroid</id>
<added>2017-06-23</added>
<lastupdated>2017-06-23</lastupdated>
<name>Polite Droid</name>
<summary>Calendar tool</summary>
<icon>com.politedroid.6.png</icon>
<desc>&lt;p&gt;Activates silent mode during calendar events.&lt;/p&gt;</desc>
<license>GPL-3.0</license>
<categories>Time</categories>
<category>Time</category>
<web></web>
<source>https://github.com/miguelvps/PoliteDroid</source>
<tracker>https://github.com/miguelvps/PoliteDroid/issues</tracker>
<marketversion>1.5</marketversion>
<marketvercode>6</marketvercode>
<package>
<version>1.5</version>
<versioncode>6</versioncode>
<apkname>com.politedroid_6.apk</apkname>
<hash type="sha256">70c2f776a2bac38a58a7d521f96ee0414c6f0fb1de973c3ca8b10862a009247d</hash>
<size>16578</size>
<sdkver>14</sdkver>
<targetSdkVersion>21</targetSdkVersion>
<added>2017-06-23</added>
<sig>b4964fd759edaa54e65bb476d0276880</sig>
<permissions>READ_CALENDAR,RECEIVE_BOOT_COMPLETED</permissions>
</package>
<package>
<version>1.4</version>
<versioncode>5</versioncode>
<apkname>com.politedroid_5.apk</apkname>
<hash type="sha256">5bdbfa071cca4b8d05ced41d6b28763595d6e8096cca5bbf0f9253c9a2622e5d</hash>
<size>18817</size>
<sdkver>3</sdkver>
<targetSdkVersion>10</targetSdkVersion>
<added>2017-06-23</added>
<sig>b4964fd759edaa54e65bb476d0276880</sig>
<permissions>READ_CALENDAR,RECEIVE_BOOT_COMPLETED</permissions>
</package>
<package>
<version>1.3</version>
<versioncode>4</versioncode>
<apkname>com.politedroid_4.apk</apkname>
<hash type="sha256">c809bdff83715fbf919f3840ee09869b038e209378b906e135ee40d3f0e1f075</hash>
<size>18489</size>
<sdkver>3</sdkver>
<targetSdkVersion>3</targetSdkVersion>
<added>2017-06-23</added>
<sig>b4964fd759edaa54e65bb476d0276880</sig>
<permissions>READ_CALENDAR,READ_EXTERNAL_STORAGE,READ_PHONE_STATE,RECEIVE_BOOT_COMPLETED,WRITE_EXTERNAL_STORAGE</permissions>
</package>
<package>
<version>1.2</version>
<versioncode>3</versioncode>
<apkname>com.politedroid_3.apk</apkname>
<hash type="sha256">665d03d61ebc642289fda697f71a59305b0202b16cafc5ffdae91cbe91f0b25d</hash>
<size>17552</size>
<sdkver>3</sdkver>
<targetSdkVersion>3</targetSdkVersion>
<added>2017-06-23</added>
<sig>b4964fd759edaa54e65bb476d0276880</sig>
<permissions>READ_CALENDAR,READ_EXTERNAL_STORAGE,READ_PHONE_STATE,RECEIVE_BOOT_COMPLETED,WRITE_EXTERNAL_STORAGE</permissions>
</package>
</application>
<application id="info.guardianproject.urzip">
<id>info.guardianproject.urzip</id>
<added>2016-06-23</added>

View File

@ -237,7 +237,119 @@ test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc
# we can't easily reproduce the timestamps for things, so just hardcode them
sed -i --expression='s,timestamp="[0-9]*",timestamp="1480431575",' repo/index.xml
diff $WORKSPACE/tests/repo/index.xml repo/index.xml
diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml
#------------------------------------------------------------------------------#
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
echo "accepted_formats = ['txt']" >> config.py
test -d metadata || mkdir metadata
cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
test -d repo || mkdir repo
cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
sed -i 's,archive_older = [0-9],archive_older = 3,' config.py
$fdroid update --pretty --nosign
test `grep '<package>' archive/index.xml | wc -l` -eq 0
test `grep '<package>' repo/index.xml | wc -l` -eq 4
grep -F com.politedroid_3.apk repo/index.xml
grep -F com.politedroid_4.apk repo/index.xml
grep -F com.politedroid_5.apk repo/index.xml
grep -F com.politedroid_6.apk repo/index.xml
test -e repo/com.politedroid_3.apk
test -e repo/com.politedroid_4.apk
test -e repo/com.politedroid_5.apk
test -e repo/com.politedroid_6.apk
echo "enable one app in the repo"
sed -i 's,^Archive Policy:4,Archive Policy:1,' metadata/com.politedroid.txt
$fdroid update --pretty --nosign
test `grep '<package>' archive/index.xml | wc -l` -eq 3
test `grep '<package>' repo/index.xml | wc -l` -eq 1
grep -F com.politedroid_3.apk archive/index.xml
grep -F com.politedroid_4.apk archive/index.xml
grep -F com.politedroid_5.apk archive/index.xml
grep -F com.politedroid_6.apk repo/index.xml
test -e archive/com.politedroid_3.apk
test -e archive/com.politedroid_4.apk
test -e archive/com.politedroid_5.apk
test -e repo/com.politedroid_6.apk
#------------------------------------------------------------------------------#
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
echo "accepted_formats = ['txt']" >> config.py
test -d metadata || mkdir metadata
cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
sed -i '/Archive Policy:/d' metadata/com.politedroid.txt
test -d repo || mkdir repo
cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
sed -i 's,archive_older = [0-9],archive_older = 3,' config.py
$fdroid update --pretty --nosign
test `grep '<package>' archive/index.xml | wc -l` -eq 1
test `grep '<package>' repo/index.xml | wc -l` -eq 3
grep -F com.politedroid_3.apk archive/index.xml
grep -F com.politedroid_4.apk repo/index.xml
grep -F com.politedroid_5.apk repo/index.xml
grep -F com.politedroid_6.apk repo/index.xml
test -e archive/com.politedroid_3.apk
test -e repo/com.politedroid_4.apk
test -e repo/com.politedroid_5.apk
test -e repo/com.politedroid_6.apk
sed -i 's,archive_older = 3,archive_older = 1,' config.py
$fdroid update --pretty --nosign
test `grep '<package>' archive/index.xml | wc -l` -eq 3
test `grep '<package>' repo/index.xml | wc -l` -eq 1
grep -F com.politedroid_3.apk archive/index.xml
grep -F com.politedroid_4.apk archive/index.xml
grep -F com.politedroid_5.apk archive/index.xml
grep -F com.politedroid_6.apk repo/index.xml
test -e archive/com.politedroid_3.apk
test -e archive/com.politedroid_4.apk
test -e archive/com.politedroid_5.apk
test -e repo/com.politedroid_6.apk
# disabling deletes from the archive
sed -i 's/Build:1.3,4/Build:1.3,4\n disable=testing deletion/' metadata/com.politedroid.txt
$fdroid update --pretty --nosign
test `grep '<package>' archive/index.xml | wc -l` -eq 2
test `grep '<package>' repo/index.xml | wc -l` -eq 1
grep -F com.politedroid_3.apk archive/index.xml
! grep -F com.politedroid_4.apk archive/index.xml
grep -F com.politedroid_5.apk archive/index.xml
grep -F com.politedroid_6.apk repo/index.xml
test -e archive/com.politedroid_3.apk
! test -e archive/com.politedroid_4.apk
test -e archive/com.politedroid_5.apk
test -e repo/com.politedroid_6.apk
# disabling deletes from the repo, and promotes one from the archive
sed -i 's/Build:1.5,6/Build:1.5,6\n disable=testing deletion/' metadata/com.politedroid.txt
$fdroid update --pretty --nosign
test `grep '<package>' archive/index.xml | wc -l` -eq 1
test `grep '<package>' repo/index.xml | wc -l` -eq 1
grep -F com.politedroid_3.apk archive/index.xml
grep -F com.politedroid_5.apk repo/index.xml
! grep -F com.politedroid_6.apk repo/index.xml
test -e archive/com.politedroid_3.apk
test -e repo/com.politedroid_5.apk
! test -e repo/com.politedroid_6.apk
#------------------------------------------------------------------------------#

View File

@ -1,3 +1,7 @@
com.politedroid_3.apk repo/com.politedroid 2017-06-23
com.politedroid_4.apk repo/com.politedroid 2017-06-23
com.politedroid_5.apk repo/com.politedroid 2017-06-23
com.politedroid_6.apk repo/com.politedroid 2017-06-23
fake.ota.update_1234.zip fake.ota.update 2016-03-10
obb.main.oldversion_1444412523.apk obb.main.oldversion 2013-12-31
obb.main.twoversions_1101613.apk obb.main.twoversions 2015-10-12

View File

@ -205,8 +205,16 @@ class UpdateTest(unittest.TestCase):
apps = fdroidserver.metadata.read_metadata(xref=True)
knownapks = fdroidserver.common.KnownApks()
apks, cachechanged = fdroidserver.update.scan_apks({}, 'repo', knownapks, False)
self.assertEqual(len(apks), 7)
self.assertEqual(len(apks), 11)
apk = apks[0]
self.assertEqual(apk['packageName'], 'com.politedroid')
self.assertEqual(apk['versionCode'], 3)
self.assertEqual(apk['minSdkVersion'], '3')
self.assertEqual(apk['targetSdkVersion'], '3')
self.assertFalse('maxSdkVersion' in apk)
apk = apks[4]
self.assertEqual(apk['packageName'], 'obb.main.oldversion')
self.assertEqual(apk['versionCode'], 1444412523)
self.assertEqual(apk['minSdkVersion'], '4')
self.assertEqual(apk['targetSdkVersion'], '18')
self.assertFalse('maxSdkVersion' in apk)