mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-06 13:22:58 +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:
@@ -36,13 +36,13 @@ from ansible_collections.community.crypto.plugins.module_utils._time import (
|
||||
|
||||
|
||||
if t.TYPE_CHECKING:
|
||||
import datetime
|
||||
import datetime # pragma: no cover
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.community.crypto.plugins.module_utils._argspec import (
|
||||
from ansible.module_utils.basic import AnsibleModule # pragma: no cover
|
||||
from ansible_collections.community.crypto.plugins.module_utils._argspec import ( # pragma: no cover
|
||||
ArgumentSpec,
|
||||
)
|
||||
from cryptography.hazmat.primitives.asymmetric.types import (
|
||||
from cryptography.hazmat.primitives.asymmetric.types import ( # pragma: no cover
|
||||
CertificateIssuerPrivateKeyTypes,
|
||||
)
|
||||
|
||||
@@ -114,9 +114,11 @@ class SelfSignedCertificateBackendCryptography(CertificateBackend):
|
||||
def generate_certificate(self) -> None:
|
||||
"""(Re-)Generate certificate."""
|
||||
if self.csr is None:
|
||||
raise AssertionError("Contract violation: csr has not been populated")
|
||||
if self.privatekey is None:
|
||||
raise AssertionError(
|
||||
"Contract violation: csr has not been populated"
|
||||
) # pragma: no cover
|
||||
if self.privatekey is None:
|
||||
raise AssertionError( # pragma: no cover
|
||||
"Contract violation: privatekey has not been populated"
|
||||
)
|
||||
try:
|
||||
@@ -156,7 +158,9 @@ class SelfSignedCertificateBackendCryptography(CertificateBackend):
|
||||
def get_certificate_data(self) -> bytes:
|
||||
"""Return bytes for self.cert."""
|
||||
if self.cert is None:
|
||||
raise AssertionError("Contract violation: cert has not been populated")
|
||||
raise AssertionError(
|
||||
"Contract violation: cert has not been populated"
|
||||
) # pragma: no cover
|
||||
return self.cert.public_bytes(Encoding.PEM)
|
||||
|
||||
def needs_regeneration(
|
||||
|
||||
Reference in New Issue
Block a user