Exemple d'unites systemd (service + minuteur hh:x4/hh:x9), non installees
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
d12d75c7b2
révision
5cfed7a174
3 fichiers modifiés
+82
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,34 @@
|
||||
"""Contrôles statiques des fichiers systemd d'exemple (pas de systemd sous Windows : rien n'est installé)."""
|
||||
import datetime as dt
|
||||
import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from meteo_collecte.infoclimat import type_passage
|
||||
from tests.aide import t
|
||||
|
||||
DOSSIER = Path(__file__).resolve().parent.parent / "deploiement"
|
||||
|
||||
|
||||
class TestUnites(unittest.TestCase):
|
||||
def test_minuteur_aligne_sur_les_passages(self):
|
||||
texte = (DOSSIER / "meteo-collecte.timer").read_text(encoding="utf-8")
|
||||
m = re.search(r"^OnCalendar=\*:(\d\d)/(\d+)$", texte, re.M)
|
||||
self.assertIsNotNone(m)
|
||||
depart, pas = int(m.group(1)), int(m.group(2))
|
||||
minutes = list(range(depart, 60, pas))
|
||||
self.assertEqual(minutes, [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59])
|
||||
genres = [type_passage(t(12, 0) + dt.timedelta(minutes=x)) for x in minutes]
|
||||
self.assertEqual(genres, ["principal", "rattrapage"] * 6)
|
||||
|
||||
def test_service_sans_secret_ni_sudo(self):
|
||||
texte = (DOSSIER / "meteo-collecte.service").read_text(encoding="utf-8")
|
||||
actif = [l for l in texte.splitlines() if l and not l.startswith("#")]
|
||||
self.assertTrue(any(l.startswith("ExecStart=") and "meteo_collecte.ordonnanceur" in l for l in actif))
|
||||
for l in actif:
|
||||
self.assertNotRegex(l, r"(?i)MC_JETON_INFOCLIMAT=|MC_CLE_ROMMA=|token=|apikey=|sudo")
|
||||
self.assertIn("EnvironmentFile=-", texte)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur