diff --git a/debexpo/accounts/apps.py b/debexpo/accounts/apps.py index 383c3e76396ff071046f1c6179d1c1fff84660e7..47313a2853b8054dfd083435a125cb17c82ee693 100644 --- a/debexpo/accounts/apps.py +++ b/debexpo/accounts/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class AccountsConfig(AppConfig): - name = 'accounts' + name = 'debexpo.accounts' diff --git a/debexpo/base/apps.py b/debexpo/base/apps.py index 466c3da355a0ac5c43f00dbf3887d27a54eeb514..abe1fba7c875c0093bf7df4439cb394d26837660 100644 --- a/debexpo/base/apps.py +++ b/debexpo/base/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class BaseConfig(AppConfig): - name = 'base' + name = 'debexpo.base' diff --git a/debexpo/bugs/apps.py b/debexpo/bugs/apps.py index 8024aebf76f910994f9407f10b5ecad1587b6792..a36bc29e68145b11cb13356e586e2148346f9275 100644 --- a/debexpo/bugs/apps.py +++ b/debexpo/bugs/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class BugsConfig(AppConfig): - name = 'bugs' + name = 'debexpo.bugs' diff --git a/debexpo/comments/apps.py b/debexpo/comments/apps.py index 23b3934a5910a8563f70870e3a9fa4029317bb21..a795e699779d20987c8845584b050f47e305a0a7 100644 --- a/debexpo/comments/apps.py +++ b/debexpo/comments/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class CommentsConfig(AppConfig): - name = 'comments' + name = 'debexpo.comments' diff --git a/debexpo/importer/apps.py b/debexpo/importer/apps.py index 4b1300e7942cddbe1e9e7ed30eb17118c7c1b526..cd947e8e160ba1454696577ea8fc755dd21febe4 100644 --- a/debexpo/importer/apps.py +++ b/debexpo/importer/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class ImporterConfig(AppConfig): - name = 'importer' + name = 'debexpo.importer' diff --git a/debexpo/importer/tasks.py b/debexpo/importer/tasks.py index 444aef243c2bc9a9a26cccc72a303cb1d6e8e124..8a9da789a27c0deb14392eb8e4d51549c1d648a6 100644 --- a/debexpo/importer/tasks.py +++ b/debexpo/importer/tasks.py @@ -26,7 +26,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from celery.decorators import task +from celery import shared_task from django.conf import settings @@ -34,7 +34,7 @@ from debexpo.importer.models import Importer from debexpo.tools.cache import enforce_unique_instance -@task +@shared_task def importer(): with enforce_unique_instance('importer'): importctl = Importer(settings.UPLOAD_SPOOL) diff --git a/debexpo/keyring/apps.py b/debexpo/keyring/apps.py index f7757a0924e6fe40110d27bb8e8aa05ff4403689..6c769d142834d3d737742f60b8849268fb126d8d 100644 --- a/debexpo/keyring/apps.py +++ b/debexpo/keyring/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class KeyringConfig(AppConfig): - name = 'keyring' + name = 'debexpo.keyring' diff --git a/debexpo/keyring/migrations/0004_set_ecc_size_to_zero.py b/debexpo/keyring/migrations/0004_set_ecc_size_to_zero.py new file mode 100644 index 0000000000000000000000000000000000000000..1017178b17f9b0175827ec9014d1c12e740e237c --- /dev/null +++ b/debexpo/keyring/migrations/0004_set_ecc_size_to_zero.py @@ -0,0 +1,59 @@ +# 0004_set_ecc_size_to_zero.py - Set ECC minimum size to zero +# +# This file is part of debexpo +# https://salsa.debian.org/mentors.debian.net-team/debexpo +# +# Copyright © 2021 Baptiste Beauplat +# +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: +# +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +from django.db import migrations + + +def set_ecc_size_to_zero(apps, schema_editor): + set_ecc_size(apps, schema_editor, 0) + + +def revert_set_ecc_size_to_zero(apps, schema_editor): # pragma: no cover + set_ecc_size(apps, schema_editor, 256) + + +def set_ecc_size(apps, schema_editor, size): + GPGAlgo = apps.get_model('keyring', 'GPGAlgo') + + algo = GPGAlgo.objects.get(name='ed25519') + algo.minimal_size_requirement = size + algo.full_clean() + algo.save() + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('keyring', '0003_fingerprint_uniqueness',), + ] + + operations = [ + migrations.RunPython(set_ecc_size_to_zero, revert_set_ecc_size_to_zero), + ] diff --git a/debexpo/nntp/apps.py b/debexpo/nntp/apps.py index a2d9e8bf00d9ba365ca2ec6a77fee7f01968e382..56ddb3e85f5fd0048b1c19ef7a22a69dd97314d7 100644 --- a/debexpo/nntp/apps.py +++ b/debexpo/nntp/apps.py @@ -29,4 +29,4 @@ from django.apps import AppConfig class NntpConfig(AppConfig): - name = 'nntp' + name = 'debexpo.nntp' diff --git a/debexpo/packages/apps.py b/debexpo/packages/apps.py index 2d566080b9f89222d9ed745c4e4cdbc5b8e9cff7..85ef34272565c654137326404a0caa41b301040e 100644 --- a/debexpo/packages/apps.py +++ b/debexpo/packages/apps.py @@ -29,4 +29,4 @@ from django.apps import AppConfig class PackagesConfig(AppConfig): - name = 'packages' + name = 'debexpo.packages' diff --git a/debexpo/packages/tasks.py b/debexpo/packages/tasks.py index 77d33694f926967fb6395e6a7b39cf0870ef28ea..1c3239c9b380d9190fbc8d34f853b60fcb6fc779 100644 --- a/debexpo/packages/tasks.py +++ b/debexpo/packages/tasks.py @@ -27,7 +27,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from celery.decorators import task +from celery import shared_task from datetime import timedelta, datetime, timezone from logging import getLogger from debian.deb822 import Changes @@ -97,7 +97,7 @@ def remove_uploads(uploads): return removals -@task +@shared_task def remove_old_uploads(): expiration_date = datetime.now(timezone.utc) - \ timedelta(weeks=settings.MAX_AGE_UPLOAD_WEEKS) @@ -128,7 +128,7 @@ def notify_uploaders(removals, reason): reason=reason) -@task +@shared_task def remove_uploaded_packages(client=None): uploads_to_archive = set() uploads_to_new = set() diff --git a/debexpo/plugins/apps.py b/debexpo/plugins/apps.py index 2b78aee6a14a03bc971d242d47e209f53b882618..4a35b1a51856c3828c770c80174fac3bf795ddf6 100644 --- a/debexpo/plugins/apps.py +++ b/debexpo/plugins/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class PluginsConfig(AppConfig): - name = 'plugins' + name = 'debexpo.plugins' diff --git a/debexpo/repository/apps.py b/debexpo/repository/apps.py index 6959e71c06ba5a5406a5ae6fa1b60cde6e38f1b1..1180470707e1af4d799a694f431eccc83f47cd10 100644 --- a/debexpo/repository/apps.py +++ b/debexpo/repository/apps.py @@ -30,4 +30,4 @@ from django.apps import AppConfig class RepositoryConfig(AppConfig): - name = 'repository' + name = 'debexpo.repository' diff --git a/debexpo/settings/common.py b/debexpo/settings/common.py index 874975bc135697c212e47b23fa889402f568b0e9..a7e79204e683b4eb795efba717df213f2c29e05f 100644 --- a/debexpo/settings/common.py +++ b/debexpo/settings/common.py @@ -260,3 +260,6 @@ REGISTRATION_CACHE_TIMEOUT = 1 * 24 * 3600 # Timeout for processes (10 minutes by default, 30 minutes for lintian) SUBPROCESS_TIMEOUT = 10 * 60 SUBPROCESS_TIMEOUT_LINTIAN = 30 * 60 + +# Default settings for models +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' diff --git a/debexpo/tools/token.py b/debexpo/tools/token.py index 72f8e493068ae1d2646e0def89b80635ba32b499..de02cb9bd91d0a75b8881e4c31ba8c8e1b85b9c5 100644 --- a/debexpo/tools/token.py +++ b/debexpo/tools/token.py @@ -26,6 +26,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. +from datetime import date from django.conf import settings from django.utils.crypto import constant_time_compare, salted_hmac @@ -87,5 +88,12 @@ class EmailChangeTokenGenerator(PasswordResetTokenGenerator): str(login_timestamp) + \ str(timestamp) + def _num_days(self, dt): + return (dt - date(2001, 1, 1)).days + + def _today(self): + # Used for mocking in tests + return date.today() # pragma: no cover + email_change_token_generator = EmailChangeTokenGenerator() diff --git a/setup.py b/setup.py index c13decdce2643a160f8b69ef6d47dff03f820ebe..5f8ce0114cb039834e2e2d48a47633a299fa8074 100644 --- a/setup.py +++ b/setup.py @@ -77,13 +77,13 @@ setup( # Requirements install_requires=[ - 'django >= 2.2.10, < 3', + 'django >= 2.2.10, < 4', 'bcrypt >= 3.1.6, < 4', 'python-debian >= 0.1.35, < 1', 'celery >= 4.2.1, < 6', 'django-celery-beat >= 1.1.1, < 3', 'redis >= 3.2.1, < 4', - 'django-redis >= 4.10.0, < 5', + 'django-redis >= 4.10.0, < 6', 'python-debianbts >= 2.8.2, < 4', 'lxml >= 4.3.2, < 5', 'dulwich >= 0.19.11, < 1', diff --git a/tests/functional/accounts/test_reset.py b/tests/functional/accounts/test_reset.py index 1dbf2cf9cf78c2d3fb9641e4b3ab8005e45418b5..0f779e11a8471585c0c6f1dd560348551a981090 100644 --- a/tests/functional/accounts/test_reset.py +++ b/tests/functional/accounts/test_reset.py @@ -27,8 +27,7 @@ # OTHER DEALINGS IN THE SOFTWARE. from django.contrib.auth.tokens import PasswordResetTokenGenerator -from django.contrib.auth.views import INTERNAL_RESET_URL_TOKEN, \ - INTERNAL_RESET_SESSION_TOKEN +from django.contrib.auth.views import INTERNAL_RESET_SESSION_TOKEN from django.core import mail from django.urls import reverse from django.utils.encoding import force_bytes @@ -67,7 +66,7 @@ class TestResetController(TestController): response = self.client.post(reverse('password_reset_confirm', kwargs={ 'uidb64': uid, - 'token': INTERNAL_RESET_URL_TOKEN + 'token': 'set-password' }), { 'new_password1': 'newpass', 'new_password2': 'newpass', diff --git a/tox.ini b/tox.ini index aa76e1b57d43fe5d7d0eda76e4d6c738e3bbe49d..7b30496e4960d94231e4c590c5f96a608cd59be5 100644 --- a/tox.ini +++ b/tox.ini @@ -4,21 +4,23 @@ # and then run "tox" from this directory. [tox] -envlist = py3-django2,flake8 +envlist = py3-django{2,3},flake8 [testenv] extras = testing deps = coverage + django2: Django >= 2.2.24, < 3 + django3: Django >= 3.2.7, <4 setenv = DJANGO_SETTINGS_MODULE=debexpo.settings.test commands = coverage erase - coverage run manage.py test -v 2 - coverage report --include='debexpo*' - coverage html --include='debexpo*' + coverage run manage.py test -v 2 --exclude-tag nntp {posargs} + coverage report --include='debexpo*' --omit '*/nntp.py' + coverage html --include='debexpo*' --omit '*/nntp.py' [testenv:flake8] deps = flake8