From 4ccd679ce1d173d75ae0ca73eaa5dd5b959ee69e Mon Sep 17 00:00:00 2001 From: Mathias Ertl Date: Sun, 21 Apr 2024 15:31:09 +0200 Subject: [PATCH] dep-update, add pydantic 2.7, acme 2.10 --- .github/workflows/faketime.yml | 4 ++-- .github/workflows/tests.yml | 2 +- ca/django_ca/tests/base/mixins.py | 16 ++-------------- ca/django_ca/tests/key_backends/test_storages.py | 7 +++++++ devscripts/validation/state.py | 5 +++-- docs/source/changelog/TBR_1.29.0.rst | 1 + docs/source/quickstart/as_app.rst | 8 ++++---- pyproject.toml | 4 ++-- requirements/requirements-lint.txt | 2 +- requirements/requirements-mypy.txt | 8 ++++---- tox.ini | 8 +++++--- 11 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.github/workflows/faketime.yml b/.github/workflows/faketime.yml index 8e88eb146..2de10f4b3 100644 --- a/.github/workflows/faketime.yml +++ b/.github/workflows/faketime.yml @@ -20,7 +20,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5.0.0 with: - python-version: 3.12 + python-version: "3.12" architecture: x64 - name: Apply caching of dependencies @@ -35,4 +35,4 @@ jobs: pip install -r requirements.txt -r requirements/requirements-test.txt - name: Run tests - run: faketime -f +100y pytest -v --cov-report term-missing --durations=20 + run: faketime -f +100y pytest -v --no-selenium --cov-report term-missing --durations=20 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e7420289a..ccad3c8bb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: python-version: [ "3.9", "3.10", "3.11", "3.12" ] django-version: [ "4.2.0", "5.0.0", ] cryptography-version: [ "42.0" ] - pydantic-version: [ "2.5.0", "2.6.0" ] + pydantic-version: [ "2.5.0", "2.6.0", "2.7.0" ] exclude: - python-version: 3.9 django-version: 5.0.0 diff --git a/ca/django_ca/tests/base/mixins.py b/ca/django_ca/tests/base/mixins.py index 10a374e91..9e7747b5f 100644 --- a/ca/django_ca/tests/base/mixins.py +++ b/ca/django_ca/tests/base/mixins.py @@ -47,7 +47,7 @@ from django_ca.models import Certificate, CertificateAuthority, DjangoCAModel, X509CertMixin from django_ca.signals import post_revoke_cert, post_sign_cert, pre_sign_cert from django_ca.tests.admin.assertions import assert_change_response, assert_changelist_response -from django_ca.tests.base.constants import CERT_DATA, TIMESTAMPS +from django_ca.tests.base.constants import CERT_DATA from django_ca.tests.base.mocks import mock_signal from django_ca.tests.base.typehints import DjangoCAModelTypeVar @@ -408,16 +408,13 @@ def expires(cls, days: int) -> timedelta: @contextmanager def freeze_time( - self, timestamp: Union[str, datetime] + self, timestamp: Union[datetime] ) -> Iterator[Union[FrozenDateTimeFactory, StepTickTimeFactory]]: """Context manager to freeze time to a given timestamp. If `timestamp` is a str that is in the `TIMESTAMPS` dict (e.g. "everything-valid"), use that timestamp. """ - if isinstance(timestamp, str): # pragma: no branch - timestamp = TIMESTAMPS[timestamp] - with freeze_time(timestamp) as frozen: yield frozen @@ -595,15 +592,6 @@ def create_superuser( """Shortcut to create a superuser.""" return User.objects.create_superuser(username=username, password=password, email=email) - @contextmanager - def freeze_time( - self, timestamp: Union[str, datetime] - ) -> Iterator[Union[FrozenDateTimeFactory, StepTickTimeFactory]]: - """Overridden to force a client login, otherwise the user session is expired.""" - with super().freeze_time(timestamp) as frozen: - self.client.force_login(self.user) - yield frozen - def get_changelist_view(self, data: Optional[dict[str, str]] = None) -> "HttpResponse": """Get the response to a changelist view for the given model.""" return self.client.get(self.changelist_url, data) diff --git a/ca/django_ca/tests/key_backends/test_storages.py b/ca/django_ca/tests/key_backends/test_storages.py index bac5281e4..cc64cc345 100644 --- a/ca/django_ca/tests/key_backends/test_storages.py +++ b/ca/django_ca/tests/key_backends/test_storages.py @@ -82,6 +82,13 @@ def test_check_usable_no_path_configured(root: CertificateAuthority) -> None: root.check_usable(UsePrivateKeyOptions(password=None)) +def test_is_usable_no_path_configured(root: CertificateAuthority) -> None: + """Test is_usable() when no path is configured.""" + root.key_backend_options = {} + root.save() + assert root.is_usable(UsePrivateKeyOptions(password=None)) is False + + def test_get_ocsp_key_size_with_invalid_key_type(usable_ec: CertificateAuthority) -> None: """Test getting key size for a non-RSA/DSA CA.""" with pytest.raises(ValueError, match=r"^This function should only be called with RSA/DSA CAs\.$"): diff --git a/devscripts/validation/state.py b/devscripts/validation/state.py index 0330b9413..88f6f3135 100644 --- a/devscripts/validation/state.py +++ b/devscripts/validation/state.py @@ -118,8 +118,9 @@ def check_github_action_versions(job: dict[str, Any]) -> int: if action == "actions/setup-python": py_version = step_config["with"]["python-version"] - if py_version not in ("${{ matrix.python-version }}", config.PYTHON_RELEASES[-1]): - errors += err(f"Outdated Python version: {py_version}") + newest_python = config.PYTHON_RELEASES[-1] + if py_version not in ("${{ matrix.python-version }}", newest_python): + errors += err(f"Outdated Python version: {py_version} (newest: {newest_python})") return errors diff --git a/docs/source/changelog/TBR_1.29.0.rst b/docs/source/changelog/TBR_1.29.0.rst index 1b154d4a5..faa70ff2f 100644 --- a/docs/source/changelog/TBR_1.29.0.rst +++ b/docs/source/changelog/TBR_1.29.0.rst @@ -23,6 +23,7 @@ Profiles Dependencies ************ +* Add support for ``acme~=2.10.0`` and ``pydantic~=2.7.0``. * **BACKWARDS INCOMPATIBLE:** Dropped support for Python 3.8. * **BACKWARDS INCOMPATIBLE:** Dropped support for ``cryptography~=41.0``, ``acme~=2.7.0`` and ``acme~=2.8.0``. diff --git a/docs/source/quickstart/as_app.rst b/docs/source/quickstart/as_app.rst index bcb8d20fc..98c1499b7 100644 --- a/docs/source/quickstart/as_app.rst +++ b/docs/source/quickstart/as_app.rst @@ -29,10 +29,10 @@ tested with what release (changes to previous versions in **bold**): .. Keep no more then 10 releases in this table. -=========== ============== ================== =============== ============= =================== ========= +=========== ============== ================== =============== ============= =================== ============= django-ca Python Django cryptography Celery acme pydantic -=========== ============== ================== =============== ============= =================== ========= -1.29 **3.9** - 3.12 4.2 - 5.0 **42** 5.3 **2.9** 2.5 - 2.6 +=========== ============== ================== =============== ============= =================== ============= +1.29 **3.9** - 3.12 4.2 - 5.0 **42** 5.3 - **5.4** **2.9** - **2.10** 2.5 - **2.7** 1.28 3.8 - 3.12 **4.2** - **5.0** 41 - **42** 5.3 **2.7** - **2.9** 2.5 - 2.6 1.27 3.8 - **3.12** 3.2, **4.2** **41** **5.3** 2.6 - **2.7** 1.26 3.8 - 3.11 3.2, 4.1 - 4.2 **40** - 41 **5.2** - 5.3 **2.5** - 2.6 @@ -42,7 +42,7 @@ django-ca Python Django cryptography Celery acme 1.22 3.7 - **3.11** 3.2 - **4.1** **36** - **38** **5.1** - 5.2 **1.27** - **2.1** 1.21 3.7 - 3.10 **3.2** - 4.0 **35** - **37** 5.0 - 5.2 **1.23** - **1.25** 1.20 **3.7 - 3.10** **2.2, 3.2 - 4.0** **3.4 - 36** 5.0 - **5.2** **1.22** -=========== ============== ================== =============== ============= =================== ========= +=========== ============== ================== =============== ============= =================== ============= Note that we don't deliberately break support for older versions, we merely stop testing it. You can try your luck with older versions. diff --git a/pyproject.toml b/pyproject.toml index e0cb5da53..f76494728 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,8 +11,8 @@ python = ["3.9", "3.10", "3.11", "3.12"] # https://www.djangoproject.com/download/ django = ["4.2", "5.0"] cryptography = ["42"] -acme = ["2.9"] -pydantic = ["2.5", "2.6"] +acme = ["2.9", "2.10"] +pydantic = ["2.5", "2.6", "2.7"] # https://alpinelinux.org/releases/ alpine = [ diff --git a/requirements/requirements-lint.txt b/requirements/requirements-lint.txt index a6d87df58..9e985da52 100644 --- a/requirements/requirements-lint.txt +++ b/requirements/requirements-lint.txt @@ -2,5 +2,5 @@ pre-commit==3.7.0 pylint-django==2.5.5 pylint==3.1.0 -ruff==0.3.7 +ruff==0.4.1 setuptools>=65 diff --git a/requirements/requirements-mypy.txt b/requirements/requirements-mypy.txt index b122ca963..5cf09e25f 100644 --- a/requirements/requirements-mypy.txt +++ b/requirements/requirements-mypy.txt @@ -6,10 +6,10 @@ types-docutils==0.20.0.20240406 types-freezegun==1.1.10 types-jinja2==2.11.9 types-mysqlclient==2.2.0.20240311 -types-psycopg2==2.9.21.20240311 -types-pyOpenSSL==24.0.0.20240311 +types-psycopg2==2.9.21.20240417 +types-pyOpenSSL==24.0.0.20240417 types-pyRFC3339==1.1.1.5 -types-redis==4.6.0.20240409 +types-redis==4.6.0.20240417 types-requests==2.31.0.20240406 -types-setuptools==69.2.0.20240317 +types-setuptools==69.5.0.20240415 types-tabulate==0.9.0.20240106 diff --git a/tox.ini b/tox.ini index 15dde5e64..3f7fee6e6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = pylint,docs,lint,mypy,demo,dist-test - py{310,311,312}-dj{5.0}-cg{42}-acme{2.9}-pydantic{2.5,2.6} - py{39,310,311,312}-dj{4.2}-cg{42}-acme{2.9}-pydantic{2.5,2.6} + py{310,311,312}-dj{5.0}-cg{42}-acme{2.9,2.10}-pydantic{2.5,2.6,2.7} + py{39,310,311,312}-dj{4.2}-cg{42}-acme{2.9,2.10}-pydantic{2.5,2.6,2.7} faketime [testenv] @@ -13,8 +13,10 @@ deps = dj5.0: Django~=5.0.0 cg42: cryptography~=42.0 acme2.9: acme~=2.9.0 + acme2.10: acme~=2.10.0 pydantic2.5: pydantic~=2.5.0 pydantic2.6: pydantic~=2.6.0 + pydantic2.7: pydantic~=2.7.0 setenv = COVERAGE_FILE = {envdir}/.coverage commands = @@ -29,7 +31,7 @@ setenv = COVERAGE_FILE = {envdir}/.coverage allowlist_externals = faketime commands = - faketime -f "+100y" pytest -v --basetemp="{env_tmp_dir}" --cov-report html:{envdir}/htmlcov/ --durations=20 {posargs} + faketime -f "+100y" pytest -v --no-selenium --basetemp="{env_tmp_dir}" --cov-report html:{envdir}/htmlcov/ --durations=20 {posargs} [testenv:demo] basepython = python3