Commit Graph

907 Commits

Author SHA1 Message Date
Hans-Christoph Steiner 5745ed4753 common: only try to delete .testfiles dir if it exists
Otherwise, some tests fail with an error.
2024-05-08 16:28:14 +02:00
Hans-Christoph Steiner 18f3acc32e split out options from read_config()
There is no longer any reason for these to be intertwined.

This deliberately avoids touching some files as much as possible because
they are super tangled and due to be replaced.  Those files are:

* fdroidserver/build.py
* fdroidserver/update.py

# Conflicts:
#	tests/testcommon.py

# Conflicts:
#	fdroidserver/btlog.py
#	fdroidserver/import_subcommand.py
2024-05-08 16:26:46 +02:00
Hans-Christoph Steiner 685efa23d4 import: always load testcommon from localmodule
Having this import before sys.path.insert() made it load testcommon from
the Debian package.
2024-05-08 16:19:27 +02:00
Hans-Christoph Steiner 1e5699e90c remove all references to optparse (deprecated since Python 3.2) 2024-05-08 16:19:27 +02:00
Hans-Christoph Steiner 717df09be0 clarify that config/options can be global or module-level variable 2024-05-08 16:19:27 +02:00
Hans-Christoph Steiner 8208841460 common: make explicit which test cases need mocked options 2024-05-08 16:19:27 +02:00
Hans-Christoph Steiner ad9f0a9022 include @obfusk's proof-of-concept APKs in test suite
https://github.com/obfusk/fdroid-fakesigner-poc/releases/tag/poc-apks
2024-05-07 16:22:59 +02:00
Hans-Christoph Steiner fc4a9c96a5 test APK signatures with a cert chain are parsed like apksigner
Microsoft and SanDisk sign APKs with a X.509 certificate chain of
trust, so there are actually three certificates included. apksigner
only cares about one certificate and ignores the other certificates in
the chain.

The correct values come from:

    apksigner verify --print-certs 883cbdae7aeb2e4b122e8ee8d89966c7062d0d49107a130235fa220a5b994a79.apk

X.509 certificates are machine generated and just data, so are not
copyrightable.  So I included SANAPPSI.* directly.
2024-05-07 16:22:59 +02:00
Hans-Christoph Steiner accdd65f91 also handle APKs entirely without JAR/v1 signatures
future-proofing!
2024-05-07 16:22:59 +02:00
Hans-Christoph Steiner 9a327b5097 reliable implementation of get_first_signer_certificate()
This keeps key pieces of @linsui's algorithm, specifically the check
that all certificates are the same.  apksigner also does this check.

closes #1128
2024-05-07 16:22:59 +02:00
Hans-Christoph Steiner 1b65e33835 make it easy to keep test artifacts from jobs
When troubleshooting things that are difficult to reproduce locally, like
different behaviors in the fedora_latest job, these changes make it easy to
keep the test files around after the tests run.  For example, if PNGs are
processed differently by newer Python versions.
2024-05-07 12:58:23 +00:00
Hans-Christoph Steiner 299e3e5f4c index: handle image processing diffs across various Python versions
Apparently, the newest Python thingies strip the PNGs a tiny bit smaller,
so a fixed file size will lead to the test failing:

https://gitlab.com/fdroid/fdroidserver/-/jobs/6703386074
```
Traceback (most recent call last):
  File "/builds/fdroid/fdroidserver/tests/index.TestCase", line 704, in test_package_metadata
    self.assertEqual(36027, metadata['featureGraphic']['en-US']['size'])
AssertionError: 36027 != 35619
```
2024-05-07 12:58:23 +00:00
Hans-Christoph Steiner 9a9b5beeaa simplify test setup
I'm in the midst of working towards getting rid of the "config" instances
that are in the subcommand module, e.g. `fdroidserver.lint.config`
2024-05-07 11:33:04 +00:00
Hans-Christoph Steiner 14c8647909 add additional tests 2024-05-07 11:33:04 +00:00
linsui d243cbd030 lint: blocklist known AOSP debug keys in AASK 2024-05-07 11:33:04 +00:00
Hans-Christoph Steiner 5b7abc0423 single function to tame androguard's verbose default output
# Conflicts:
#	fdroidserver/common.py
2024-04-25 12:39:12 +02:00
Hans-Christoph Steiner 7a144a4762 port to androguard >= 4 and drop support for older than 3.3.3
This also makes androguard a hard requirement, which has been true for a
while anyway.  So the code that handles androguard as an optional
requirement is removed.  androguard from Debian/buster is new enough, so
this does not seem like it will cause any problems.
2024-04-25 12:39:12 +02:00
Hans-Christoph Steiner cdc7c98707 common.get_androguard_APK() is no longer private to the module 2024-04-25 12:39:12 +02:00
Michael Pöhn bd6afa4365
🐛 index fix: skip altstore when no IPAs present 2024-04-24 12:45:29 +02:00
Michael Pöhn d00a87ed6c
🏏 alt-store index: incorporate review feedback 2024-04-23 17:28:30 +02:00
Michael Pöhn f2118b35a3
🏟️ fix ci 2024-04-23 16:06:10 +02:00
Michael Pöhn 45efb88f85
🕴️ add test for make_altstore 2024-04-23 16:05:58 +02:00
Michael Pöhn 86db8c93cc
🩹 fix parse_ipa tests 2024-04-23 16:05:47 +02:00
Michael Pöhn f742799a9d
🏟️ add test for _parse_from_pbxproj
Also fix lint issues
2024-04-23 16:05:34 +02:00
Michael Pöhn 450765490b
🗺️ add test for _get_ipa_ico 2024-04-23 16:05:22 +02:00
Michael Pöhn 6152abee08 🪀 tests for insert_localized_ios_app_metadata
Split some functions from insert_localized_ios_app_metadata into
sub-functions and implemented separate tests for each.
2024-04-03 14:55:35 +00:00
Michael Pöhn bbf17ee59c 🧆 improve and test parse_ios_screenshot_name 2024-04-03 14:55:35 +00:00
Michael Pöhn 293caf5ff9 🪪 iOS fastlane screenshot support 2024-04-03 14:55:35 +00:00
Hans-Christoph Steiner 9c65bed4a5 check for <application android:testOnly="true">
This adds a check for "testOnly" to the existing "debuggable" check, since
they are very similar.  We should really be refactoring all the checks into
a more reasonable setup.  Since "debuggable" and "testOnly" are both set in
the same place (`<application>` in _AndroidManifest.xml_) and are both set
by the same process (running debug builds), I thought it would be OK to
include both in the same place.  Plus it was a one-line change.
2024-04-03 13:47:04 +00:00
Hans-Christoph Steiner e269e41b12
publish: --error-on-failed to exit when signing/verifying fails
Since we have limited visibility into @CiaranG's signing server, it is hard
to make changes to the publishing process, especially ones that might break
@CiaranG's automation.  So `fdroid publish` mostly reports success by
moving an APK from unsigned/ to repo/.  In some cases, we want immediate
failure, like in CI.  So this adds `--error-on-failed` for that purpose.
2024-04-03 15:33:18 +02:00
proletarius101 ac4694fcd3
fix `Could not initialize class org.codehaus.groovy.runtime.InvokerHelper`
https://gitlab.com/proletarius101/fdroidserver/-/jobs/6068794117#L547
2024-03-14 13:14:41 +01:00
proletarius101 f2bdf5214a
install openjdk 11 from bullseye repo instead in the test cases 2024-03-14 13:14:41 +01:00
proletarius101 0a3f785254
drop gradle support before 7.3
debian bookworm supports only Java 17+, which is compatible with gradle 7.3+: https://docs.gradle.org/current/userguide/compatibility.html
2024-03-14 13:14:41 +01:00
proletarius101 a0a766cc8e
drop gradle support before 2.0
debian bullseye supports only Java 8+, which is compatible with gradle 2.0+: https://docs.gradle.org/current/userguide/compatibility.html
2024-03-14 13:14:41 +01:00
linsui a002e46997 scanner: update maven repo regex 2024-03-12 07:57:11 +00:00
Hans-Christoph Steiner cff3364fdf split out mirrors data structure into standalone, tested function 2024-03-06 13:31:46 +00:00
Hans-Christoph Steiner 9749282b44 net: fix test_download_file_url_parsing
self.assertTrue(requests_get.called) will always be true because .called
will contain a MagicMock instance.
2024-03-06 13:31:46 +00:00
Hans-Christoph Steiner 7904f12d05 net: add test of automatic retries in download_file()
The existing logic from d1ddd525c in !1225 is confusing because it adds its
own retry loop on top of the retry mechanism that is built into requests.
So this test confirms that setting `download_file(retries=3)` actually
results in more than three retries.
2024-03-06 13:31:46 +00:00
Hans-Christoph Steiner 074dda4b61 use tiny entry.jar rather than large index-v1.jar for net test case 2024-03-06 13:31:46 +00:00
Hans-Christoph Steiner 261be20109 convert tests/testcommon.py to black code format 2024-03-06 13:31:46 +00:00
Nitai Sasson 8931e038d6 add 'non-changeable' to NonFreeNet description 2024-02-21 17:13:58 +01:00
proletarius101 947217549a feat: add servergitmirrors as a dict support 2024-02-14 16:50:39 +00:00
Hans-Christoph Steiner 031a130395 scanner: add refresh_config config item for buildserver
Includes some cosmetic changes from black.
2024-01-25 17:04:38 +01:00
Hans-Christoph Steiner d6aa3caaca
scanner: test of --refresh controls triggering a refresh 2024-01-25 14:03:46 +01:00
Hans-Christoph Steiner 1d9ec42758 scanner: update test counts based on new default rules
The new rules announce more things.
2024-01-25 12:31:05 +01:00
Hans-Christoph Steiner 681392d8c2 scanner: script to update default rules from SUSS 2024-01-25 11:51:22 +01:00
Hans-Christoph Steiner 810387a009 deploy: update_serverwebroots() for testable logic
This moves all of the serverwebroot: logic into a function, and adds tests.
I did this because I ran into issues in the logic in main():

Traceback (most recent call last):
  File "/builds/eighthave/fdroidserver/fdroid", line 22, in <module>
    fdroidserver.__main__.main()
  File "/builds/eighthave/fdroidserver/fdroidserver/__main__.py", line 230, in main
    raise e
  File "/builds/eighthave/fdroidserver/fdroidserver/__main__.py", line 211, in main
    mod.main()
  File "/builds/eighthave/fdroidserver/fdroidserver/deploy.py", line 753, in main
    s = serverwebroot.rstrip('/').split(':')
AttributeError: 'dict' object has no attribute 'rstrip'
2024-01-23 18:49:12 +01:00
Hans-Christoph Steiner fbf097d390 deploy: update_serverwebroot() works w/o options/config
Since update_serverwebroot() is part of the public API, this function should
work without setting `fdroidserver.deploy.options` or
`fdroidserver.deploy.config`.
2024-01-23 17:48:47 +01:00
Hans-Christoph Steiner 7a656d45e3 config: convert serverwebroot: to list-of-dicts format
This allows for more metadata about the server and deploy mode.
2024-01-22 22:11:49 +01:00
Hans-Christoph Steiner 3f50372d8d config: test cases for serverwebroot: with string and list 2024-01-22 22:11:49 +01:00