mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 23:26:20 +00:00
Isolate vars
This commit is contained in:
@@ -185,28 +185,33 @@ def bootstrap_infisical(context: Context):
|
|||||||
|
|
||||||
|
|
||||||
def before_all(context: Context):
|
def before_all(context: Context):
|
||||||
|
base_vars = {
|
||||||
|
"BASE_URL": BASE_URL,
|
||||||
|
"PEBBLE_URL": PEBBLE_URL,
|
||||||
|
}
|
||||||
if BOOTSTRAP_INFISICAL:
|
if BOOTSTRAP_INFISICAL:
|
||||||
details = bootstrap_infisical(context)
|
details = bootstrap_infisical(context)
|
||||||
context.vars = {
|
vars = base_vars | {
|
||||||
"BASE_URL": BASE_URL,
|
|
||||||
"PEBBLE_URL": PEBBLE_URL,
|
|
||||||
"PROJECT_ID": details["project"]["id"],
|
"PROJECT_ID": details["project"]["id"],
|
||||||
"CERT_CA_ID": details["ca"]["id"],
|
"CERT_CA_ID": details["ca"]["id"],
|
||||||
"CERT_TEMPLATE_ID": details["cert_template"]["id"],
|
"CERT_TEMPLATE_ID": details["cert_template"]["id"],
|
||||||
"AUTH_TOKEN": details["auth_token"],
|
"AUTH_TOKEN": details["auth_token"],
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
context.vars = {
|
vars = base_vars | {
|
||||||
"BASE_URL": BASE_URL,
|
|
||||||
"PEBBLE_URL": PEBBLE_URL,
|
|
||||||
"PROJECT_ID": PROJECT_ID,
|
"PROJECT_ID": PROJECT_ID,
|
||||||
"CERT_CA_ID": CERT_CA_ID,
|
"CERT_CA_ID": CERT_CA_ID,
|
||||||
"CERT_TEMPLATE_ID": CERT_TEMPLATE_ID,
|
"CERT_TEMPLATE_ID": CERT_TEMPLATE_ID,
|
||||||
"AUTH_TOKEN": AUTH_TOKEN,
|
"AUTH_TOKEN": AUTH_TOKEN,
|
||||||
}
|
}
|
||||||
|
context._initial_vars = vars
|
||||||
context.http_client = httpx.Client(base_url=BASE_URL)
|
context.http_client = httpx.Client(base_url=BASE_URL)
|
||||||
|
|
||||||
|
|
||||||
|
def before_scenario(context: Context, scenario: typing.Any):
|
||||||
|
context.vars = deepcopy(context._initial_vars)
|
||||||
|
|
||||||
|
|
||||||
def after_scenario(context: Context, scenario: typing.Any):
|
def after_scenario(context: Context, scenario: typing.Any):
|
||||||
if hasattr(context, "web_server"):
|
if hasattr(context, "web_server"):
|
||||||
context.web_server.shutdown_and_server_close()
|
context.web_server.shutdown_and_server_close()
|
||||||
|
|||||||
@@ -387,8 +387,9 @@ def register_account_with_eab(
|
|||||||
):
|
):
|
||||||
acme_client = context.acme_client
|
acme_client = context.acme_client
|
||||||
account_public_key = acme_client.net.key.public_key()
|
account_public_key = acme_client.net.key.public_key()
|
||||||
# clear the account in case if we want to register twice
|
if not only_return_existing:
|
||||||
acme_client.net.account = None
|
# clear the account in case if we want to register twice
|
||||||
|
acme_client.net.account = None
|
||||||
if hasattr(context, "alt_eab_url"):
|
if hasattr(context, "alt_eab_url"):
|
||||||
eab_directory = messages.Directory.from_json(
|
eab_directory = messages.Directory.from_json(
|
||||||
{"newAccount": context.alt_eab_url}
|
{"newAccount": context.alt_eab_url}
|
||||||
@@ -408,8 +409,14 @@ def register_account_with_eab(
|
|||||||
only_return_existing=only_return_existing,
|
only_return_existing=only_return_existing,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
context.vars[account_var] = acme_client.new_account(registration)
|
if not only_return_existing:
|
||||||
|
context.vars[account_var] = acme_client.new_account(registration)
|
||||||
|
else:
|
||||||
|
context.vars[account_var] = acme_client.query_registration(
|
||||||
|
acme_client.net.account
|
||||||
|
)
|
||||||
except Exception as exp:
|
except Exception as exp:
|
||||||
|
logger.error(f"Failed to register: {exp}", exc_info=True)
|
||||||
context.vars["error"] = exp
|
context.vars["error"] = exp
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user