From 52ae835d0fe707714c0c48650aac80e37ba386a4 Mon Sep 17 00:00:00 2001 From: Fang-Pen Lin Date: Mon, 3 Nov 2025 13:19:34 -0800 Subject: [PATCH] More tests --- backend/bdd/features/pki/acme/cert-profile.feature | 14 +++++++------- backend/bdd/features/steps/pki_acme.py | 5 ++++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/backend/bdd/features/pki/acme/cert-profile.feature b/backend/bdd/features/pki/acme/cert-profile.feature index 7e4dbdc84..1fc6f0dae 100644 --- a/backend/bdd/features/pki/acme/cert-profile.feature +++ b/backend/bdd/features/pki/acme/cert-profile.feature @@ -15,10 +15,10 @@ Feature: ACME Cert Profile "acmeConfig": {} } """ - Then the value response.status_code should be equal to 201 - Then the value response with jq .eab_kid should be present - Then the value response with jq .eab_secret should be present - Then the value response with jq .slug should be equal to {profile_slug} - Then the value response with jq .caId should be equal to {CA_ID} - Then the value response with jq .certificateTemplateId should be equal to {CERT_TEMPLATE_ID} - Then the value response with jq .enrollmentTYpe should be equal to acme + Then the value response.status_code should be equal to 200 + Then the value response with jq .certificateProfile.slug should be equal to "{profile_slug}" + Then the value response with jq .certificateProfile.caId should be equal to "{CERT_CA_ID}" + Then the value response with jq .certificateProfile.certificateTemplateId should be equal to "{CERT_TEMPLATE_ID}" + Then the value response with jq .certificateProfile.enrollmentType should be equal to "acme" + Then the value response with jq .certificateProfile.eab_kid should be present + Then the value response with jq .certificateProfile.eab_secret should be present diff --git a/backend/bdd/features/steps/pki_acme.py b/backend/bdd/features/steps/pki_acme.py index 0bd55e397..f2008e867 100644 --- a/backend/bdd/features/steps/pki_acme.py +++ b/backend/bdd/features/steps/pki_acme.py @@ -3,6 +3,7 @@ import logging import re import threading +import httpx import jq import requests import glom @@ -108,6 +109,8 @@ def eval_var(context: Context, var_path: str, as_json: bool = True): value = value.to_json() elif isinstance(value, requests.Response): value = value.json() + elif isinstance(value, httpx.Response): + value = value.json() return value @@ -327,7 +330,7 @@ def step_impl(context: Context, var_path: str, jq_query: str, expected: str): var_path=var_path, jq_query=jq_query, ) - expected_value = json.loads(expected) + expected_value = replace_vars(json.loads(expected), context.vars) 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}" )