1033 Commits

Author SHA1 Message Date
Hans-Christoph Steiner
8b52740636 use for f in files var name; avoid using keyword as var name 2025-02-13 17:56:30 +01:00
Hans-Christoph Steiner
1720a51e9e replace := walrus operator usages 2025-02-13 17:56:30 +01:00
mindston
1cbd68af84 Ignore bandit insecure usage of tmp dir warnings 2025-02-13 17:56:30 +01:00
mindston
565ae02678 Remove macOS exceptions 2025-02-13 17:56:30 +01:00
mindston
fa4ff197aa Force C.UTF-8 locale for messages instead of en_US.UTF-8 2025-02-13 17:56:30 +01:00
mindston
aeb6c612e9 Set configuration variables for tests that run Git 2025-02-13 17:56:30 +01:00
mindston
96f9d7fdf8 Fix androguard import for versions <4 2025-02-13 17:56:30 +01:00
mindston
385832c1fd Fix usage of removed $WORKSPACE variable in run-tests 2025-02-13 17:56:30 +01:00
mindston
62b4af4f19 Fix UTC timezone import to work on Python <3.11 2025-02-13 17:56:30 +01:00
mindston
9201b3ca94 Migrate integration tests from Bash to Python 2025-02-13 17:56:30 +01:00
Hans-Christoph Steiner
66d220bd9f tests: rename testcommon module to shared_test_code
This name always confuses me, since there is also test_common.py. And this
module is not actually a test suite, even though it starts with "test".
This also makes for better tab completion, e.g.

python3 -m unittest tests/te[Tab] -> tests/test_
2025-01-27 10:11:19 +00:00
Hans-Christoph Steiner
2ac925a249 ban apksigner v33, it has bugs verifying APKs with v3/v3.1 sigs 2025-01-21 15:00:23 +00:00
Hans-Christoph Steiner
9b5a67340e checkupdates: skip test_get_upstream_main_branch on macOS
This test checks the detection of the default initial branch. It is a hard
thing to test since different platform configurations have different
defaults.  checkupdates is basically only used on GNU/Linux anyway.

Here's the failure:
https://gitlab.com/fdroid/fdroidserver/-/jobs/8896420261
2025-01-20 15:37:54 +01:00
Simon Chopin
89a282c12e test_net: figure out the proper IP protocol for localhost
On some systems, localhost is only defined for 127.0.0.1 (e.g. Ubuntu
and Debian containers). However, there is code that hardcodes possible
values for localhost, making it possible to open an IPv6 socket for
localhost.

On those systems, the socket will be open but urllib3 will resolve
localhost *only* to 127.0.0.1, thus failing miserably to connect.

To resolve the situation, rather than defaulting to IPv6 we actually
resolve localhost and use the socket family of the first result. On my
current system (upcoming Ubuntu Plucky) if localhost=::1 is defined in
/etc/hosts it will come up as the first result, if not 127.0.0.1 will.

V2: Use self.port rather than a forgotten hardcoded port.

Fixes: f01628ca6b1b "fix localhost network tests on systems with IPv6"
2025-01-20 10:33:49 +00:00
Hans-Christoph Steiner
5b1b1d12a1 verify: handle corrupt verified.json
verified.json can get quite large on verification.f-droid.org, and for some
unknown reason, it sometimes corrupts it when writing it out.  All the data
is already available in all the other JSON files, so this just automatically
reconstructs it.  Its a hack, but it took me much less time than I've
already spent trying to troubleshoot why it writes out corrupt verified.json.
2025-01-20 09:48:20 +00:00
Hans-Christoph Steiner
20caa6fa1c match the full file name when looking for the v1 signature block
ZipFile.namelist() produces a string per file.  The filename could contain
newline chars, including at the beginning and end.  ^$ in regex matches
around newline chars.  \A\Z matches the beginning/end of the full string.

This is exactly the same as obfusk's r'\AMETA-INF/(?s:.)*\.(DSA|EC|RSA)\Z'
but in a readable format that is also easily searchable, and standard for
this code base.

https://github.com/obfusk/fdroid-fakesigner-poc/blob/master/fdroidserver-regex.patch

#1251
2025-01-15 14:45:35 +01:00
Hans-Christoph Steiner
f01628ca6b fix localhost network tests on systems with IPv6
Thanks to themill from Debian for this suggestion:

> https://docs.python.org/3/library/socket.html#socket.socket makes me
> think socket.socket has done an ipv4 only but urilib3 will do
> whatever localhost resolves to.  I suspect the test code should be
> using socket.create_server - there's an example at
> https://docs.python.org/3/library/socket.html#socket.create_server
2024-12-12 15:19:58 +00:00
Hans-Christoph Steiner
5fde2f4d03
replace deprecated pkg_resources.get_distribution() from setuptools
This should fix the CI error for macOS and reduce technical debt.
https://gitlab.com/fdroid/fdroidserver/-/jobs/8542884186
2024-12-06 12:26:37 +01:00
Hans-Christoph Steiner
0ec9cd6921 checkupdates: only update app branches if metadata file changed 2024-11-21 12:15:14 +00:00
Hans-Christoph Steiner
e3f724681a checkupdates: parse default branch from upstream remote 2024-11-21 12:15:14 +00:00
Hans-Christoph Steiner
c97503b5f3 checkupdates: get default branch from git config 2024-11-21 12:15:14 +00:00
Hans-Christoph Steiner
cd8d4ef88b checkupdates: reuse per-app branches when making merge requests
https://gitlab.com/fdroid/fdroidserver/-/merge_requests/1551#note_2206085258
2024-11-21 12:15:14 +00:00
Hans-Christoph Steiner
20ff302e89 checkupdates: remove duplicate push in push_commits() 2024-11-21 12:15:14 +00:00
Hans-Christoph Steiner
487269c667 tests: standardize on VerboseFalseOptions as mock 2024-11-20 10:46:21 +01:00
SilentGhost
7ff32bc4b0 Refactor TestCase files into python modules
Convert all TestCase files into standard python modules to be run and
discovered by unittest.
2024-11-20 10:37:52 +01:00
Hans-Christoph Steiner
65119b3193 rename to test_gradlew-fdroid to match Python unittest naming 2024-11-19 20:27:29 +01:00
Hans-Christoph Steiner
ad66baa266 net: skip test in CI that mysteriously fails there
I couldn't figure out why it is failing there.
2024-11-08 17:49:15 +02:00
Hans-Christoph Steiner
85e585161f net: use localhost instead of IP for both sides of test setup 2024-11-08 17:49:15 +02:00
Hans-Christoph Steiner
90eeb63809 net: ignore proxy env vars, tests only use localhost
Proxy settings via environment variables can interfere with this
test. The requests library will automatically pick up proxy
settings from environment variables. Proxy settings can force the
local connection over the proxy, which might not support that,
then this fails with an error like 405 or others.
2024-11-08 17:49:14 +02:00
Hans-Christoph Steiner
acae5f1ac9 tests/run-tests: stop skipping install.TestCase 2024-11-01 00:57:45 +01:00
Hans-Christoph Steiner
4d22a7f67f install: Y/n prompt, --yes, --no controls downloading F-Droid.apk 2024-11-01 00:34:03 +01:00
Hans-Christoph Steiner
560472e4e5 install: download from GitHub Releases 2024-11-01 00:16:13 +01:00
Hans-Christoph Steiner
1eb6516f16 install: add IPNS download method 2024-11-01 00:09:58 +01:00
Hans-Christoph Steiner
3da48e64bc install: use Maven Central as additional source 2024-11-01 00:09:58 +01:00
Hans-Christoph Steiner
b77eba824b install: convert to common.get_config() 2024-11-01 00:09:54 +01:00
Hans-Christoph Steiner
c7bc8d0fea install: function to fetch, verify and install the F-Droid.apk 2024-10-31 23:49:30 +01:00
Hans-Christoph Steiner
681d705da0 install: reliable algorithm for picking devices from adb output
Versions of this algorithm are used elsewhere:
* https://github.com/openatx/adbutils/blob/master/adbutils/_adb.py
2024-10-31 21:55:20 +01:00
Hans-Christoph Steiner
f1b110942a net: let localhost RetryServer tests run with an HTTP proxy active 2024-10-31 21:55:20 +01:00
Hans-Christoph Steiner
59fcfa5dec index: download_repo_index_v2() uses mirrors
test_download_repo_index_v2_url_parsing is no longer needed, since all the
things it tested are now handled in test_download_repo_index_v2
2024-10-31 21:55:18 +01:00
Hans-Christoph Steiner
2e3f6d273a net: download_using_mirrors() to download like fdroidclient does 2024-10-31 21:54:47 +01:00
Hans-Christoph Steiner
49dcc53076 install: download_fdroid_apk() to fetch the recommended initial APK 2024-10-31 21:54:47 +01:00
Hans-Christoph Steiner
56bed02a29 install: download_apk() fetchs APKs by appid based on the index 2024-10-31 21:54:45 +01:00
Hans-Christoph Steiner
173c1d67f4 KnownApks: appid is no longer needed at all, remove it. 2024-10-31 09:20:26 +00:00
Hans-Christoph Steiner
5032207da0 add basic tests of KnownApks mechanism
The tests in tests/run-tests do provide coverage for these cases, but it is
not explicit, but just comes from testing that the index file has not
changed.  These tests make it explicit what is being tested.
2024-10-31 09:20:26 +00:00
Jochen Sprickerhof
81c0c9d4aa Drop stats/known_apks.txt
Use repo/index-v2.json instead.
Also fix deprecated datetime.utcnow().
2024-10-31 09:20:26 +00:00
Hans-Christoph Steiner
25779e8b32 checkupdates: --merge_request commits to branch named after appid 2024-10-30 18:35:34 +01:00
Hans-Christoph Steiner
9a34590e95 checkupdates: make merge-request per appid on push 2024-10-30 14:43:45 +00:00
Hans-Christoph Steiner
66a340fe89 checkupdates: add --verbose progress to push_commits() 2024-10-30 14:43:45 +00:00
Hans-Christoph Steiner
206f07364b checkupdates: remove appid branches that have been merged
To avoid having thousands of branches on checkupdatess-bot's remote, this
cleans up any remote branches that are pointing to commit that has been
fully merged.
2024-10-30 14:43:45 +00:00
Hans-Christoph Steiner
78b368f88b enforce black code format for tests/checkupdates.TestCase 2024-10-30 14:43:45 +00:00