Skip to content

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

Fix all broken tests

Fang-Pen Lin65b61514ae9e
diff --git a/backend/bdd/features/pki/acme/order.feature b/backend/bdd/features/pki/acme/order.feature
index 2a85dc84ce..046dcda55e 100644
--- a/backend/bdd/features/pki/acme/order.feature
+++ b/backend/bdd/features/pki/acme/order.feature
@@ -19,7 +19,7 @@ Feature: Order
Then the value order.body with jq ".status" should be equal to "pending"
Then the value order.body with jq ".identifiers" should be equal to [{"type": "dns", "value": "localhost"}]
Then the value order.body with jq ".finalize" should match pattern {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/orders/(.+)/finalize
- Then the value order.body with jq "all(.authorizations[]; startswith('{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/authorizations/'))" should be equal to true
+ Then the value order.body with jq "all(.authorizations[]; startswith("{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/authorizations/"))" should be equal to true
Scenario: Create a new order with SANs
Given I have an ACME cert profile as "acme_profile"
@@ -71,4 +71,4 @@ Feature: Order
Then the value fetched_order with jq ".status" should be equal to "pending"
Then the value fetched_order with jq ".identifiers" should be equal to [{"type": "dns", "value": "localhost"}]
Then the value fetched_order with jq ".finalize" should match pattern {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/orders/(.+)/finalize
- Then the value fetched_order with jq "all(.authorizations[]; startswith('{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/authorizations/'))" should be equal to true
+ Then the value fetched_order with jq "all(.authorizations[]; startswith("{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/authorizations/"))" should be equal to true
diff --git a/backend/bdd/features/steps/pki_acme.py b/backend/bdd/features/steps/pki_acme.py
index 30482c5b32..3441b851ae 100644
--- a/backend/bdd/features/steps/pki_acme.py
+++ b/backend/bdd/features/steps/pki_acme.py
@@ -160,7 +160,10 @@ def step_impl(context: Context, method: str, url: str):
)
context.vars["response"] = response
logger.debug("Response status: %r", response.status_code)
- logger.debug("Response JSON payload: %r", response.json())
+ try:
+ logger.debug("Response JSON payload: %r", response.json())
+ except json.decoder.JSONDecodeError:
+ pass
@when('I send a {method} request to "{url}" with JSON payload')
@@ -203,14 +206,14 @@ def step_impl(context: Context, url: str):
@then('the response status code should be "{expected_status_code:d}"')
def step_impl(context: Context, expected_status_code: int):
- assert context.response.status_code == expected_status_code, (
- f"{context.response.status_code} != {expected_status_code}"
+ assert context.vars["response"].status_code == expected_status_code, (
+ f"{context.vars['response'].status_code} != {expected_status_code}"
)
@then('the response header "{header}" should contains non-empty value')
def step_impl(context: Context, header: str):
- header_value = context.response.headers.get(header)
+ header_value = context.vars["response"].headers.get(header)
assert header_value is not None, f"Header {header} not found in response"
assert header_value, (
f"Header {header} found in response, but value {header_value:!r} is empty"
@@ -219,7 +222,7 @@ def step_impl(context: Context, header: str):
@then("the response body should match JSON value")
def step_impl(context: Context):
- payload = context.response.json()
+ payload = context.vars["response"].json()
expected = json.loads(context.text)
replaced = replace_vars(expected, context.vars)
assert payload == replaced, f"{payload} != {replaced}"