Enclume : editeur CLAPI, catalogue de 26 packs, empaquetage Docker
Construction et publication / verifier (push) Successful in 41s
Construction et publication / verifier (pull_request) Successful in 11s
Construction et publication / publier (pull_request) Skipped
Construction et publication / publier (push) Failing after 6m3s

This commit is contained in:
hcornet committed 2026-09-10 11:32:03 +02:00
1 parent aa71251de0
commit de7a691861
59 files changed
+4466 -205

No files matched your search

+78
View File
@@ -0,0 +1,78 @@
"""Garde-fous minimaux : ce qui casserait silencieusement le code genere."""
import json
from enclume.catalog import Catalog
from enclume.generator import build_plan, render_bundle
from enclume.model import Project, strip_secrets, validate
from enclume.packs import pack_to_project
from enclume.webapp import create_app
def projet_exemple() -> Project:
catalog = Catalog("catalog")
return pack_to_project(catalog.get("os-linux-snmp"))
def test_catalogue_lisible():
catalog = Catalog("catalog")
assert not catalog.errors
assert len(catalog.packs) >= 20
def test_plan_complet():
plan = build_plan(projet_exemple())
lignes = plan.ops
assert any(o.obj == "CMD" and o.action == "ADD" for o in lignes)
assert any(o.obj == "STPL" and o.action == "addhosttemplate" for o in lignes)
assert not plan.has_errors
def test_prefixe_applique_aux_references():
projet = projet_exemple()
projet.prefix = "ACME-"
lignes = [o.import_line() for o in build_plan(projet).ops if o.obj != "#"]
liaison = [l for l in lignes if l.startswith("STPL;addhosttemplate")][0]
assert liaison.count("ACME-") == 2
def test_macros_trois_champs_sur_ancienne_version():
projet = projet_exemple()
projet.centreon_version = "legacy"
macro = [o for o in build_plan(projet).ops if o.action == "setmacro"][0]
assert len(macro.values) == 3
def test_echappement_shell_des_macros_centreon():
fichiers = render_bundle(build_plan(projet_exemple()))
ligne = [l for l in fichiers["deploy.sh"].splitlines() if "HOSTADDRESS" in l][0]
assert ligne.startswith("clapi -o CMD -a ADD -v '")
def test_point_virgule_refuse():
projet = projet_exemple()
projet.commands[0].line += "; rm -rf /"
erreurs = [i for i in validate(projet) if i["level"] == "error"]
assert erreurs
def test_les_mots_de_passe_ne_sont_pas_conserves():
projet = projet_exemple()
projet.host_templates[0].macros.append(
type(projet.host_templates[0].macros[0])(name="PASSWORD", value="secret", is_password=True)
)
assert all(not m.value for m in strip_secrets(projet).host_templates[0].macros if m.is_password)
def test_api_de_generation():
client = create_app().test_client()
reponse = client.post("/api/generer", json={"project": projet_exemple().to_dict()})
donnees = reponse.get_json()
assert reponse.status_code == 200
assert donnees["files"]["deploy.clapi"].startswith("#")
assert donnees["summary"]["operations"] > 0
def test_sante():
reponse = create_app().test_client().get("/sante")
assert reponse.get_json()["statut"] == "ok"