mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-06 21:33:00 +00:00
Ensure that *everything* is typed in community.crypto (#917)
* Ensure that *everything* is typed in community.crypto. * Fix comment. * Ignore type definitions/imports and AssertionErrors for code coverage.
This commit is contained in:
@@ -21,10 +21,20 @@ from ..test__time import TIMEZONES, cartesian_product
|
||||
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
from ansible_collections.community.crypto.plugins.module_utils._acme.backends import (
|
||||
from ansible_collections.community.crypto.plugins.module_utils._acme.backends import ( # pragma: no cover
|
||||
Criterium,
|
||||
)
|
||||
|
||||
class DatetimeKwarg(t.TypedDict): # pragma: no cover
|
||||
year: int
|
||||
month: int
|
||||
day: int
|
||||
hour: t.NotRequired[int]
|
||||
minute: t.NotRequired[int]
|
||||
second: t.NotRequired[int]
|
||||
microsecond: t.NotRequired[int]
|
||||
tzinfo: t.NotRequired[datetime.timezone | None]
|
||||
|
||||
|
||||
def load_fixture(name: str) -> str:
|
||||
with open(
|
||||
@@ -133,7 +143,7 @@ TEST_CERT_INFO: list[tuple[str, CertificateInformation, str]] = [
|
||||
]
|
||||
|
||||
|
||||
TEST_PARSE_ACME_TIMESTAMP: list[tuple[datetime.timedelta, str, dict[str, int]]] = (
|
||||
TEST_PARSE_ACME_TIMESTAMP: list[tuple[datetime.timedelta, str, DatetimeKwarg]] = (
|
||||
cartesian_product(
|
||||
TIMEZONES,
|
||||
[
|
||||
@@ -201,7 +211,7 @@ TEST_PARSE_ACME_TIMESTAMP: list[tuple[datetime.timedelta, str, dict[str, int]]]
|
||||
|
||||
|
||||
TEST_INTERPOLATE_TIMESTAMP: list[
|
||||
tuple[datetime.timedelta, dict[str, int], dict[str, int], float, dict[str, int]]
|
||||
tuple[datetime.timedelta, DatetimeKwarg, DatetimeKwarg, float, DatetimeKwarg]
|
||||
] = cartesian_product(
|
||||
TIMEZONES,
|
||||
[
|
||||
@@ -233,17 +243,17 @@ class FakeBackend(CryptoBackend):
|
||||
*,
|
||||
key_file: str | os.PathLike | None = None,
|
||||
key_content: str | None = None,
|
||||
passphrase=None,
|
||||
passphrase: str | None = None,
|
||||
) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
def sign(
|
||||
self, *, payload64: str, protected64: str, key_data: dict[str, t.Any] | None
|
||||
) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
def create_mac_key(self, *, alg: str, key: str) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
def get_ordered_csr_identifiers(
|
||||
self,
|
||||
@@ -251,7 +261,7 @@ class FakeBackend(CryptoBackend):
|
||||
csr_filename: str | os.PathLike | None = None,
|
||||
csr_content: str | bytes | None = None,
|
||||
) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
def get_csr_identifiers(
|
||||
self,
|
||||
@@ -259,7 +269,7 @@ class FakeBackend(CryptoBackend):
|
||||
csr_filename: str | os.PathLike | None = None,
|
||||
csr_content: str | bytes | None = None,
|
||||
) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
def get_cert_days(
|
||||
self,
|
||||
@@ -268,10 +278,10 @@ class FakeBackend(CryptoBackend):
|
||||
cert_content: str | bytes | None = None,
|
||||
now: datetime.datetime | None = None,
|
||||
) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
def create_chain_matcher(self, *, criterium: Criterium) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
def get_cert_information(
|
||||
self,
|
||||
@@ -279,4 +289,4 @@ class FakeBackend(CryptoBackend):
|
||||
cert_filename: str | os.PathLike | None = None,
|
||||
cert_content: str | bytes | None = None,
|
||||
) -> t.NoReturn:
|
||||
raise BackendException("Not implemented in fake backend")
|
||||
raise BackendException("Not implemented in fake backend") # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user