fix(0.32.1): URL sœurs dracodev dérivées de l'environnement de l'agent
CI / test (push) Successful in 2m58s
CI / test (push) Successful in 2m58s
This commit is contained in:
@@ -71,6 +71,117 @@ def test_config_agent_evenements_derive_de_agent_url(monkeypatch):
|
||||
)
|
||||
|
||||
|
||||
# ── Dérivation d'environnement des URL sœurs (0.32.1) ──
|
||||
# Sur la dev, seul AGENT_EVENEMENTS_URL est posé : les URL sœurs
|
||||
# doivent suivre son suffixe (-dev) sans quatre variables de plus.
|
||||
_ENV_URLS_SOEURS = (
|
||||
"DRACO_SSO_URL", # ObsiGate (émettrice SSO)
|
||||
"DRACO_FLOWDECK_URL",
|
||||
"DRACO_TIKTAK_URL",
|
||||
"KANBANTE_PUBLIC_URL", # Kanbante elle-même
|
||||
"AGENT_URL",
|
||||
)
|
||||
|
||||
_DEFAUTS_OFFICIELS = (
|
||||
"https://og.dracodev.net",
|
||||
"https://flowdeck.dracodev.net",
|
||||
"https://tiktak.dracodev.net",
|
||||
"https://kanbante.dracodev.net",
|
||||
)
|
||||
|
||||
_URLS_DEV = (
|
||||
"https://og-dev.dracodev.net",
|
||||
"https://flowdeck-dev.dracodev.net",
|
||||
"https://tiktak-dev.dracodev.net",
|
||||
"https://kanbante-dev.dracodev.net",
|
||||
)
|
||||
|
||||
|
||||
def _nettoyer_env_soeurs(monkeypatch):
|
||||
for nom in _ENV_URLS_SOEURS:
|
||||
monkeypatch.delenv(nom, raising=False)
|
||||
|
||||
|
||||
def _urls_soeurs(settings):
|
||||
return (
|
||||
settings.sso_url,
|
||||
settings.flowdeck_url,
|
||||
settings.tiktak_url,
|
||||
settings.public_url,
|
||||
)
|
||||
|
||||
|
||||
def test_config_urls_soeurs_derivees_du_seul_agent_evenements(monkeypatch):
|
||||
from app.config import _env_settings
|
||||
|
||||
_nettoyer_env_soeurs(monkeypatch)
|
||||
monkeypatch.setenv(
|
||||
"AGENT_EVENEMENTS_URL",
|
||||
"https://agent-dev.dracodev.net/api/v1/evenements",
|
||||
)
|
||||
assert _urls_soeurs(_env_settings()) == _URLS_DEV
|
||||
|
||||
|
||||
def test_barre_urls_soeurs_derivees_du_seul_agent_evenements(
|
||||
monkeypatch, fake_gitea
|
||||
):
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
import app.main as main
|
||||
|
||||
_nettoyer_env_soeurs(monkeypatch)
|
||||
monkeypatch.setenv(
|
||||
"AGENT_EVENEMENTS_URL",
|
||||
"https://agent-dev.dracodev.net/api/v1/evenements",
|
||||
)
|
||||
with TestClient(main.app) as client:
|
||||
r = client.get("/")
|
||||
assert r.status_code == 200
|
||||
for url in _URLS_DEV:
|
||||
assert f"{url}/" in r.text
|
||||
|
||||
|
||||
def test_config_url_soeur_explicite_gagne_sur_la_derivation(monkeypatch):
|
||||
from app.config import _env_settings
|
||||
|
||||
_nettoyer_env_soeurs(monkeypatch)
|
||||
monkeypatch.setenv(
|
||||
"AGENT_EVENEMENTS_URL",
|
||||
"https://agent-dev.dracodev.net/api/v1/evenements",
|
||||
)
|
||||
monkeypatch.setenv(
|
||||
"DRACO_FLOWDECK_URL", "https://flowdeck.example.test"
|
||||
)
|
||||
s = _env_settings()
|
||||
assert s.flowdeck_url == "https://flowdeck.example.test"
|
||||
# Les autres sœurs restent dérivées de l'environnement.
|
||||
assert s.sso_url == "https://og-dev.dracodev.net"
|
||||
assert s.tiktak_url == "https://tiktak-dev.dracodev.net"
|
||||
assert s.public_url == "https://kanbante-dev.dracodev.net"
|
||||
|
||||
|
||||
def test_config_hote_agent_hors_motif_reste_aux_defauts(monkeypatch):
|
||||
from app.config import _env_settings
|
||||
|
||||
_nettoyer_env_soeurs(monkeypatch)
|
||||
for url_agent in (
|
||||
"https://agent.example.com/api/v1/evenements",
|
||||
"https://agent-dev.autre-domaine.net/api/v1/evenements",
|
||||
"http://192.168.30.101:8790/api/v1/evenements",
|
||||
"http://127.0.0.1:8790/api/v1/evenements",
|
||||
):
|
||||
monkeypatch.setenv("AGENT_EVENEMENTS_URL", url_agent)
|
||||
assert _urls_soeurs(_env_settings()) == _DEFAUTS_OFFICIELS
|
||||
|
||||
|
||||
def test_config_aucun_env_reste_aux_defauts_officiels(monkeypatch):
|
||||
from app.config import _env_settings
|
||||
|
||||
_nettoyer_env_soeurs(monkeypatch)
|
||||
monkeypatch.delenv("AGENT_EVENEMENTS_URL", raising=False)
|
||||
assert _urls_soeurs(_env_settings()) == _DEFAUTS_OFFICIELS
|
||||
|
||||
|
||||
def test_statiques_de_la_barre_servis(client):
|
||||
assert client.get("/static/css/draco-barre.css").status_code == 200
|
||||
assert client.get("/static/js/draco-barre.js").status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user