Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Fix challenge bdd tests

Fang-Pen Linf14df38eaaad
diff --git a/backend/bdd/features/pki/acme/challenge.feature b/backend/bdd/features/pki/acme/challenge.feature
index 543e4cea35..b4aaa1a345 100644
--- a/backend/bdd/features/pki/acme/challenge.feature
+++ b/backend/bdd/features/pki/acme/challenge.feature
@@ -20,6 +20,8 @@ Feature: Challenge
And I poll and finalize the ACME order order as finalized_order
And the value finalized_order.body with jq ".status" should be equal to "valid"
+ # TODO: add challenge with SANs
+
Scenario: Did not finish all challenges
Given I have an ACME cert profile as "acme_profile"
When I have an ACME client connecting to "{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/directory"
@@ -151,6 +153,7 @@ Feature: Challenge
And I memorize response.headers with jq ".["replay-nonce"]" as nonce
And I memorize response as order
And I pass all challenges with type http-01 for order in order
+ And I encode CSR csr_pem as JOSE Base-64 DER as base64_csr_der
When I send a raw ACME request to "{finalize_url}"
"""
{
@@ -161,11 +164,11 @@ Feature: Challenge
"kid": "{acme_account.uri}"
},
"payload": {
- "csr": "{csr_pem}"
+ "csr": "{base64_csr_der}"
}
}
"""
Then the value response.status_code should be equal to 400
And the value response with jq ".status" should be equal to 400
- And the value response with jq ".type" should be equal to "urn:ietf:params:acme:error:malformed"
- And the value response with jq ".detail" should be equal to "<error_detail>"
+ And the value response with jq ".type" should be equal to "urn:ietf:params:acme:error:badCSR"
+ And the value response with jq ".detail" should be equal to "Invalid CSR: Common name + SANs mismatch with order identifiers"
diff --git a/backend/bdd/features/steps/pki_acme.py b/backend/bdd/features/steps/pki_acme.py
index f8e6da300c..604aa5e7a1 100644
--- a/backend/bdd/features/steps/pki_acme.py
+++ b/backend/bdd/features/steps/pki_acme.py
@@ -389,6 +389,15 @@ def step_impl(context: Context, url: str):
send_raw_acme_req(context, url)
+@then(
+ "I encode CSR {pem_var} as JOSE Base-64 DER as {var_name}",
+)
+def step_impl(context: Context, pem_var: str, var_name: str):
+ csr = eval_var(context, pem_var)
+ parsed_csr = x509.load_pem_x509_csr(csr)
+ context.vars[var_name] = json_util.encode_csr(parsed_csr)
+
+
@then(
"I submit the certificate signing request PEM {pem_var} certificate order to the ACME server as {order_var}"
)