Skip to content

Commit 15114f7

Browse files
joschjo-so-nxJPEWdev
authored
tests/test_CLI.py: create $GNUPGHOME on the fly (#31)
* tests/test_CLI.py: create $GNUPGHOME on the fly - avoid expiration of keys by re-creating them - prevent gnupg version being incompatible with $GNUPGHOME in git Storing binary data is bad because: - git is not good at handling binary data - binary data is harder to inspect (remember the xz incident) * TransRead.read: pass on -1 instead of 0xFFFFFFFFFFFFFFFF Passing 0xFFFFFFFFFFFFFFFF to read causes python to complain about: OverflowError: cannot fit 'int' into an index-sized integer Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de> * tests: Rework CLI tests The current tests do not take into account whether the `gpg` package has been installed or not. If it is missing, the tests should be skipped. Furthermore, the output of the tests must be checked in order to decide whether tests fail due to an exception or whether the desired error message is displayed. Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de> * CLI: rework PGP verification The verification of PGP signatures had some flaws and didn't work, because the Python API and the GPG interface have changed. Inline signatures were not detected, because of a comparison of string and byte array. And even after this the code failed, because `sig.status` is no longer available. Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de> * tests/test_CLI.py: factor out verification logic into its own function * add gpg verification methods using gpg and gpgv binaries * ci: Fix GPG tests Fixes up the way that the GPG tests work by adding a new "native" python test version. This is required because the python 'gpg' module *must* come from the host package in order to patch libgpgme (e.g. 'python3-gpg'). It's not possible to get this module installed with the pre-canned python versions provided by GitHub Actions, so the gpg tests are skipped for this version, but using the host native python can. --------- Signed-off-by: Jörg Sommer <joerg.sommer@navimatix.de> Co-authored-by: Jörg Sommer <joerg.sommer@navimatix.de> Co-authored-by: Joshua Watt <JPEWhacker@gmail.com>
1 parent 1f54211 commit 15114f7

15 files changed

+295
-393
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,40 @@ jobs:
1616
- "3.10"
1717
- "3.11"
1818
- "3.12"
19+
# Testing with native host python is required in order to test the
20+
# GPG code, since it must use the host python3-gpg package
21+
- "native"
1922
steps:
2023
- uses: actions/checkout@v4
21-
- name: Setup Python ${{ matrix.python-version }}
24+
25+
- if: matrix.python-version != 'native'
26+
name: Setup Python ${{ matrix.python-version }}
2227
uses: actions/setup-python@v4
2328
with:
2429
python-version: ${{ matrix.python-version }}
30+
31+
- if: matrix.python-version == 'native'
32+
name: Setup Native Python
33+
run: |
34+
sudo apt-get install -y python3 python3-pip libgpgme11-dev python3-gpg
35+
2536
- name: Install dependencies
2637
run: |
27-
sudo apt-get install -y pbzip2 pigz lzop liblz4-tool libgpgme11-dev
28-
python -m pip install --upgrade pip
29-
pip install build
38+
sudo apt-get install -y pbzip2 pigz lzop liblz4-tool
39+
python3 -m pip install --upgrade pip
40+
python3 -m pip install build
41+
3042
- name: Build package
3143
run: |
32-
python -m build
44+
python3 -m build
45+
3346
- name: Install package
3447
run: |
35-
pip install -e .[dev]
48+
python3 -m pip install -e .[dev]
49+
3650
- name: Run tests
3751
run: |
38-
python -m unittest -vb
52+
python3 -m unittest -vb
3953
4054
lint:
4155
runs-on: ubuntu-latest

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ name = "bmaptool"
33
description = "BMAP tools"
44
dynamic = ["version"]
55
dependencies = [
6-
"gpg >= 1.10.0",
6+
# NOTE: gpg is not installed because it must come from the system GPG package
7+
# (e.g. python3-gpg on Ubuntu) and not from PyPi. The PyPi version is very old
8+
# and no longer functions correctly
9+
#"gpg >= 1.10.0",
710
]
811
required-python = ">= 3.8"
912
authors = [

0 commit comments

Comments
 (0)