More tests

This commit is contained in:
Fang-Pen Lin
2025-11-07 09:20:01 -08:00
parent 2cee9cf3cc
commit 52ae835d0f
2 changed files with 11 additions and 8 deletions
@@ -15,10 +15,10 @@ Feature: ACME Cert Profile
"acmeConfig": {} "acmeConfig": {}
} }
""" """
Then the value response.status_code should be equal to 201 Then the value response.status_code should be equal to 200
Then the value response with jq .eab_kid should be present Then the value response with jq .certificateProfile.slug should be equal to "{profile_slug}"
Then the value response with jq .eab_secret should be present Then the value response with jq .certificateProfile.caId should be equal to "{CERT_CA_ID}"
Then the value response with jq .slug should be equal to {profile_slug} Then the value response with jq .certificateProfile.certificateTemplateId should be equal to "{CERT_TEMPLATE_ID}"
Then the value response with jq .caId should be equal to {CA_ID} Then the value response with jq .certificateProfile.enrollmentType should be equal to "acme"
Then the value response with jq .certificateTemplateId should be equal to {CERT_TEMPLATE_ID} Then the value response with jq .certificateProfile.eab_kid should be present
Then the value response with jq .enrollmentTYpe should be equal to acme Then the value response with jq .certificateProfile.eab_secret should be present
+4 -1
View File
@@ -3,6 +3,7 @@ import logging
import re import re
import threading import threading
import httpx
import jq import jq
import requests import requests
import glom import glom
@@ -108,6 +109,8 @@ def eval_var(context: Context, var_path: str, as_json: bool = True):
value = value.to_json() value = value.to_json()
elif isinstance(value, requests.Response): elif isinstance(value, requests.Response):
value = value.json() value = value.json()
elif isinstance(value, httpx.Response):
value = value.json()
return value return value
@@ -327,7 +330,7 @@ def step_impl(context: Context, var_path: str, jq_query: str, expected: str):
var_path=var_path, var_path=var_path,
jq_query=jq_query, jq_query=jq_query,
) )
expected_value = json.loads(expected) expected_value = replace_vars(json.loads(expected), context.vars)
assert result == expected_value, ( assert result == expected_value, (
f"{json.dumps(value)!r} with jq {jq_query!r}, the result {json.dumps(result)!r} does not match {json.dumps(expected_value)!r}" f"{json.dumps(value)!r} with jq {jq_query!r}, the result {json.dumps(result)!r} does not match {json.dumps(expected_value)!r}"
) )