Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python-gnupg version increase breaks unencrypt_file function #460

Closed
chambersh1129 opened this issue Sep 26, 2022 · 3 comments · Fixed by #461
Closed

python-gnupg version increase breaks unencrypt_file function #460

chambersh1129 opened this issue Sep 26, 2022 · 3 comments · Fixed by #461

Comments

@chambersh1129
Copy link
Member

chambersh1129 commented Sep 26, 2022

Bug Report

Describe the bug

Latest version of python-gnupg on PyPi is 0.5.0. The file argument for gnupg.GPG().decrypt_file has changed from "file" to "fileobj_or_path". This is causing tests to fail with error "TypeError: GPG.decrypt_file() got an unexpected keyword argument 'file'".

decrypt_file can be found here.

Failing tests:

  • dbbackup.tests.functional.test_commands.MediaRestoreCommandTest.test_encrypted
  • dbbackup.tests.functional.test_commands.DbRestoreCommandTest.test_encrypted
  • dbbackup.tests.commands.test_dbrestore.DbrestoreCommandRestoreBackupTest.test_decrypt
  • dbbackup.tests.test_utils.Unencrypt_FileTest.test_unencrypt

If tests are failing, decryption of the backups are likely failing to for newer installs.

To Reproduce

  • create a fresh virtual environment
  • install django-dbbackup requirements, including test requirements
  • run tests

Alternatively, in a django project

  • pip install --upgrade python-gnupg
  • make an encrypted backup
  • try to restore backup

Expected behavior

Tests pass, backups are decrypted

Versions

Django-dbbackup

  • pypi: 4.0.1

External tools

  • Python: 3.10
  • Django: 4.1.1
  • OS: Linux, Fedora Silverblue 36
@chambersh1129
Copy link
Member Author

If this gets accepted, I'd like to take a stab at fixing it. Just want some input on whether it is better to compare versions or pin the python-gnupg version in the requirements/tests.txt file.

Compare versions pseudo-code:
`
from pgk_resources import parse_version

if parse_version(gnupg.version) >= parse_version("5.0.0"):
use new fileobj_or_path
else:
use file
`

@Archmonger
Copy link
Contributor

In general, it's best to practice pin the minimum version and keep the max unpinned. I'd be okay with reviewing a PR that supports python-gnupg>=0.5.0.

@chambersh1129
Copy link
Member Author

I'll submit a PR to address this later today, thanks for the input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants