Skip to content

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

More asserts

Fang-Pen Linb50d7157b94f
diff --git a/backend/bdd/features/pki/acme/auth.feature b/backend/bdd/features/pki/acme/auth.feature
index 6a542ea633..e81d3dd613 100644
--- a/backend/bdd/features/pki/acme/auth.feature
+++ b/backend/bdd/features/pki/acme/auth.feature
@@ -16,5 +16,12 @@ Feature: Order
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 the value order.authorizations[0] with jq .uri should match pattern {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/authorizations/(.+)
- Then the value order.authorizations[0] with jq . should be equal to {}
+ Then the value order.authorizations[0].uri with jq . should match pattern {BASE_URL}/api/v1/pki/acme/profiles/{acme_profile.id}/authorizations/(.+)
+ Then the value order.authorizations[0].body with jq .status should be equal to "pending"
+ Then the value order.authorizations[0].body with jq .identifier should be equal to json
+ """
+ {
+ "type": "dns",
+ "value": "localhost"
+ }
+ """
diff --git a/backend/bdd/features/steps/pki_acme.py b/backend/bdd/features/steps/pki_acme.py
index c5f8e068b5..db9e8a28a4 100644
--- a/backend/bdd/features/steps/pki_acme.py
+++ b/backend/bdd/features/steps/pki_acme.py
@@ -41,55 +41,53 @@ def replace_vars(payload: dict | list | int | float | str, vars: dict):
return payload
-def parse_glom_path(path_str: str):
+def parse_glom_path(path_str: str) -> glom.Path:
"""
Parse a glom path string with 'attr[index]' syntax into a Path object.
Examples:
- >>> parse_glom_path('authorizations[0].name')
- Path('authorizations', 0, 'name')
-
- >>> parse_glom_path('items[1].user[0].id')
- Path('items', 1, 'user', 0, 'id')
-
- >>> parse_glom_path('simple_attr')
- Path('simple_attr')
-
- >>> parse_glom_path('nested.attr')
- Path('nested', 'attr')
+ >>> parse_glom_path('authorizations[0]') == Path('authorizations', 0)
+ True
+ >>> parse_glom_path('data.items[1].name') == Path('data', 'items', 1, 'name')
+ True
+ >>> parse_glom_path('user.addresses[0].street') == Path('user', 'addresses', 0, 'street')
+ True
"""
- # Pattern to match attr[index] or just attr
- # Groups: (attr_name)(?:\[(index)\])?
- pattern = r"([a-zA-Z_][a-zA-Z0-9_]*)(?:\[(\d+)\])?"
-
- # Split on dots, but preserve the parts
parts = []
- current_pos = 0
-
- # Find all matches in the string
- for match in re.finditer(pattern, path_str):
- # Add any literal text before this match
- if match.start() > current_pos:
- before = path_str[current_pos : match.start()]
- raise ValueError(f"Invalid path syntax: unexpected text '{before}'")
-
- attr_name = match.group(1)
- index = match.group(2)
-
- # Add the attribute name
- parts.append(attr_name)
-
- # Add index if present
- if index is not None:
- parts.append(int(index))
-
- current_pos = match.end()
- # Check for trailing text
- if current_pos < len(path_str):
- after = path_str[current_pos:]
- if after != ".":
- raise ValueError(f"Invalid path syntax: unexpected text '{after}'")
+ # Split by dots, but preserve bracketed content
+ tokens = re.split(r"(?<!\[)\.(?![^\[]*\])", path_str)
+
+ for token in tokens:
+ token = token.strip()
+ if not token:
+ continue
+
+ # Check for attr[index] pattern
+ match = re.match(r"^(.+?)\[([^\]]+)\]$", token)
+ if match:
+ attr_name = match.group(1).strip()
+ index_str = match.group(2).strip()
+
+ # Parse index (support integers, slices, etc.)
+ if index_str.isdigit():
+ index = int(index_str)
+ elif "-" in index_str:
+ # Handle negative indices like [-1]
+ index = int(index_str)
+ elif ":" in index_str:
+ # Handle slices like [0:10]
+ index = slice(
+ *map(int, [x.strip() for x in index_str.split(":") if x.strip()])
+ )
+ else:
+ # Treat as string key
+ index = index_str
+
+ parts.extend([attr_name, index])
+ else:
+ # Plain attribute/key
+ parts.append(token)
return glom.Path(*parts)