mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
More test cases
This commit is contained in:
@@ -6,6 +6,14 @@ Feature: Account
|
||||
Then I register a new ACME account with email fangpen@infisical.com 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 fangpen@infisical.com 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 fangpen@infisical.com 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
|
||||
|
||||
@@ -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}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user