Add ACME cert profile creation feature

This commit is contained in:
Fang-Pen Lin
2025-11-07 09:19:58 -08:00
parent 3a84e9a50e
commit ebb4260386
5 changed files with 80 additions and 0 deletions
+25
View File
@@ -2,6 +2,7 @@ import json
import re
import threading
import faker
import jq
import requests
import glom
@@ -107,6 +108,11 @@ def eval_var(context: Context, var_path: str, as_json: bool = True):
return value
@given("I make a random {faker_type} as {var_name}")
def step_impl(context: Context, faker_type: str, var_name: str):
context.vars[var_name] = getattr(faker, faker_type)()
@given('I have an ACME cert profile as "{profile_var}"')
def step_impl(context: Context, profile_var: str):
# TODO: Fixed value for now, just to make test much easier,
@@ -121,6 +127,13 @@ def step_impl(context: Context, method: str, url: str):
context.response = context.http_client.request(method, url.format(**context.vars))
@when('I send a {method} request to "{url}" with JSON payload')
def step_impl(context: Context, method: str, url: str):
context.response = context.http_client.request(
method, url.format(**context.vars), json_payload=context.text
)
@when("I have an ACME client connecting to {url}")
def step_impl(context: Context, url: str):
private_key = rsa.generate_private_key(
@@ -260,6 +273,18 @@ def step_impl(context: Context, var_path: str, jq_query: str):
)
@then("the value {var_path} with jq {jq_query} should be present")
def step_impl(context: Context, var_path: str, jq_query: str):
value, result = apply_value_with_jq(
context=context,
var_path=var_path,
jq_query=jq_query,
)
assert result, (
f"{json.dumps(value)!r} with jq {jq_query!r}, the result {json.dumps(result)!r} is not present"
)
@then("the value {var_path} with jq {jq_query} should be equal to {expected}")
def step_impl(context: Context, var_path: str, jq_query: str, expected: str):
value, result = apply_value_with_jq(