From de55d2070f26a521f5d38fa14510dc20d4f4e1fb Mon Sep 17 00:00:00 2001 From: Mathias Ertl Date: Sat, 9 Mar 2024 15:15:04 +0100 Subject: [PATCH] fix docs --- ca/django_ca/constants.py | 2 +- .../{backends => key_backends}/__init__.py | 2 +- .../{backends => key_backends}/base.py | 23 ++++++++++--------- .../{backends => key_backends}/storages.py | 2 +- ca/django_ca/management/actions.py | 2 +- ca/django_ca/management/commands/import_ca.py | 2 +- ca/django_ca/management/commands/init_ca.py | 2 +- ca/django_ca/management/mixins.py | 2 +- ca/django_ca/managers.py | 7 +++--- ca/django_ca/models.py | 2 +- ca/django_ca/profiles.py | 2 +- .../tests/acme/views/test_revocation.py | 2 +- ca/django_ca/tests/base/assertions.py | 2 +- ca/django_ca/tests/commands/test_import_ca.py | 2 +- ca/django_ca/tests/commands/test_init_ca.py | 2 +- .../commands/test_regenerate_ocsp_keys.py | 2 +- ca/django_ca/tests/conftest.py | 6 ++--- ca/django_ca/tests/key_backends/conftest.py | 4 ++-- ca/django_ca/tests/key_backends/test_base.py | 6 ++--- .../tests/key_backends/test_storages.py | 6 ++--- ca/django_ca/tests/test_management_actions.py | 6 ++--- ca/django_ca/tests/test_managers.py | 2 +- ca/django_ca/tests/test_models.py | 2 +- ca/django_ca/tests/test_profiles.py | 2 +- ca/django_ca/tests/test_tasks.py | 2 +- ca/django_ca/tests/test_verification.py | 4 ++-- ca/django_ca/tests/test_views_ocsp.py | 2 +- devscripts/commands/init_demo.py | 2 +- devscripts/recreate_fixtures_helpers.py | 4 ++-- devscripts/standalone/create-testdata.py | 4 ++-- devscripts/standalone/validate-testdata.py | 2 +- docs/source/conf.py | 7 +++--- docs/source/python/backends.rst | 6 ++--- docs/source/python/intro.rst | 4 ++-- docs/source/python/models.rst | 4 ++-- docs/source/python/profiles.rst | 2 +- 36 files changed, 69 insertions(+), 66 deletions(-) rename ca/django_ca/{backends => key_backends}/__init__.py (92%) rename ca/django_ca/{backends => key_backends}/base.py (93%) rename ca/django_ca/{backends => key_backends}/storages.py (99%) diff --git a/ca/django_ca/constants.py b/ca/django_ca/constants.py index 09bf84736..5da6d844b 100644 --- a/ca/django_ca/constants.py +++ b/ca/django_ca/constants.py @@ -59,7 +59,7 @@ } ) -DEFAULT_STORAGE_BACKEND = "django_ca.backends.storages.StoragesBackend" +DEFAULT_STORAGE_BACKEND = "django_ca.key_backends.storages.StoragesBackend" #: Mapping of elliptic curve names to the implementing classes ELLIPTIC_CURVE_TYPES: "MappingProxyType[EllipticCurves, Type[ec.EllipticCurve]]" = MappingProxyType( diff --git a/ca/django_ca/backends/__init__.py b/ca/django_ca/key_backends/__init__.py similarity index 92% rename from ca/django_ca/backends/__init__.py rename to ca/django_ca/key_backends/__init__.py index 094d881ab..f5e030a9e 100644 --- a/ca/django_ca/backends/__init__.py +++ b/ca/django_ca/key_backends/__init__.py @@ -13,6 +13,6 @@ """Public exports of the backend module.""" -from django_ca.backends.base import KeyBackend, key_backends +from django_ca.key_backends.base import KeyBackend, key_backends __all__ = ["KeyBackend", "key_backends"] diff --git a/ca/django_ca/backends/base.py b/ca/django_ca/key_backends/base.py similarity index 93% rename from ca/django_ca/backends/base.py rename to ca/django_ca/key_backends/base.py index 8cd0d8958..fd65da754 100644 --- a/ca/django_ca/backends/base.py +++ b/ca/django_ca/key_backends/base.py @@ -77,9 +77,9 @@ def add_create_private_key_group(self, parser: CommandParser) -> Optional[Argume """Add an argument group for arguments for private key generation with this backend. By default, the title and description of the argument group is based on - :py:attr:`~django_ca.backends.base.KeyBackend.alias`, - :py:attr:`~django_ca.backends.base.KeyBackend.title` and - :py:attr:`~django_ca.backends.base.KeyBackend.description`. + :py:attr:`~django_ca.key_backends.base.KeyBackend.alias`, + :py:attr:`~django_ca.key_backends.base.KeyBackend.title` and + :py:attr:`~django_ca.key_backends.base.KeyBackend.description`. Return ``None`` if you don't need to create such a group. """ @@ -92,7 +92,7 @@ def add_store_private_key_group(self, parser: CommandParser) -> Optional[Argumen """Add an argument group for storing private keys (when importing an existing CA). By default, this method adds the same group as - :py:func:`~django_ca.backends.base.KeyBackend.add_create_private_key_group` + :py:func:`~django_ca.key_backends.base.KeyBackend.add_create_private_key_group` """ return self.add_create_private_key_group(parser) @@ -100,8 +100,8 @@ def add_use_private_key_group(self, parser: CommandParser) -> Optional[ArgumentG """Add an argument group for arguments required for using a private key stored with this backend. By default, the title and description of the argument group is based on - :py:attr:`~django_ca.backends.base.KeyBackend.alias` and - :py:attr:`~django_ca.backends.base.KeyBackend.title`. + :py:attr:`~django_ca.key_backends.base.KeyBackend.alias` and + :py:attr:`~django_ca.key_backends.base.KeyBackend.title`. Return ``None`` if you don't need to create such a group. """ @@ -116,7 +116,7 @@ def add_create_private_key_arguments(self, group: ArgumentGroup) -> None: Add arguments that can be used for generating private keys with your backend to `group`. The arguments you add here are expected to be loaded (and validated) using - :py:func:`~django_ca.backends.base.KeyBackend.get_create_private_key_options`. + :py:func:`~django_ca.key_backends.base.KeyBackend.get_create_private_key_options`. """ @abc.abstractmethod @@ -124,7 +124,7 @@ def add_use_parent_private_key_arguments(self, group: ArgumentGroup) -> None: """Add arguments for loading the private key of a parent certificate authority. The arguments you add here are expected to be loaded (and validated) using - :py:func:`~django_ca.backends.base.KeyBackend.get_load_parent_private_key_options`. + :py:func:`~django_ca.key_backends.base.KeyBackend.get_use_parent_private_key_options`. """ @abc.abstractmethod @@ -136,7 +136,7 @@ def add_use_private_key_arguments(self, group: ArgumentGroup) -> None: """Add arguments required for using private key stored with this backend. The arguments you add here are expected to be loaded (and validated) using - :py:func:`~django_ca.backends.base.KeyBackend.get_load_parent_private_key_options`. + :py:func:`~django_ca.key_backends.base.KeyBackend.get_use_parent_private_key_options`. """ return None @@ -147,7 +147,8 @@ def get_create_private_key_options( """Load options to create private keys into a Pydantic model. `options` is the dictionary of arguments to ``manage.py init_ca`` (including default values). The - returned model will be passed to :py:func:`~django_ca.backends.base.KeyBackend.create_private_key`. + returned model will be passed to + :py:func:`~django_ca.key_backends.base.KeyBackend.create_private_key`. """ @abc.abstractmethod @@ -179,7 +180,7 @@ def is_usable( """Boolean returning if the given `ca` can be used to sign new certificates (or CRLs). The `options` are the options returned by - :py:func:`~django_ca.backends.base.KeyBackend.get_load_private_key_options`. It may be ``None`` in + :py:func:`~django_ca.key_backends.base.KeyBackend.get_use_private_key_options`. It may be ``None`` in cases where key options cannot (yet) be loaded. If ``None``, the backend should return ``False`` if it knows for sure that it will not be usable, and ``True`` if usability cannot be determined. """ diff --git a/ca/django_ca/backends/storages.py b/ca/django_ca/key_backends/storages.py similarity index 99% rename from ca/django_ca/backends/storages.py rename to ca/django_ca/key_backends/storages.py index 085d033a8..6397c8784 100644 --- a/ca/django_ca/backends/storages.py +++ b/ca/django_ca/key_backends/storages.py @@ -40,7 +40,7 @@ from django.core.files.storage import storages from django_ca import constants -from django_ca.backends.base import KeyBackend +from django_ca.key_backends.base import KeyBackend from django_ca.management.actions import PasswordAction from django_ca.management.base import add_elliptic_curve, add_key_size, add_password from django_ca.typehints import AllowedHashTypes, ArgumentGroup, ParsableKeyType diff --git a/ca/django_ca/management/actions.py b/ca/django_ca/management/actions.py index 9e906be01..7d8bc771c 100644 --- a/ca/django_ca/management/actions.py +++ b/ca/django_ca/management/actions.py @@ -30,8 +30,8 @@ from django.core.validators import URLValidator from django_ca import ca_settings, constants -from django_ca.backends import KeyBackend, key_backends from django_ca.constants import EXTENSION_DEFAULT_CRITICAL, KEY_USAGE_NAMES, ReasonFlags +from django_ca.key_backends import KeyBackend, key_backends from django_ca.models import Certificate, CertificateAuthority from django_ca.typehints import AllowedHashTypes, AlternativeNameExtensionType, EllipticCurves from django_ca.utils import is_power2, parse_encoding, parse_general_name diff --git a/ca/django_ca/management/commands/import_ca.py b/ca/django_ca/management/commands/import_ca.py index 2124e7473..9cb127b2d 100644 --- a/ca/django_ca/management/commands/import_ca.py +++ b/ca/django_ca/management/commands/import_ca.py @@ -30,8 +30,8 @@ from django.core.management.base import CommandError, CommandParser from django_ca import ca_settings, constants -from django_ca.backends import KeyBackend, key_backends from django_ca.constants import PRIVATE_KEY_TYPES, PUBLIC_KEY_TYPES +from django_ca.key_backends import KeyBackend, key_backends from django_ca.management.actions import PasswordAction from django_ca.management.base import BaseCommand from django_ca.management.mixins import CertificateAuthorityDetailMixin, StorePrivateKeyMixin diff --git a/ca/django_ca/management/commands/init_ca.py b/ca/django_ca/management/commands/init_ca.py index 0e105b62f..821997452 100644 --- a/ca/django_ca/management/commands/init_ca.py +++ b/ca/django_ca/management/commands/init_ca.py @@ -29,7 +29,7 @@ from django.utils.translation import gettext_lazy as _ from django_ca import ca_settings, constants -from django_ca.backends import KeyBackend, key_backends +from django_ca.key_backends import KeyBackend, key_backends from django_ca.management.actions import ExpiresAction, IntegerRangeAction, NameAction from django_ca.management.base import BaseSignCommand from django_ca.management.mixins import CertificateAuthorityDetailMixin, StorePrivateKeyMixin diff --git a/ca/django_ca/management/mixins.py b/ca/django_ca/management/mixins.py index be1ec227a..3fa28147b 100644 --- a/ca/django_ca/management/mixins.py +++ b/ca/django_ca/management/mixins.py @@ -25,8 +25,8 @@ from django.core.management.base import BaseCommand, CommandError, CommandParser from django_ca import ca_settings -from django_ca.backends import key_backends from django_ca.extensions import extension_as_text, get_extension_name +from django_ca.key_backends import key_backends from django_ca.management import actions from django_ca.management.actions import IntegerRangeAction, KeyBackendAction from django_ca.models import CertificateAuthority, X509CertMixin diff --git a/ca/django_ca/managers.py b/ca/django_ca/managers.py index 61f64c1b4..80a47b64a 100644 --- a/ca/django_ca/managers.py +++ b/ca/django_ca/managers.py @@ -26,8 +26,8 @@ from django.urls import reverse from django_ca import ca_settings, constants -from django_ca.backends.base import KeyBackend from django_ca.extensions.utils import format_extensions, get_formatting_context +from django_ca.key_backends.base import KeyBackend from django_ca.modelfields import LazyCertificateSigningRequest from django_ca.openssh import SshHostCaExtension, SshUserCaExtension from django_ca.profiles import Profile, profiles @@ -270,8 +270,9 @@ def init( # noqa: PLR0912,PLR0913,PLR0915 ---------- name : str The name of the CA. This is a human-readable string and is used for administrative purposes only. - key_backend : :py:class:`~django_ca.backends.base.KeyBackend` - A subclass of :py:class:`~django_ca.backends.base.KeyBackend` to use for storing the private key. + key_backend : :py:class:`~django_ca.key_backends.base.KeyBackend` + A subclass of :py:class:`~django_ca.key_backends.base.KeyBackend` to use for storing the private + key. key_backend_options : BaseModel Parameters required for creating the private key using `key_backend`. subject : :py:class:`cg:cryptography.x509.Name` diff --git a/ca/django_ca/models.py b/ca/django_ca/models.py index 310bcc339..5fa6c75b7 100644 --- a/ca/django_ca/models.py +++ b/ca/django_ca/models.py @@ -54,10 +54,10 @@ from django_ca import ca_settings, constants from django_ca.acme.constants import BASE64_URL_ALPHABET, IdentifierType, Status -from django_ca.backends import KeyBackend, key_backends from django_ca.constants import REVOCATION_REASONS, ReasonFlags from django_ca.deprecation import not_valid_after, not_valid_before from django_ca.extensions import get_extension_name +from django_ca.key_backends import KeyBackend, key_backends from django_ca.managers import ( AcmeAccountManager, AcmeAuthorizationManager, diff --git a/ca/django_ca/profiles.py b/ca/django_ca/profiles.py index 752896bbd..e8f7df7ab 100644 --- a/ca/django_ca/profiles.py +++ b/ca/django_ca/profiles.py @@ -199,7 +199,7 @@ def create_cert( # noqa: PLR0913 >>> from cryptography import x509 >>> from cryptography.x509.oid import NameOID - >>> from django_ca.backends.storages import UsePrivateKeyOptions + >>> from django_ca.key_backends.storages import UsePrivateKeyOptions >>> subject = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, 'example.com')]) >>> key_backend_options = UsePrivateKeyOptions(password=None) >>> profile = get_profile('webserver') diff --git a/ca/django_ca/tests/acme/views/test_revocation.py b/ca/django_ca/tests/acme/views/test_revocation.py index 371a6d2c2..b5d903018 100644 --- a/ca/django_ca/tests/acme/views/test_revocation.py +++ b/ca/django_ca/tests/acme/views/test_revocation.py @@ -27,8 +27,8 @@ from freezegun import freeze_time from django_ca import ca_settings -from django_ca.backends.storages import UsePrivateKeyOptions from django_ca.constants import ReasonFlags +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.models import AcmeAccount, AcmeAuthorization, AcmeCertificate, AcmeOrder, Certificate from django_ca.tests.acme.views.base import AcmeWithAccountViewTestCaseMixin from django_ca.tests.base.constants import CERT_DATA, TIMESTAMPS diff --git a/ca/django_ca/tests/base/assertions.py b/ca/django_ca/tests/base/assertions.py index 1f35a60fb..1a621be27 100644 --- a/ca/django_ca/tests/base/assertions.py +++ b/ca/django_ca/tests/base/assertions.py @@ -34,13 +34,13 @@ import pytest from django_ca import ca_settings -from django_ca.backends.storages import UsePrivateKeyOptions from django_ca.deprecation import ( RemovedInDjangoCA200Warning, crl_last_update, crl_next_update, revoked_certificate_revocation_date, ) +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.models import Certificate, CertificateAuthority, X509CertMixin from django_ca.signals import post_create_ca, post_issue_cert, pre_create_ca, pre_sign_cert from django_ca.tests.base.mocks import mock_signal diff --git a/ca/django_ca/tests/commands/test_import_ca.py b/ca/django_ca/tests/commands/test_import_ca.py index ca62214e8..a8a04a600 100644 --- a/ca/django_ca/tests/commands/test_import_ca.py +++ b/ca/django_ca/tests/commands/test_import_ca.py @@ -30,7 +30,7 @@ from ca import settings from django_ca import ca_settings -from django_ca.backends.storages import UsePrivateKeyOptions +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.models import CertificateAuthority from django_ca.tests.base.assertions import assert_command_error, assert_signature from django_ca.tests.base.constants import CERT_DATA, TIMESTAMPS diff --git a/ca/django_ca/tests/commands/test_init_ca.py b/ca/django_ca/tests/commands/test_init_ca.py index 6ca9239a7..ba32f0f67 100644 --- a/ca/django_ca/tests/commands/test_init_ca.py +++ b/ca/django_ca/tests/commands/test_init_ca.py @@ -35,8 +35,8 @@ from pytest_django.fixtures import SettingsWrapper from django_ca import ca_settings -from django_ca.backends.storages import UsePrivateKeyOptions from django_ca.constants import ExtendedKeyUsageOID +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.models import Certificate, CertificateAuthority from django_ca.signals import post_create_ca from django_ca.tests.base.assertions import ( diff --git a/ca/django_ca/tests/commands/test_regenerate_ocsp_keys.py b/ca/django_ca/tests/commands/test_regenerate_ocsp_keys.py index 4d3b50b60..e75019914 100644 --- a/ca/django_ca/tests/commands/test_regenerate_ocsp_keys.py +++ b/ca/django_ca/tests/commands/test_regenerate_ocsp_keys.py @@ -24,7 +24,7 @@ from django.test import TestCase -from django_ca.backends.storages import UsePrivateKeyOptions +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.models import Certificate, CertificateAuthority from django_ca.tests.base.assertions import assert_command_error from django_ca.tests.base.constants import CERT_DATA diff --git a/ca/django_ca/tests/conftest.py b/ca/django_ca/tests/conftest.py index f3108410a..c77989bc8 100644 --- a/ca/django_ca/tests/conftest.py +++ b/ca/django_ca/tests/conftest.py @@ -39,8 +39,8 @@ from ca import settings_utils # noqa: F401 # to get rid of pytest warnings from django_ca import ca_settings -from django_ca.backends import key_backends -from django_ca.backends.storages import StoragesBackend +from django_ca.key_backends import key_backends +from django_ca.key_backends.storages import StoragesBackend from django_ca.models import Certificate, CertificateAuthority from django_ca.profiles import profiles from django_ca.tests.base.conftest_helpers import ( @@ -144,7 +144,7 @@ def hostname(ca_name: str) -> Iterator[str]: @pytest.fixture() def key_backend(request: "SubRequest") -> Iterator[StoragesBackend]: - """Return a :py:class:`~django_ca.backends.storages.StoragesBackend` suitable for creating a new CA.""" + """Return a :py:class:`~django_ca.key_backends.storages.StoragesBackend` for creating a new CA.""" request.getfixturevalue("tmpcadir") yield key_backends[ca_settings.CA_DEFAULT_KEY_BACKEND] # type: ignore[misc] diff --git a/ca/django_ca/tests/key_backends/conftest.py b/ca/django_ca/tests/key_backends/conftest.py index dfa5e6b63..df353aa9c 100644 --- a/ca/django_ca/tests/key_backends/conftest.py +++ b/ca/django_ca/tests/key_backends/conftest.py @@ -17,8 +17,8 @@ import pytest -from django_ca.backends import key_backends -from django_ca.backends.base import KeyBackends +from django_ca.key_backends import key_backends +from django_ca.key_backends.base import KeyBackends @pytest.fixture() diff --git a/ca/django_ca/tests/key_backends/test_base.py b/ca/django_ca/tests/key_backends/test_base.py index f2c37e7da..2d76bcea2 100644 --- a/ca/django_ca/tests/key_backends/test_base.py +++ b/ca/django_ca/tests/key_backends/test_base.py @@ -29,7 +29,7 @@ from pytest_django.fixtures import SettingsWrapper from django_ca import ca_settings -from django_ca.backends import KeyBackend, key_backends +from django_ca.key_backends import KeyBackend, key_backends from django_ca.models import CertificateAuthority from django_ca.tests.base.assertions import assert_improperly_configured from django_ca.typehints import AllowedHashTypes, ArgumentGroup, ParsableKeyType @@ -116,7 +116,7 @@ def test_key_backends_getitem_with_default() -> None: def test_key_backends_getitem_caching() -> None: """Test that lookups are cached properly.""" - patch_target = "django_ca.backends.key_backends._get_key_backend" + patch_target = "django_ca.key_backends.key_backends._get_key_backend" value = "xxx" with patch(patch_target, autospec=True, return_value=value) as load_mock: assert key_backends[ca_settings.CA_DEFAULT_KEY_BACKEND] == value # type: ignore[comparison-overlap] @@ -139,7 +139,7 @@ def test_key_backends_iter(settings: SettingsWrapper) -> None: settings.CA_KEY_BACKENDS = { ca_settings.CA_DEFAULT_KEY_BACKEND: { - "BACKEND": "django_ca.backends.storages.StoragesBackend", + "BACKEND": "django_ca.key_backends.storages.StoragesBackend", "OPTIONS": {"storage_alias": "django-ca"}, }, "test": { diff --git a/ca/django_ca/tests/key_backends/test_storages.py b/ca/django_ca/tests/key_backends/test_storages.py index 467ce9d22..d8c6b1f8d 100644 --- a/ca/django_ca/tests/key_backends/test_storages.py +++ b/ca/django_ca/tests/key_backends/test_storages.py @@ -17,8 +17,8 @@ from pytest_django.fixtures import SettingsWrapper from django_ca import ca_settings -from django_ca.backends import key_backends -from django_ca.backends.storages import StoragesBackend, UsePrivateKeyOptions +from django_ca.key_backends import key_backends +from django_ca.key_backends.storages import StoragesBackend, UsePrivateKeyOptions from django_ca.models import CertificateAuthority @@ -27,7 +27,7 @@ def test_invalid_storages_alias(settings: SettingsWrapper) -> None: """Test configuring an invalid storage alias.""" settings.CA_KEY_BACKENDS = { ca_settings.CA_DEFAULT_KEY_BACKEND: { - "BACKEND": "django_ca.backends.storages.StoragesBackend", + "BACKEND": "django_ca.key_backends.storages.StoragesBackend", "OPTIONS": {"storage_alias": "invalid"}, }, } diff --git a/ca/django_ca/tests/test_management_actions.py b/ca/django_ca/tests/test_management_actions.py index 5e673bbfe..88d133691 100644 --- a/ca/django_ca/tests/test_management_actions.py +++ b/ca/django_ca/tests/test_management_actions.py @@ -32,8 +32,8 @@ import pytest from pytest_django.fixtures import SettingsWrapper -from django_ca.backends import key_backends from django_ca.constants import ReasonFlags +from django_ca.key_backends import key_backends from django_ca.management import actions from django_ca.models import Certificate, CertificateAuthority from django_ca.tests.base.constants import CERT_DATA @@ -51,11 +51,11 @@ def key_backend_parser(settings: SettingsWrapper) -> Iterator[argparse.ArgumentP } settings.CA_KEY_BACKENDS = { "default": { - "BACKEND": "django_ca.backends.storages.StoragesBackend", + "BACKEND": "django_ca.key_backends.storages.StoragesBackend", "OPTIONS": {"storage_alias": "django-ca"}, }, "other": { - "BACKEND": "django_ca.backends.storages.StoragesBackend", + "BACKEND": "django_ca.key_backends.storages.StoragesBackend", "OPTIONS": {"storage_alias": "other-storage"}, }, } diff --git a/ca/django_ca/tests/test_managers.py b/ca/django_ca/tests/test_managers.py index 41f1776ab..60d84d91c 100644 --- a/ca/django_ca/tests/test_managers.py +++ b/ca/django_ca/tests/test_managers.py @@ -28,8 +28,8 @@ from pytest_django.fixtures import SettingsWrapper from django_ca import ca_settings -from django_ca.backends.storages import CreatePrivateKeyOptions, StoragesBackend, UsePrivateKeyOptions from django_ca.constants import ExtendedKeyUsageOID +from django_ca.key_backends.storages import CreatePrivateKeyOptions, StoragesBackend, UsePrivateKeyOptions from django_ca.models import Certificate, CertificateAuthority from django_ca.profiles import profiles from django_ca.querysets import CertificateAuthorityQuerySet, CertificateQuerySet diff --git a/ca/django_ca/tests/test_models.py b/ca/django_ca/tests/test_models.py index 879f44733..69c5ec503 100644 --- a/ca/django_ca/tests/test_models.py +++ b/ca/django_ca/tests/test_models.py @@ -47,9 +47,9 @@ from freezegun import freeze_time from django_ca import ca_settings -from django_ca.backends.storages import UsePrivateKeyOptions from django_ca.constants import ReasonFlags from django_ca.deprecation import not_valid_after, not_valid_before +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.modelfields import LazyCertificate, LazyCertificateSigningRequest from django_ca.models import ( AcmeAccount, diff --git a/ca/django_ca/tests/test_profiles.py b/ca/django_ca/tests/test_profiles.py index 0298d7dc5..795818f0d 100644 --- a/ca/django_ca/tests/test_profiles.py +++ b/ca/django_ca/tests/test_profiles.py @@ -26,9 +26,9 @@ import pytest from django_ca import ca_settings -from django_ca.backends.storages import UsePrivateKeyOptions from django_ca.constants import EXTENSION_DEFAULT_CRITICAL, EXTENSION_KEYS from django_ca.deprecation import RemovedInDjangoCA128Warning +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.models import Certificate, CertificateAuthority from django_ca.profiles import Profile, get_profile, profile, profiles from django_ca.signals import pre_sign_cert diff --git a/ca/django_ca/tests/test_tasks.py b/ca/django_ca/tests/test_tasks.py index 523fa2aaa..8dc4e89e0 100644 --- a/ca/django_ca/tests/test_tasks.py +++ b/ca/django_ca/tests/test_tasks.py @@ -42,7 +42,7 @@ from freezegun import freeze_time from django_ca import ca_settings, tasks -from django_ca.backends.storages import UsePrivateKeyOptions +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.models import ( AcmeAccount, AcmeAuthorization, diff --git a/ca/django_ca/tests/test_verification.py b/ca/django_ca/tests/test_verification.py index fd5131142..52d6a9289 100644 --- a/ca/django_ca/tests/test_verification.py +++ b/ca/django_ca/tests/test_verification.py @@ -29,8 +29,8 @@ from freezegun import freeze_time -from django_ca.backends import key_backends -from django_ca.backends.storages import CreatePrivateKeyOptions +from django_ca.key_backends import key_backends +from django_ca.key_backends.storages import CreatePrivateKeyOptions from django_ca.models import CertificateAuthority, X509CertMixin from django_ca.tests.base.constants import CERT_DATA, TIMESTAMPS from django_ca.tests.base.mixins import TestCaseMixin diff --git a/ca/django_ca/tests/test_views_ocsp.py b/ca/django_ca/tests/test_views_ocsp.py index baa95227f..fd385cd88 100644 --- a/ca/django_ca/tests/test_views_ocsp.py +++ b/ca/django_ca/tests/test_views_ocsp.py @@ -38,8 +38,8 @@ from freezegun import freeze_time from django_ca import ca_settings -from django_ca.backends.storages import UsePrivateKeyOptions from django_ca.constants import ReasonFlags +from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.modelfields import LazyCertificate from django_ca.models import Certificate, CertificateAuthority from django_ca.tests.base.constants import CERT_DATA, FIXTURES_DATA, FIXTURES_DIR, TIMESTAMPS diff --git a/devscripts/commands/init_demo.py b/devscripts/commands/init_demo.py index c144c8cc5..8cc5f575c 100644 --- a/devscripts/commands/init_demo.py +++ b/devscripts/commands/init_demo.py @@ -217,7 +217,7 @@ def handle(self, args: argparse.Namespace) -> None: from django.core.management import call_command as manage from django_ca import ca_settings - from django_ca.backends.storages import UsePrivateKeyOptions + from django_ca.key_backends.storages import UsePrivateKeyOptions from django_ca.utils import ca_storage # pylint: enable=import-outside-toplevel diff --git a/devscripts/recreate_fixtures_helpers.py b/devscripts/recreate_fixtures_helpers.py index 32018f685..3683fcbf3 100644 --- a/devscripts/recreate_fixtures_helpers.py +++ b/devscripts/recreate_fixtures_helpers.py @@ -41,8 +41,8 @@ from devscripts import config from django_ca import ca_settings -from django_ca.backends import key_backends -from django_ca.backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions +from django_ca.key_backends import key_backends +from django_ca.key_backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions from django_ca.models import Certificate, CertificateAuthority from django_ca.profiles import profiles from django_ca.pydantic.extensions import ( diff --git a/devscripts/standalone/create-testdata.py b/devscripts/standalone/create-testdata.py index d9e749674..42bd4d2f4 100755 --- a/devscripts/standalone/create-testdata.py +++ b/devscripts/standalone/create-testdata.py @@ -59,8 +59,8 @@ # pylint: disable=wrong-import-position # django_setup needs to be called first from django_ca import ca_settings # noqa: E402 -from django_ca.backends import key_backends # noqa: E402 -from django_ca.backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions # noqa: E402 +from django_ca.key_backends import key_backends # noqa: E402 +from django_ca.key_backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions # noqa: E402 from django_ca.models import Certificate, CertificateAuthority # noqa: E402 # pylint: enable=wrong-import-position diff --git a/devscripts/standalone/validate-testdata.py b/devscripts/standalone/validate-testdata.py index dee683f5b..223853b78 100755 --- a/devscripts/standalone/validate-testdata.py +++ b/devscripts/standalone/validate-testdata.py @@ -54,7 +54,7 @@ sys.exit(1) # pylint: disable=wrong-import-position # django_setup needs to be called first. -from django_ca.backends.storages import UsePrivateKeyOptions # noqa: E402 +from django_ca.key_backends.storages import UsePrivateKeyOptions # noqa: E402 from django_ca.models import Certificate, CertificateAuthority # noqa: E402 # pylint: enable=wrong-import-position diff --git a/docs/source/conf.py b/docs/source/conf.py index 10c176523..4de1423ac 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -502,10 +502,11 @@ ("py:class", "KeyUsages"), ("py:class", "GeneralNames"), # TypeVars for classes that make no sense in documenting. - ("py:class", "django_ca.backends.base.CreatePrivateKeyOptionsTypeVar"), - ("py:class", "django_ca.backends.base.UsePrivateKeyOptionsTypeVar"), + ("py:class", "django_ca.key_backends.base.CreatePrivateKeyOptionsTypeVar"), + ("py:class", "django_ca.key_backends.base.StorePrivateKeyOptionsTypeVar"), + ("py:class", "django_ca.key_backends.base.UsePrivateKeyOptionsTypeVar"), # Just no need to document these - ("py:class", "django_ca.backends.base.Self"), # pragma: only py<3.11 # replace with typing.Self + ("py:class", "django_ca.key_backends.base.Self"), # pragma: only py<3.11 # replace with typing.Self # Undocumented in Python: ("py:class", "argparse._ArgumentGroup"), ("py:class", "doctest.TestResults"), diff --git a/docs/source/python/backends.rst b/docs/source/python/backends.rst index a48395576..d114c2325 100644 --- a/docs/source/python/backends.rst +++ b/docs/source/python/backends.rst @@ -6,7 +6,7 @@ Supported backends ****************** -.. autoclass:: django_ca.backends.storages.StoragesBackend +.. autoclass:: django_ca.key_backends.storages.StoragesBackend *********************** Writing custom backends @@ -16,6 +16,6 @@ Writing custom backends Base class documentation ************************ -.. autoclass:: django_ca.backends.base.KeyBackend +.. autoclass:: django_ca.key_backends.base.KeyBackend :members: - :exclude-members: class_path \ No newline at end of file + :exclude-members: class_path diff --git a/docs/source/python/intro.rst b/docs/source/python/intro.rst index 8b45577ae..a2759c07f 100644 --- a/docs/source/python/intro.rst +++ b/docs/source/python/intro.rst @@ -43,8 +43,8 @@ To create a new CA, you have to :py:meth:`~django_ca.managers.CertificateAuthori creates a minimal CA using the filesystem storage backend:: >>> from datetime import datetime - >>> from django_ca.backends import key_backends - >>> from django_ca.backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions + >>> from django_ca.key_backends import key_backends + >>> from django_ca.key_backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions >>> from django_ca.models import CertificateAuthority >>> from django_ca.utils import x509_name >>> key_backend = key_backends["default"] diff --git a/docs/source/python/models.rst b/docs/source/python/models.rst index c6025d275..fb785dffd 100644 --- a/docs/source/python/models.rst +++ b/docs/source/python/models.rst @@ -34,8 +34,8 @@ Use ``CertificateAuthority.objects.init()`` to create new certificate authoritie but is designed to provide defaults that work in most cases:: >>> from cryptography.x509.oid import NameOID - >>> from django_ca.backends import key_backends - >>> from django_ca.backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions + >>> from django_ca.key_backends import key_backends + >>> from django_ca.key_backends.storages import CreatePrivateKeyOptions, UsePrivateKeyOptions >>> from django_ca.models import CertificateAuthority >>> key_backend = key_backends["default"] >>> key_backend_options = CreatePrivateKeyOptions(password=None, path="ca", key_size=1024) diff --git a/docs/source/python/profiles.rst b/docs/source/python/profiles.rst index 11c30bc9f..8617147c6 100644 --- a/docs/source/python/profiles.rst +++ b/docs/source/python/profiles.rst @@ -11,7 +11,7 @@ the ``webserver`` profile:: # Note: "csr" is a predefined variable, see https://cryptography.io/en/latest/x509/tutorial/ >>> from cryptography import x509 >>> from cryptography.x509.oid import NameOID - >>> from django_ca.backends.storages import UsePrivateKeyOptions + >>> from django_ca.key_backends.storages import UsePrivateKeyOptions >>> from django_ca.models import Certificate >>> from django_ca.profiles import profiles >>> subject = x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, 'example.com')])