Skip to content

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

More test cases

Fang-Pen Lin26bb0e51d8fc
diff --git a/backend/bdd/features/pki/acme/account.feature b/backend/bdd/features/pki/acme/account.feature
index 4df6756695..e3673aee7f 100644
--- a/backend/bdd/features/pki/acme/account.feature
+++ b/backend/bdd/features/pki/acme/account.feature
@@ -6,6 +6,14 @@ Feature: Account
Then I register a new ACME account with email [email protected] and EAB key id "{acme_profile.eab_kid}" with secret "{acme_profile.eab_secret}" as acme_account
Then the value acme_account.uri with jq "." should match pattern {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/accounts/(.+)
+ Scenario: Find existing account
+ 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
+ Then I register a new ACME account with email [email protected] and EAB key id "{acme_profile.eab_kid}" with secret "{acme_profile.eab_secret}" as acme_account
+ Then I memorize acme_account.uri as account_uri
+ Then I find the existing ACME account with email [email protected] and EAB key id "{acme_profile.eab_kid}" with secret "{acme_profile.eab_secret}" as acme_account
+ Then the value acme_account.uri should be equal to "{account_uri}"
+
Scenario: Create a new account without EAB
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
diff --git a/backend/bdd/features/steps/pki_acme.py b/backend/bdd/features/steps/pki_acme.py
index c4da1f91a4..f6e8a26363 100644
--- a/backend/bdd/features/steps/pki_acme.py
+++ b/backend/bdd/features/steps/pki_acme.py
@@ -237,10 +237,14 @@ def step_impl(context: Context, url: str):
context.alt_eab_url = replace_vars(url, context.vars)
-@then(
- 'I register a new ACME account with email {email} and EAB key id "{kid}" with secret "{secret}" as {account_var}'
-)
-def step_impl(context: Context, email: str, kid: str, secret: str, account_var: str):
+def register_account_with_eab(
+ context: Context,
+ email: str,
+ kid: str,
+ secret: str,
+ account_var: str,
+ only_return_existing: bool = False,
+):
acme_client = context.acme_client
account_public_key = acme_client.net.key.public_key()
if hasattr(context, "alt_eab_url"):
@@ -259,6 +263,7 @@ def step_impl(context: Context, email: str, kid: str, secret: str, account_var:
registration = messages.NewRegistration.from_data(
email=email,
external_account_binding=eab,
+ only_return_existing=only_return_existing,
)
try:
context.vars[account_var] = acme_client.new_account(registration)
@@ -266,6 +271,29 @@ def step_impl(context: Context, email: str, kid: str, secret: str, account_var:
context.vars["error"] = exp
+@then(
+ 'I register a new ACME account with email {email} and EAB key id "{kid}" with secret "{secret}" as {account_var}'
+)
+def step_impl(context: Context, email: str, kid: str, secret: str, account_var: str):
+ register_account_with_eab(
+ context=context, email=email, kid=kid, secret=secret, account_var=account_var
+ )
+
+
+@then(
+ 'I find the existing ACME account with email {email} and EAB key id "{kid}" with secret "{secret}" as {account_var}'
+)
+def step_impl(context: Context, email: str, kid: str, secret: str, account_var: str):
+ register_account_with_eab(
+ context=context,
+ email=email,
+ kid=kid,
+ secret=secret,
+ account_var=account_var,
+ only_return_existing=True,
+ )
+
+
@then("I register a new ACME account with email {email} without EAB")
def step_impl(context: Context, email: str):
acme_client = context.acme_client
@@ -451,7 +479,7 @@ def step_impl(context: Context, var_path: str):
@then("the value {var_path} should be equal to {expected}")
def step_impl(context: Context, var_path: str, expected: str):
value = eval_var(context, var_path)
- expected_value = json.loads(expected)
+ expected_value = replace_vars(json.loads(expected), context.vars)
assert value == expected_value, f"{value!r} does not match {expected_value!r}"