mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: add repository name sanitization to prevent invalid characters in poetry config
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -183,6 +183,41 @@ def test_apply_multiple_repositories(tmp_path) -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_apply_sanitizes_poetry_repository_name_with_special_characters(
|
||||
tmp_path,
|
||||
) -> None:
|
||||
data = {
|
||||
"uuid": "12345678-1234-5678-1234-567812345678",
|
||||
"organisation": "InterDiode",
|
||||
"configurations": {
|
||||
"python": {
|
||||
"repositories": [
|
||||
{
|
||||
"name": "weird.name]here[bad",
|
||||
"index-url": "https://example.invalid/simple",
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
config = Configuration.model_validate(data)
|
||||
dst = tmp_path / "dst"
|
||||
context = Context(config=config, dst=dst, src=None)
|
||||
|
||||
PythonModule().apply(context)
|
||||
|
||||
poetry_config = (dst / "root/.config/pypoetry/config.toml").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
assert poetry_config == (
|
||||
"[repositories.weird_name_here_bad]\n"
|
||||
'url = "https://example.invalid/simple"\n'
|
||||
"\n"
|
||||
"[certificates.weird_name_here_bad]\n"
|
||||
'cert = "/etc/ssl/certs/ca-certificates.crt"\n'
|
||||
)
|
||||
|
||||
|
||||
def test_apply_writes_poetry_config_for_each_configured_user(tmp_path) -> None:
|
||||
config = Configuration.model_validate(ONE_REPO_CONFIG)
|
||||
dst = tmp_path / "dst"
|
||||
|
||||
Reference in New Issue
Block a user