Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
More test cases
Fang-Pen Lina0571002743f
diff --git a/backend/bdd/features/pki/acme/access-control.feature b/backend/bdd/features/pki/acme/access-control.featureindex f39d087a3b..96da3f7c89 100644--- a/backend/bdd/features/pki/acme/access-control.feature+++ b/backend/bdd/features/pki/acme/access-control.feature@@ -2,7 +2,7 @@ Feature: Access ControlScenario Outline: Access across resources across different accountGiven 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+ 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_account0Then I memorize acme_account0.uri with jq "capture("/(?<id>[^/]+)$") | .id" as account0_idWhen I create certificate signing request as csr@@ -34,7 +34,7 @@ Feature: Access ControlThen the value response.status_code should not be equal to 404And I put away current ACME client as client0- When I have an ACME client connecting to {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/directory+ 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_account1Then I peak and memorize the next nonce as nonceWhen I send a raw ACME request to "<url>"@@ -62,7 +62,87 @@ Feature: Access ControlScenario Outline: Access resources across a different profileGiven 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+ 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_account0+ Then I memorize acme_account0.uri with jq "capture("/(?<id>[^/]+)$") | .id" as account0_id+ When I create certificate signing request as csr+ Then I add names to certificate signing request csr+ """+ {+ "COMMON_NAME": "localhost"+ }+ """+ Then I create a RSA private key pair as cert_key+ Then I sign the certificate signing request csr with private key cert_key and output it as csr_pem in PEM format+ Then I submit the certificate signing request PEM csr_pem certificate order to the ACME server as order+ Then I peak and memorize the next nonce as nonce+ Then I memorize <src_var> with jq "<jq>" as <dest_var>+ When I send a raw ACME request to "<url>"+ """+ {+ "protected": {+ "alg": "RS256",+ "nonce": "{nonce}",+ "url": "<url>",+ "kid": "{acme_account0.uri}"+ },+ "payload": {"invalid": "payload"}+ }+ """+ # With original owner account under their profile, the invalid payload is going to trigger other errors instead of+ # 404, this is to make sure that our URLs are actually correct+ Then the value response.status_code should not be equal to 404+ And I put away current ACME client as client0++ Given I make a random slug as profile_slug+ Given I use AUTH_TOKEN for authentication+ When I send a "POST" request to "/api/v1/pki/certificate-profiles" with JSON payload+ """+ {+ "projectId": "{PROJECT_ID}",+ "slug": "{profile_slug}",+ "description": "",+ "enrollmentType": "acme",+ "caId": "{CERT_CA_ID}",+ "certificateTemplateId": "{CERT_TEMPLATE_ID}",+ "acmeConfig": {}+ }+ """+ Then the value response.status_code should be equal to 200+ Then I memorize response with jq ".certificateProfile.id" as profile_id+ When I send a "GET" request to "/api/v1/pki/certificate-profiles/{profile_id}/acme/eab-secret/reveal"+ Then I memorize response with jq ".eabKid" as eab_kid+ And I memorize response with jq ".eabSecret" as eab_secret+ When I have an ACME client connecting to "{BASE_URL}/api/v1/pki/acme/profiles/{profile_id}/directory"+ Then I register a new ACME account with email [email protected] and EAB key id "{eab_kid}" with secret "{eab_secret}" as acme_account1+ Then I peak and memorize the next nonce as nonce+ Then I memorize <src_var> with jq "<jq>" as <dest_var>+ When I send a raw ACME request to "<url>"+ """+ {+ "protected": {+ "alg": "RS256",+ "nonce": "{nonce}",+ "url": "<url>",+ "kid": "{acme_account1.uri}"+ },+ "raw_payload": "<payload>"+ }+ """+ Then the value response.status_code should be equal to 404++ Examples: Endpoints+ | src_var | jq | dest_var | url | payload |+ | order | . | not_used | {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/accounts/{account0_id}/orders | |+ | order | . | not_used | {order.uri} | |+ | order | . | not_used | {order.uri}/finalize | {\"csr\": \"\"} |+ | order | . | not_used | {order.uri}/certificate | |+ | order | .authorizations[0].uri | auth_uri | {auth_uri} | |+ | order | .authorizations[0].body.challenges[0].url | challenge_uri | {challenge_uri} | {} |++ Scenario Outline: Access resources across a different profile with the same key pair+ 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_account0Then I memorize acme_account0.uri with jq "capture("/(?<id>[^/]+)$") | .id" as account0_idWhen I create certificate signing request as csr@@ -99,7 +179,7 @@ Feature: Access ControlWhen I send a "GET" request to "/api/v1/pki/certificate-profiles/{profile_id}/acme/eab-secret/reveal"Then I memorize response with jq ".eabKid" as eab_kidAnd I memorize response with jq ".eabSecret" as eab_secret- When I have an ACME client connecting to {BASE_URL}/api/v1/pki/acme/profiles/{profile_id}/directory+ When I have an ACME client connecting to "{BASE_URL}/api/v1/pki/acme/profiles/{profile_id}/directory" with the key pair from client0Then I register a new ACME account with email [email protected] and EAB key id "{eab_kid}" with secret "{eab_secret}" as acme_account1Then I peak and memorize the next nonce as nonceThen I memorize <src_var> with jq "<jq>" as <dest_var>@@ -126,9 +206,10 @@ Feature: Access Control| order | .authorizations[0].uri | auth_uri | {auth_uri} | || order | .authorizations[0].body.challenges[0].url | challenge_uri | {challenge_uri} | {} |+Scenario Outline: URL mismatchGiven 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+ 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_accountThen I memorize acme_account.uri with jq "capture("/(?<id>[^/]+)$") | .id" as account_idWhen I create certificate signing request as csrdiff --git a/backend/bdd/features/pki/acme/account.feature b/backend/bdd/features/pki/acme/account.featureindex 2c0ce35661..589c5ab244 100644--- a/backend/bdd/features/pki/acme/account.feature+++ b/backend/bdd/features/pki/acme/account.feature@@ -2,13 +2,13 @@ Feature: AccountScenario: Create a new accountGiven 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+ 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_accountAnd the value acme_account.uri with jq "." should match pattern {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/accounts/(.+)Scenario: Find an existing accountGiven 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+ 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_accountAnd I memorize acme_account.uri as account_uriAnd 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@@ -16,13 +16,13 @@ Feature: AccountScenario: Create a new account without EABGiven 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+ 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] without EABAnd the value error with jq ".type" should be equal to "urn:ietf:params:acme:error:externalAccountRequired"Scenario Outline: Scenario: Create a new account with bad EAB credentialsGiven 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+ 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 "<eab_kid>" with secret "<eab_secret>" as acme_accountAnd the value error with jq ".type" should be equal to "<error_type>"And the value error with jq ".detail" should be equal to "<error_msg>"@@ -38,7 +38,7 @@ Feature: AccountScenario Outline: Scenario: Create a new account with bad EAB urlGiven 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+ When I have an ACME client connecting to "{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/directory"And I use a different new-account URL "<url>" for EAB signatureThen 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_accountAnd the value error with jq ".type" should be equal to "urn:ietf:params:acme:error:externalAccountRequired"diff --git a/backend/bdd/features/pki/acme/auth.feature b/backend/bdd/features/pki/acme/auth.featureindex 65b8ec114a..46cc9d4e25 100644--- a/backend/bdd/features/pki/acme/auth.feature+++ b/backend/bdd/features/pki/acme/auth.feature@@ -2,7 +2,7 @@ Feature: AuthorizationScenario: Get authorizationGiven 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+ 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_accountWhen I create certificate signing request as csrThen I add names to certificate signing request csrdiff --git a/backend/bdd/features/pki/acme/cert-profile.feature b/backend/bdd/features/pki/acme/cert-profile.featureindex 92a921ddef..3c292e8baf 100644--- a/backend/bdd/features/pki/acme/cert-profile.feature+++ b/backend/bdd/features/pki/acme/cert-profile.feature@@ -45,5 +45,5 @@ Feature: ACME Cert ProfileAnd the value response with jq ".eabSecret" should be presentAnd I memorize response with jq ".eabKid" as eab_kidAnd I memorize response with jq ".eabSecret" as eab_secret- When I have an ACME client connecting to {BASE_URL}/api/v1/pki/acme/profiles/{profile_id}/directory+ When I have an ACME client connecting to "{BASE_URL}/api/v1/pki/acme/profiles/{profile_id}/directory"Then I register a new ACME account with email [email protected] and EAB key id "{eab_kid}" with secret "{eab_secret}" as acme_accountdiff --git a/backend/bdd/features/pki/acme/challenge.feature b/backend/bdd/features/pki/acme/challenge.featureindex b36a3e328e..bee46c3fb9 100644--- a/backend/bdd/features/pki/acme/challenge.feature+++ b/backend/bdd/features/pki/acme/challenge.feature@@ -2,7 +2,7 @@ Feature: ChallengeScenario: Validate challengeGiven 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+ 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_accountWhen I create certificate signing request as csrThen I add names to certificate signing request csrdiff --git a/backend/bdd/features/pki/acme/nonce.feature b/backend/bdd/features/pki/acme/nonce.featureindex 601c53a859..9a55ae2845 100644--- a/backend/bdd/features/pki/acme/nonce.feature+++ b/backend/bdd/features/pki/acme/nonce.feature@@ -8,7 +8,7 @@ Feature: NonceScenario Outline: Send a bad nonce to account endpointsGiven 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+ 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_accountAnd I memorize acme_account.uri with jq "capture("/(?<id>[^/]+)$") | .id" as account_idWhen I create certificate signing request as csr@@ -51,7 +51,7 @@ Feature: NonceScenario Outline: Send the same nonce twiceGiven 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+ 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_accountAnd I memorize acme_account.uri with jq "capture("/(?<id>[^/]+)$") | .id" as account_idWhen I create certificate signing request as csrdiff --git a/backend/bdd/features/pki/acme/order.feature b/backend/bdd/features/pki/acme/order.featureindex 9e8b47980b..19f467f00a 100644--- a/backend/bdd/features/pki/acme/order.feature+++ b/backend/bdd/features/pki/acme/order.feature@@ -2,7 +2,7 @@ Feature: OrderScenario: Create a new orderGiven 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+ 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_accountWhen I create certificate signing request as csrThen I add names to certificate signing request csr@@ -22,7 +22,7 @@ Feature: OrderScenario: Create a new order with SANsGiven 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+ 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_accountWhen I create certificate signing request as csrThen I add names to certificate signing request csr@@ -52,7 +52,7 @@ Feature: OrderScenario: Fetch an orderGiven 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+ 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_accountWhen I create certificate signing request as csrThen I add names to certificate signing request csr@@ -72,7 +72,7 @@ Feature: OrderScenario Outline: Create an order with invalid identifier typesGiven 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+ 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_accountAnd I peak and memorize the next nonce as nonceWhen I send a raw ACME request to "{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/new-order"@@ -105,7 +105,7 @@ Feature: OrderScenario Outline: Create an order with invalid identifier valuesGiven 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+ 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_accountAnd I peak and memorize the next nonce as nonceWhen I send a raw ACME request to "{BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/new-order"@@ -129,7 +129,7 @@ Feature: OrderAnd the value response with jq ".status" should be equal to 400And the value response with jq ".type" should be equal to "urn:ietf:params:acme:error:unsupportedIdentifier"And the value response with jq ".detail" should be equal to "Invalid DNS identifier"-+Examples: Bad Identifier Vluaes| identifier_value || 127.0.0.1 |diff --git a/backend/bdd/features/steps/pki_acme.py b/backend/bdd/features/steps/pki_acme.pyindex 88c31c4a06..1d20cd9bdd 100644--- a/backend/bdd/features/steps/pki_acme.py+++ b/backend/bdd/features/steps/pki_acme.py@@ -191,23 +191,34 @@ def step_impl(context: Context, method: str, url: str):logger.debug("Response JSON payload: %r", response.json())-@when("I have an ACME client connecting to {url}")-def step_impl(context: Context, url: str):- private_key = rsa.generate_private_key(- public_exponent=ACC_KEY_PUBLIC_EXPONENT, key_size=ACC_KEY_BITS- )- pem_bytes = private_key.private_bytes(- encoding=serialization.Encoding.PEM,- format=serialization.PrivateFormat.PKCS8,- encryption_algorithm=serialization.NoEncryption(),- )- acc_jwk = JWKRSA.load(pem_bytes)+def create_acme_client(context: Context, url: str, acc_jwk: JWKRSA | None = None):+ if acc_jwk is None:+ private_key = rsa.generate_private_key(+ public_exponent=ACC_KEY_PUBLIC_EXPONENT, key_size=ACC_KEY_BITS+ )+ pem_bytes = private_key.private_bytes(+ encoding=serialization.Encoding.PEM,+ format=serialization.PrivateFormat.PKCS8,+ encryption_algorithm=serialization.NoEncryption(),+ )+ acc_jwk = JWKRSA.load(pem_bytes)net = client.ClientNetwork(acc_jwk)directory_url = url.format(**context.vars)directory = client.ClientV2.get_directory(directory_url, net)context.acme_client = client.ClientV2(directory, net=net)+@when('I have an ACME client connecting to "{url}"')+def step_impl(context: Context, url: str):+ create_acme_client(context, url)+++@when('I have an ACME client connecting to "{url}" with the key pair from {client_var}')+def step_impl(context: Context, url: str, client_var: str):+ another_client = eval_var(context, client_var, as_json=False)+ create_acme_client(context, url, acc_jwk=another_client.net.key)++@then('the response status code should be "{expected_status_code:d}"')def step_impl(context: Context, expected_status_code: int):assert context.vars["response"].status_code == expected_status_code, (