This commit is contained in:
@@ -15,10 +15,60 @@ def test_barre_presente_sur_le_dashboard(client):
|
||||
assert "draco-barre.css" in r.text
|
||||
assert "draco-barre.js" in r.text
|
||||
assert 'window.DRACO_BAR_CONFIG' in r.text
|
||||
# Les quatre applications de la barre, aux URL publiques.
|
||||
# Les quatre applications de la barre, aux URL publiques par
|
||||
# défaut (noms officiels/prod, issus de la configuration).
|
||||
for url in ("https://og.dracodev.net/", "https://flowdeck.dracodev.net/",
|
||||
"https://tiktak.dracodev.net/", "https://kanbante.dracodev.net/"):
|
||||
assert url in r.text
|
||||
# L'adresse du service d'agents est injectée au panneau.
|
||||
assert 'window.DRACO_PANNEAU_CONFIG = { api: "https://agent.dracodev.net" }' in r.text
|
||||
|
||||
|
||||
def test_barre_et_panneau_urls_par_configuration(monkeypatch, fake_gitea):
|
||||
# Dev/prod (0.32.0) : la dev déclare ses noms en -dev par
|
||||
# l'environnement ; aucun nom public n'est codé en dur.
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
import app.main as main
|
||||
|
||||
monkeypatch.setenv("DRACO_SSO_URL", "https://og-dev.dracodev.net")
|
||||
monkeypatch.setenv("DRACO_FLOWDECK_URL", "https://flowdeck-dev.dracodev.net")
|
||||
monkeypatch.setenv("DRACO_TIKTAK_URL", "https://tiktak-dev.dracodev.net")
|
||||
monkeypatch.setenv("KANBANTE_PUBLIC_URL", "https://kanbante-dev.dracodev.net")
|
||||
monkeypatch.setenv("AGENT_URL", "https://agent-dev.dracodev.net")
|
||||
with TestClient(main.app) as client:
|
||||
r = client.get("/")
|
||||
assert r.status_code == 200
|
||||
for url in ("https://og-dev.dracodev.net/",
|
||||
"https://flowdeck-dev.dracodev.net/",
|
||||
"https://tiktak-dev.dracodev.net/",
|
||||
"https://kanbante-dev.dracodev.net/"):
|
||||
assert url in r.text
|
||||
assert 'api: "https://agent-dev.dracodev.net"' in r.text
|
||||
# Le JS statique du panneau ne contient aucun nom en dur :
|
||||
# il lit l'adresse injectée par l'hôte.
|
||||
js = client.get("/static/js/draco-panneau.js").text
|
||||
assert "DRACO_PANNEAU_CONFIG" in js
|
||||
assert "dracodev.net" not in js
|
||||
|
||||
|
||||
def test_config_agent_evenements_derive_de_agent_url(monkeypatch):
|
||||
from app.config import _env_settings
|
||||
|
||||
monkeypatch.setenv("AGENT_URL", "https://agent-dev.dracodev.net")
|
||||
monkeypatch.delenv("AGENT_EVENEMENTS_URL", raising=False)
|
||||
s = _env_settings()
|
||||
assert s.agent_url == "https://agent-dev.dracodev.net"
|
||||
assert s.agent_evenements_url == (
|
||||
"https://agent-dev.dracodev.net/api/v1/evenements"
|
||||
)
|
||||
# L'URL d'événements explicite garde la priorité (override compose).
|
||||
monkeypatch.setenv(
|
||||
"AGENT_EVENEMENTS_URL", "https://exemple.invalid/journal"
|
||||
)
|
||||
assert _env_settings().agent_evenements_url == (
|
||||
"https://exemple.invalid/journal"
|
||||
)
|
||||
|
||||
|
||||
def test_statiques_de_la_barre_servis(client):
|
||||
|
||||
@@ -97,7 +97,20 @@ def test_pont_inerte_sans_secret(monkeypatch, fake_gitea):
|
||||
|
||||
|
||||
def test_bouton_sso_sur_la_page_login(client_sso):
|
||||
# Défauts = noms officiels (DRACO_SSO_URL / KANBANTE_PUBLIC_URL).
|
||||
r = client_sso.get("/login")
|
||||
assert r.status_code == 200
|
||||
assert "og.dracodev.net/sso/authorize" in r.text
|
||||
assert "kanbante.dracodev.net%2Fauth%2Fdraco" in r.text
|
||||
|
||||
|
||||
def test_bouton_sso_par_configuration(client_sso, monkeypatch):
|
||||
# Dev : l'émettrice et le return_to suivent l'environnement.
|
||||
monkeypatch.setenv("DRACO_SSO_URL", "https://og-dev.dracodev.net")
|
||||
monkeypatch.setenv(
|
||||
"KANBANTE_PUBLIC_URL", "https://kanbante-dev.dracodev.net"
|
||||
)
|
||||
r = client_sso.get("/login")
|
||||
assert r.status_code == 200
|
||||
assert "og-dev.dracodev.net/sso/authorize" in r.text
|
||||
assert "kanbante-dev.dracodev.net%2Fauth%2Fdraco" in r.text
|
||||
|
||||
Reference in New Issue
Block a user