diff --git a/ca/django_ca/ca_settings.py b/ca/django_ca/ca_settings.py index 086445c38..50847635a 100644 --- a/ca/django_ca/ca_settings.py +++ b/ca/django_ca/ca_settings.py @@ -293,7 +293,7 @@ def _get_hash_algorithm(setting: str, default: "HashAlgorithms") -> "AllowedHash CA_DEFAULT_ENCODING: Encoding = getattr(settings, "CA_DEFAULT_ENCODING", Encoding.PEM) CA_NOTIFICATION_DAYS = getattr(settings, "CA_NOTIFICATION_DAYS", [14, 7, 3, 1]) CA_CRL_PROFILES: Dict[str, Dict[str, Any]] = getattr(settings, "CA_CRL_PROFILES", _CA_CRL_PROFILES) -CA_PASSWORDS: Dict[str, str] = getattr(settings, "CA_PASSWORDS", {}) +CA_PASSWORDS: Dict[str, bytes] = getattr(settings, "CA_PASSWORDS", {}) # ACME settings CA_ENABLE_ACME = getattr(settings, "CA_ENABLE_ACME", True) diff --git a/ca/django_ca/key_backends/storages.py b/ca/django_ca/key_backends/storages.py index c9e57ffaa..a444be814 100644 --- a/ca/django_ca/key_backends/storages.py +++ b/ca/django_ca/key_backends/storages.py @@ -88,10 +88,7 @@ def load_default_password(cls, password: Optional[bytes], info: ValidationInfo) if info.context and password is None: ca: CertificateAuthority = info.context.get("ca") if ca: - settings_password = ca_settings.CA_PASSWORDS.get(ca.serial) - if isinstance(settings_password, str): - return settings_password.encode() - if isinstance(settings_password, bytes): + if settings_password := ca_settings.CA_PASSWORDS.get(ca.serial): return settings_password return password diff --git a/ca/django_ca/tests/admin/assertions.py b/ca/django_ca/tests/admin/assertions.py index 5cbb058c7..602044ac8 100644 --- a/ca/django_ca/tests/admin/assertions.py +++ b/ca/django_ca/tests/admin/assertions.py @@ -38,7 +38,7 @@ def assert_change_response( def assert_changelist_response(response: "HttpResponse", *objects: models.Model) -> None: - """Assert that the passed response is a model changelist view.""" + """Assert that the passed response is a model ``changelist`` view.""" assert response.status_code == HTTPStatus.OK, f"HTTP {response.status_code}" def sorter(obj: models.Model) -> Any: diff --git a/ca/django_ca/tests/base/assertions.py b/ca/django_ca/tests/base/assertions.py index 1a621be27..250a03796 100644 --- a/ca/django_ca/tests/base/assertions.py +++ b/ca/django_ca/tests/base/assertions.py @@ -196,7 +196,6 @@ def assert_crl( crl : bytes The raw CRL expected : list - CAs/certs to be expected in this CRL. signer expires algorithm diff --git a/ca/django_ca/tests/base/utils.py b/ca/django_ca/tests/base/utils.py index ceffdaaf8..b7788ee3e 100644 --- a/ca/django_ca/tests/base/utils.py +++ b/ca/django_ca/tests/base/utils.py @@ -417,7 +417,7 @@ def mock_slug() -> Iterator[str]: @contextmanager def mock_cadir(path: str) -> Iterator[None]: - """Contextmanager to set the CA_DIR to a given path without actually creating it.""" + """Context manager to set the CA_DIR to a given path without actually creating it.""" with override_settings(CA_DIR=path), patch.object(ca_storage, "location", path), patch.object( ca_storage, "_location", path ): diff --git a/ca/django_ca/tests/conftest.py b/ca/django_ca/tests/conftest.py index c77989bc8..2f7b67956 100644 --- a/ca/django_ca/tests/conftest.py +++ b/ca/django_ca/tests/conftest.py @@ -205,7 +205,7 @@ def user_client(user: "User", client: Client) -> Iterator[Client]: @pytest.fixture() def tmpcadir(tmp_path: Path, settings: SettingsWrapper) -> Iterator[SettingsWrapper]: - """Fixture to create a temporary directory for storing files using the storages backend.""" + """Fixture to create a temporary directory for storing files using the StoragesBackend.""" settings.CA_DIR = str(tmp_path) # Set the full setting and do **not** update the setting in place. This *somehow* makes a difference. diff --git a/docs/source/index.rst b/docs/source/index.rst index 20b7e5f05..f73dc58f9 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -46,7 +46,7 @@ Welcome to django-ca's documentation! Introduction signals - python/backends + python/key_backends python/extensions python/profiles python/models diff --git a/docs/source/python/intro.rst b/docs/source/python/intro.rst index a2759c07f..e21e02cf7 100644 --- a/docs/source/python/intro.rst +++ b/docs/source/python/intro.rst @@ -40,7 +40,7 @@ retrieve and manipulate CAs:: >>> ca.save() To create a new CA, you have to :py:meth:`~django_ca.managers.CertificateAuthorityManager.init`, this example -creates a minimal CA using the filesystem storage backend:: +creates a minimal CA using the file system storage backend:: >>> from datetime import datetime >>> from django_ca.key_backends import key_backends diff --git a/docs/source/python/backends.rst b/docs/source/python/key_backends.rst similarity index 61% rename from docs/source/python/backends.rst rename to docs/source/python/key_backends.rst index d114c2325..734a9ab7d 100644 --- a/docs/source/python/backends.rst +++ b/docs/source/python/key_backends.rst @@ -1,10 +1,10 @@ -##################################### -``django_ca.backends`` - Key backends -##################################### +######################################### +``django_ca.key_backends`` - Key backends +######################################### -****************** -Supported backends -****************** +********************** +Supported key backends +********************** .. autoclass:: django_ca.key_backends.storages.StoragesBackend diff --git a/docs/source/spelling_wordlist.txt b/docs/source/spelling_wordlist.txt index a029cf744..0abca468d 100644 --- a/docs/source/spelling_wordlist.txt +++ b/docs/source/spelling_wordlist.txt @@ -1,4 +1,5 @@ AllowedHashTypes +Parametrized Psycopg Pydantic Quickstart @@ -18,6 +19,7 @@ cron datastructure dicts django +doctests encipherment env filestorage diff --git a/requirements/requirements-dev-common.txt b/requirements/requirements-dev-common.txt index c9fcbf633..5e90e2511 100644 --- a/requirements/requirements-dev-common.txt +++ b/requirements/requirements-dev-common.txt @@ -5,6 +5,9 @@ PyYAML==6.0.1 Sphinx==7.2.6; python_version > '3.8' Sphinx~=7.1; python_version == '3.8' coverage[toml]==7.4.1 +pytest==8.0.1 +pytest-cov==4.1.0 +pytest-django==4.8.0 selenium==4.17.2 semantic-version==2.10.0 tabulate==0.9.0 diff --git a/requirements/requirements-test.txt b/requirements/requirements-test.txt index 36decbfc3..e3bbdf82d 100644 --- a/requirements/requirements-test.txt +++ b/requirements/requirements-test.txt @@ -4,10 +4,7 @@ django-webtest==1.9.11 freezegun==1.4.0 pyOpenSSL>=23 pyrfc3339==1.1 -pytest-cov==4.1.0 pytest-env==1.1.3 -pytest-django==4.8.0 pytest-freezegun==0.4.2 pytest-random-order==1.1.1 -pytest==8.0.1 requests-mock==1.11.0