mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-05-07 13:53:06 +00:00
ACME modules refactor (#187)
* Move acme.py to acme/__init__.py to prepare splitup. * Began moving generic code out. * Creating backends. * Update unit tests. * Move remaining new code out. * Use new interface. * Rewrite module init code. * Add changelog. * Add BackendException for crypto backend errors. * Improve / uniformize ACME error reporting. * Create ACMELegacyAccount for backwards compatibility. * Split up ACMEAccount into ACMEClient and ACMEAccount. * Move get_keyauthorization into module_utils.acme.challenges. * Improve error handling. * Move challenge and authorization handling code into module_utils. * Add split_identifier helper. * Move order code into module_utils. * Move ACME v2 certificate handling code to module_utils. * Fix/move ACME v1 certificate retrieval to module_utils as well. * Refactor alternate chain handling code by splitting it up into simpler functions. * Make chain matcher creation part of backend.
This commit is contained in:
35
tests/unit/plugins/module_utils/acme/test_utils.py
Normal file
35
tests/unit/plugins/module_utils/acme/test_utils.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
from ansible_collections.community.crypto.plugins.module_utils.acme.utils import (
|
||||
nopad_b64,
|
||||
pem_to_der,
|
||||
)
|
||||
|
||||
from .backend_data import (
|
||||
TEST_PEM_DERS,
|
||||
)
|
||||
|
||||
|
||||
NOPAD_B64 = [
|
||||
("", ""),
|
||||
("\n", "Cg"),
|
||||
("123", "MTIz"),
|
||||
("Lorem?ipsum", "TG9yZW0_aXBzdW0"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("value, result", NOPAD_B64)
|
||||
def test_nopad_b64(value, result):
|
||||
assert nopad_b64(value.encode('utf-8')) == result
|
||||
|
||||
|
||||
@pytest.mark.parametrize("pem, der", TEST_PEM_DERS)
|
||||
def test_pem_to_der(pem, der, tmpdir):
|
||||
fn = tmpdir / 'test.pem'
|
||||
fn.write(pem)
|
||||
assert pem_to_der(str(fn)) == der
|
||||
Reference in New Issue
Block a user