fix: dash in identifiers

This commit is contained in:
Piotr Dec 2026-06-11 16:50:48 +02:00
parent 3ec1942b4e
commit 2acfcc871f
Signed by: stawros
GPG key ID: 74B18A3F0F1E99C0
3 changed files with 8 additions and 4 deletions

View file

@ -9,7 +9,7 @@ from karl.services import Passwords
class ValueTemplate(Template): class ValueTemplate(Template):
# Pozwala na kropki i ukośniki w nazwach placeholderów, np. ${user.name/first} # Pozwala na kropki i ukośniki w nazwach placeholderów, np. ${user.name/first}
idpattern = r'[_a-zA-Z][_a-zA-Z0-9.\/]*' idpattern = r'[_a-zA-Z][_a-zA-Z0-9.\/\-]*'
@injectable @injectable

View file

@ -5,3 +5,6 @@ custom=${custom.field}
uname=${sample.username} uname=${sample.username}
invalid=${double.dot.example} invalid=${double.dot.example}
#some comment
dashed=${some/dashed}

View file

@ -1,7 +1,6 @@
from pathlib import Path from pathlib import Path
import pytest import pytest
import yaml
from karl.services import Passwords from karl.services import Passwords
from karl.services.mo import Mo from karl.services.mo import Mo
@ -31,11 +30,10 @@ def test1_content(target_path: Path):
content = target_path.read_text() content = target_path.read_text()
assert '${' not in content assert '${' not in content
props = {} props = {}
prop_lines = content.split('\n') prop_lines = content.split('\n')
for line in prop_lines: for line in prop_lines:
if len(line)> 1: if len(line) > 1 and not line.startswith("#"):
splitted = line.split('=') splitted = line.split('=')
props[splitted[0]] = splitted[1] props[splitted[0]] = splitted[1]
# props = {prop[0]:prop[1] for prop in content.split('\n')} # props = {prop[0]:prop[1] for prop in content.split('\n')}
@ -54,6 +52,9 @@ class TestEnvParsing:
def test_mixed(self, test1_content: dict): def test_mixed(self, test1_content: dict):
assert test1_content['mixed'] == 'nested_username' assert test1_content['mixed'] == 'nested_username'
def test_dashed(self, test1_content: dict):
assert test1_content['dashed'] == 'dd-value'
def test_custom_field(self, test1_content: dict): def test_custom_field(self, test1_content: dict):
assert test1_content['custom'] == 'custom_content' assert test1_content['custom'] == 'custom_content'