Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cfc/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from .config import config

NAME_PATTERN = r"^[^\-\.][\w\-\.]+$"
ENV_VARS_PATTERN = r"^([\w:.\/\-]+=[\w:.\/\-]+)(,[\w:.\/\-]+=[\w:.\/\-]+)*$"
ENV_VARS_PATTERN = r"^([\w:.\/\-]+=[^=,\s]+)(,[\w:.\/\-]+=[^=,\s]+)*$"
Comment thread
jens-kuerten marked this conversation as resolved.
Comment thread
jens-kuerten marked this conversation as resolved.
ENVIRONMENT_ENVVAR_NAME = "CFC_ENVIRONMENT"

env_app = typer.Typer()
Expand Down
10 changes: 10 additions & 0 deletions tests/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ def test_env_var_callback(self):
# test empty input
env_var_callback("")

# test special characters in values
env_var_callback("VAR1=p@ssw0rd!")
env_var_callback("VAR1=value#1")
env_var_callback("VAR1=hello!,VAR2=world?")
env_var_callback("SECRET=abc$def%ghi^jkl&mno*pqr")

# test invalid input
with self.assertRaises(typer.BadParameter):
env_var_callback("VAR1=VALUE1,VAR2=VALUE2,")
with self.assertRaises(typer.BadParameter):
env_var_callback("VAR1=VALUE1,VAR2=VALUE2,VAR3")
with self.assertRaises(typer.BadParameter):
env_var_callback("VAR1=VALUE1,VAR2=VALUE2,VAR3=VALUE3=")
with self.assertRaises(typer.BadParameter):
env_var_callback("VAR1=value with spaces")
with self.assertRaises(typer.BadParameter):
env_var_callback("VAR1=val1,VAR2=val=2")
Loading