fix: supprimer les portails historiques et leur tuile
Some checks failed
Validation applicative / Tests de contrat (push) Failing after 6s
Some checks failed
Validation applicative / Tests de contrat (push) Failing after 6s
This commit is contained in:
@@ -10,10 +10,6 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.http.services.portail-recette.loadbalancer.server.port=3000"
|
- "traefik.http.services.portail-recette.loadbalancer.server.port=3000"
|
||||||
- "traefik.http.routers.portail-legacy-recette.rule=Host(`portail.recette.santinova-soft.org`)"
|
|
||||||
- "traefik.http.routers.portail-legacy-recette.entrypoints=websecure"
|
|
||||||
- "traefik.http.routers.portail-legacy-recette.tls=true"
|
|
||||||
- "traefik.http.routers.portail-legacy-recette.tls.certresolver=letsencrypt"
|
|
||||||
- "traefik.http.routers.portail-itinova-recette.rule=Host(`portail-itinova.recette.santinova-soft.org`)"
|
- "traefik.http.routers.portail-itinova-recette.rule=Host(`portail-itinova.recette.santinova-soft.org`)"
|
||||||
- "traefik.http.routers.portail-itinova-recette.entrypoints=websecure"
|
- "traefik.http.routers.portail-itinova-recette.entrypoints=websecure"
|
||||||
- "traefik.http.routers.portail-itinova-recette.tls=true"
|
- "traefik.http.routers.portail-itinova-recette.tls=true"
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
'portail-santinova.santinova-soft.org': { env: 'prod', group: 'SANTINOVA', title: 'Portail Santinova', accent: '#7c3aed' },
|
'portail-santinova.santinova-soft.org': { env: 'prod', group: 'SANTINOVA', title: 'Portail Santinova', accent: '#7c3aed' },
|
||||||
'portail-santelis.santinova-soft.org': { env: 'prod', group: 'SANTELIS', title: 'Portail SANTELIS', accent: '#15803d' }
|
'portail-santelis.santinova-soft.org': { env: 'prod', group: 'SANTELIS', title: 'Portail SANTELIS', accent: '#15803d' }
|
||||||
};
|
};
|
||||||
var LEGACY_REDIRECTS = { 'portail.recette.santinova-soft.org': 'https://portail-santinova.recette.santinova-soft.org/', 'portail.santinova-soft.org': 'https://portail-santinova.santinova-soft.org/' };
|
|
||||||
/* SANTELIS Gestion est déployée uniquement en production et volontairement hors inventaire Dashboard. */
|
/* SANTELIS Gestion est déployée uniquement en production et volontairement hors inventaire Dashboard. */
|
||||||
var PORTAL_ONLY_APPS = [{ id:'santelis-gestion', name:'SANTELIS Gestion', urls:{ prod:'https://gestion-santelis.santinova-soft.org' }, image:'images/santelis-gestion.jpg' }];
|
var PORTAL_ONLY_APPS = [{ id:'santelis-gestion', name:'SANTELIS Gestion', urls:{ prod:'https://gestion-santelis.santinova-soft.org' }, image:'images/santelis-gestion.jpg' }];
|
||||||
var STATUS_REFRESH_MS = 30000, APPS_REFRESH_MS = 300000, APP_IMAGE_OVERRIDES = { 'santelis-gestion': 'images/santelis-gestion.jpg' }, hasRenderedApps = false;
|
var STATUS_REFRESH_MS = 30000, APPS_REFRESH_MS = 300000, APP_IMAGE_OVERRIDES = { 'santelis-gestion': 'images/santelis-gestion.jpg' }, hasRenderedApps = false;
|
||||||
@@ -61,7 +60,7 @@
|
|||||||
function isHttpsUrl(value) { try { return new URL(value).protocol === 'https:'; } catch (error) { return false; } }
|
function isHttpsUrl(value) { try { return new URL(value).protocol === 'https:'; } catch (error) { return false; } }
|
||||||
function isOffline(app) { return app.status === 'offline' || app.status === 'error' || app.containerRunning === false; }
|
function isOffline(app) { return app.status === 'offline' || app.status === 'error' || app.containerRunning === false; }
|
||||||
function getPortalOnlyApps() { if (!PORTAL || PORTAL.env !== 'prod' || PORTAL.group !== 'SANTELIS') return []; return PORTAL_ONLY_APPS.filter(function(app) { return isHttpsUrl(app.urls && app.urls[PORTAL.env]); }); }
|
function getPortalOnlyApps() { if (!PORTAL || PORTAL.env !== 'prod' || PORTAL.group !== 'SANTELIS') return []; return PORTAL_ONLY_APPS.filter(function(app) { return isHttpsUrl(app.urls && app.urls[PORTAL.env]); }); }
|
||||||
function isAppInCurrentPortal(app) { if (!PORTAL || !app || !isHttpsUrl(app.urls && app.urls[PORTAL.env])) return false; if (app.id === 'santelis-gestion') return false; if (PORTAL.group === 'SANTINOVA') return app.category === 'SANTINOVA' || app.category === 'INFRA'; return app.category === PORTAL.group; }
|
function isAppInCurrentPortal(app) { if (!PORTAL || !app || !isHttpsUrl(app.urls && app.urls[PORTAL.env])) return false; if (app.id === 'santelis-gestion' || app.id === 'portail-santinova') return false; if (PORTAL.group === 'SANTINOVA') return app.category === 'SANTINOVA' || app.category === 'INFRA'; return app.category === PORTAL.group; }
|
||||||
function escapeHtml(value) { return String(value || '').replace(/[&<>'"]/g, function(character) { return ({ '&':'&', '<':'<', '>':'>', "'":''', '"':'"' })[character]; }); }
|
function escapeHtml(value) { return String(value || '').replace(/[&<>'"]/g, function(character) { return ({ '&':'&', '<':'<', '>':'>', "'":''', '"':'"' })[character]; }); }
|
||||||
function buildCard(app) { var url = app.urls && app.urls[PORTAL.env], image = APP_IMAGE_OVERRIDES[app.id] || app.image || ('images/' + app.id + '.png'), offline = isOffline(app); return '<a class="app-card' + (offline ? ' offline' : '') + '" data-app-id="' + escapeHtml(app.id) + '" href="' + escapeHtml(url) + '" target="_blank" rel="noopener noreferrer"' + (offline ? ' aria-disabled="true"' : '') + '><div class="card-image-wrapper"><img src="' + escapeHtml(image) + '" alt="' + escapeHtml(app.name) + '" onerror="this.style.display=\'none\'" /></div><div class="card-name">' + escapeHtml(app.name) + '</div><div class="card-env-badge">' + PORTAL.envLabel + '</div><div class="card-status-badge">Hors ligne</div></a>'; }
|
function buildCard(app) { var url = app.urls && app.urls[PORTAL.env], image = APP_IMAGE_OVERRIDES[app.id] || app.image || ('images/' + app.id + '.png'), offline = isOffline(app); return '<a class="app-card' + (offline ? ' offline' : '') + '" data-app-id="' + escapeHtml(app.id) + '" href="' + escapeHtml(url) + '" target="_blank" rel="noopener noreferrer"' + (offline ? ' aria-disabled="true"' : '') + '><div class="card-image-wrapper"><img src="' + escapeHtml(image) + '" alt="' + escapeHtml(app.name) + '" onerror="this.style.display=\'none\'" /></div><div class="card-name">' + escapeHtml(app.name) + '</div><div class="card-env-badge">' + PORTAL.envLabel + '</div><div class="card-status-badge">Hors ligne</div></a>'; }
|
||||||
function setPortalIdentity() { document.documentElement.style.setProperty('--accent', PORTAL.accent); document.title = PORTAL.title + ' — Santinova Soft'; document.getElementById('portal-title').textContent = PORTAL.title; document.getElementById('portal-subtitle').textContent = 'Environnement de ' + PORTAL.envLabel.toLowerCase(); document.getElementById('environment-badge').textContent = PORTAL.envLabel; document.getElementById('entity-heading').firstChild.nodeValue = PORTAL.title; document.getElementById('entity-description').textContent = 'Applications déployées dans l’environnement ' + PORTAL.envLabel.toLowerCase() + '.'; }
|
function setPortalIdentity() { document.documentElement.style.setProperty('--accent', PORTAL.accent); document.title = PORTAL.title + ' — Santinova Soft'; document.getElementById('portal-title').textContent = PORTAL.title; document.getElementById('portal-subtitle').textContent = 'Environnement de ' + PORTAL.envLabel.toLowerCase(); document.getElementById('environment-badge').textContent = PORTAL.envLabel; document.getElementById('entity-heading').firstChild.nodeValue = PORTAL.title; document.getElementById('entity-description').textContent = 'Applications déployées dans l’environnement ' + PORTAL.envLabel.toLowerCase() + '.'; }
|
||||||
@@ -69,9 +68,8 @@
|
|||||||
async function requestJson(url) { var controller = new AbortController(), timeoutId = setTimeout(function() { controller.abort(); }, 8000); try { var response = await fetch(url, { cache:'no-store', signal:controller.signal }); if (!response.ok) throw new Error('HTTP ' + response.status); return await response.json(); } finally { clearTimeout(timeoutId); } }
|
async function requestJson(url) { var controller = new AbortController(), timeoutId = setTimeout(function() { controller.abort(); }, 8000); try { var response = await fetch(url, { cache:'no-store', signal:controller.signal }); if (!response.ok) throw new Error('HTTP ' + response.status); return await response.json(); } finally { clearTimeout(timeoutId); } }
|
||||||
async function fetchAndApplyStatuses() { try { var statuses = await requestJson(PORTAL.dashboardStatusUrl); if (!Array.isArray(statuses)) return; var byId = new Map(statuses.map(function(status) { return [status.id,status]; })); document.querySelectorAll('.app-card[data-app-id]').forEach(function(card) { var status = byId.get(card.getAttribute('data-app-id')); if (!status) return; var offline = isOffline(status); card.classList.toggle('offline', offline); card.setAttribute('aria-disabled', String(offline)); }); } catch (error) { console.warn('[Portail] Mise à jour des statuts impossible :', error.message); } }
|
async function fetchAndApplyStatuses() { try { var statuses = await requestJson(PORTAL.dashboardStatusUrl); if (!Array.isArray(statuses)) return; var byId = new Map(statuses.map(function(status) { return [status.id,status]; })); document.querySelectorAll('.app-card[data-app-id]').forEach(function(card) { var status = byId.get(card.getAttribute('data-app-id')); if (!status) return; var offline = isOffline(status); card.classList.toggle('offline', offline); card.setAttribute('aria-disabled', String(offline)); }); } catch (error) { console.warn('[Portail] Mise à jour des statuts impossible :', error.message); } }
|
||||||
async function loadApps() { try { var apps = await requestJson(PORTAL.dashboardAppsUrl); if (!Array.isArray(apps)) throw new Error('réponse applications invalide'); renderApps(apps); await fetchAndApplyStatuses(); } catch (error) { console.warn('[Portail] Chargement des applications impossible :', error.message); if (!hasRenderedApps) { document.getElementById('apps-grid').innerHTML = '<div class="loading-msg error">Dashboard indisponible — veuillez réessayer.</div>'; document.getElementById('app-count').textContent = '!'; } } }
|
async function loadApps() { try { var apps = await requestJson(PORTAL.dashboardAppsUrl); if (!Array.isArray(apps)) throw new Error('réponse applications invalide'); renderApps(apps); await fetchAndApplyStatuses(); } catch (error) { console.warn('[Portail] Chargement des applications impossible :', error.message); if (!hasRenderedApps) { document.getElementById('apps-grid').innerHTML = '<div class="loading-msg error">Dashboard indisponible — veuillez réessayer.</div>'; document.getElementById('app-count').textContent = '!'; } } }
|
||||||
var CURRENT_HOST = normalizeHostname(window.location.hostname), LEGACY_REDIRECT = LEGACY_REDIRECTS[CURRENT_HOST], PORTAL = resolvePortalConfig(CURRENT_HOST);
|
var CURRENT_HOST = normalizeHostname(window.location.hostname), PORTAL = resolvePortalConfig(CURRENT_HOST);
|
||||||
if (LEGACY_REDIRECT) window.location.replace(LEGACY_REDIRECT);
|
if (!PORTAL) document.addEventListener('DOMContentLoaded', function() { document.getElementById('apps-grid').innerHTML = '<div class="loading-msg error">Nom de portail non reconnu.</div>'; });
|
||||||
else if (!PORTAL) document.addEventListener('DOMContentLoaded', function() { document.getElementById('apps-grid').innerHTML = '<div class="loading-msg error">Nom de portail non reconnu.</div>'; });
|
|
||||||
else document.addEventListener('DOMContentLoaded', function() { setPortalIdentity(); loadApps(); setInterval(fetchAndApplyStatuses, STATUS_REFRESH_MS); setInterval(loadApps, APPS_REFRESH_MS); });
|
else document.addEventListener('DOMContentLoaded', function() { setPortalIdentity(); loadApps(); setInterval(fetchAndApplyStatuses, STATUS_REFRESH_MS); setInterval(loadApps, APPS_REFRESH_MS); });
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ const root = path.join(__dirname, '..');
|
|||||||
const html = fs.readFileSync(path.join(root, 'index.html'), 'utf8');
|
const html = fs.readFileSync(path.join(root, 'index.html'), 'utf8');
|
||||||
const compose = fs.readFileSync(path.join(root, 'docker-compose.yml'), 'utf8');
|
const compose = fs.readFileSync(path.join(root, 'docker-compose.yml'), 'utf8');
|
||||||
const script = html.match(/<script>([\s\S]*?)<\/script>/)?.[1];
|
const script = html.match(/<script>([\s\S]*?)<\/script>/)?.[1];
|
||||||
|
const historicalRecetteHost = ['portail', 'recette', 'santinova-soft', 'org'].join('.');
|
||||||
|
const historicalProductionHost = ['portail', 'santinova-soft', 'org'].join('.');
|
||||||
|
|
||||||
assert.ok(script, 'le script de configuration des portails doit être présent');
|
assert.ok(script, 'le script de configuration des portails doit être présent');
|
||||||
assert.equal(/^(<<<<<<<|=======|>>>>>>>)/m.test(html), false, 'aucun marqueur de conflit Git ne doit être livré');
|
assert.equal(/^(<<<<<<<|=======|>>>>>>>)/m.test(html), false, 'aucun marqueur de conflit Git ne doit être livré');
|
||||||
@@ -19,6 +21,8 @@ assert.match(html, /PORTAL_CONFIGS/, 'les domaines des portails doivent être co
|
|||||||
assert.doesNotMatch(html, /class="entity-nav"/, 'un portail ne doit proposer aucun accès aux autres portails');
|
assert.doesNotMatch(html, /class="entity-nav"/, 'un portail ne doit proposer aucun accès aux autres portails');
|
||||||
assert.doesNotMatch(html, /PORTAL_DEFINITIONS/, 'la liste de navigation croisée ne doit pas être livrée');
|
assert.doesNotMatch(html, /PORTAL_DEFINITIONS/, 'la liste de navigation croisée ne doit pas être livrée');
|
||||||
assert.doesNotMatch(html, /function renderNavigation\(/, 'aucune fonction ne doit construire des liens vers les autres portails');
|
assert.doesNotMatch(html, /function renderNavigation\(/, 'aucune fonction ne doit construire des liens vers les autres portails');
|
||||||
|
assert.equal(html.includes(historicalRecetteHost), false, 'le portail historique recette ne doit plus être livré');
|
||||||
|
assert.equal(html.includes(historicalProductionHost), false, 'le portail historique production ne doit plus être livré');
|
||||||
assert.match(html, /STATUS_REFRESH_MS = 30000/, 'le délai de grisage doit être explicite');
|
assert.match(html, /STATUS_REFRESH_MS = 30000/, 'le délai de grisage doit être explicite');
|
||||||
assert.match(html, /setInterval\(fetchAndApplyStatuses, STATUS_REFRESH_MS\)/, 'les statuts doivent être réactualisés périodiquement');
|
assert.match(html, /setInterval\(fetchAndApplyStatuses, STATUS_REFRESH_MS\)/, 'les statuts doivent être réactualisés périodiquement');
|
||||||
|
|
||||||
@@ -102,18 +106,17 @@ for (const host of [hosts.itinovaRecette, hosts.soinsRecette, hosts.santinovaRec
|
|||||||
`${host} doit avoir un routeur Traefik dédié`
|
`${host} doit avoir un routeur Traefik dédié`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
assert.match(
|
assert.equal(compose.includes(['portail', 'legacy'].join('-')), false, 'aucune route historique ne doit rester exposée');
|
||||||
compose,
|
assert.equal(compose.includes(historicalRecetteHost), false, 'l’ancienne URL recette ne doit plus être routée');
|
||||||
/traefik\.http\.routers\.portail-legacy-recette\.rule=Host\(`portail\.recette\.santinova-soft\.org`\)/,
|
assert.equal(compose.includes(historicalProductionHost), false, 'l’ancienne URL production ne doit plus être routée');
|
||||||
'l’ancienne URL recette doit garder un routeur de redirection'
|
assert.equal((compose.match(/tls\.certresolver=letsencrypt/g) || []).length, 4, 'seuls les quatre portails par entité doivent demander un certificat TLS');
|
||||||
);
|
|
||||||
assert.equal((compose.match(/tls\.certresolver=letsencrypt/g) || []).length, 5, 'chaque routeur recette doit demander un certificat TLS');
|
|
||||||
|
|
||||||
const recetteApps = [
|
const recetteApps = [
|
||||||
{ id: 'itinova-contacts', category: 'ITINOVA', urls: { recette: 'https://contacts.recette.santinova-soft.org' } },
|
{ id: 'itinova-contacts', category: 'ITINOVA', urls: { recette: 'https://contacts.recette.santinova-soft.org' } },
|
||||||
{ id: 'gestion-astreintes-had', category: 'SOINS_ET_SANTE', urls: { recette: 'https://astreintes-had.recette.santinova-soft.org' } },
|
{ id: 'gestion-astreintes-had', category: 'SOINS_ET_SANTE', urls: { recette: 'https://astreintes-had.recette.santinova-soft.org' } },
|
||||||
{ id: 'demat-facturation-dsi', category: 'SANTINOVA', urls: { recette: 'https://demat-facturation.recette.santinova-soft.org' } },
|
{ id: 'demat-facturation-dsi', category: 'SANTINOVA', urls: { recette: 'https://demat-facturation.recette.santinova-soft.org' } },
|
||||||
{ id: 'referentiel-ia', category: 'INFRA', urls: { recette: 'https://referentiel-ia.recette.santinova-soft.org' } },
|
{ id: 'referentiel-ia', category: 'INFRA', urls: { recette: 'https://referentiel-ia.recette.santinova-soft.org' } },
|
||||||
|
{ id: 'portail-santinova', category: 'INFRA', urls: { recette: 'https://portail-santinova.recette.santinova-soft.org' } },
|
||||||
{ id: 'santelis-gestion', category: 'SANTINOVA', urls: { recette: 'https://gestion-santelis.recette.santinova-soft.org' } }
|
{ id: 'santelis-gestion', category: 'SANTINOVA', urls: { recette: 'https://gestion-santelis.recette.santinova-soft.org' } }
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -148,15 +151,10 @@ for (const imageName of ['budget-si.jpg', 'gestion-astreintes-had.jpg', 'gestion
|
|||||||
assert.ok(fs.statSync(imagePath).size > 2048, `l’asset ${imageName} ne doit pas être vide`);
|
assert.ok(fs.statSync(imagePath).size > 2048, `l’asset ${imageName} ne doit pas être vide`);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.deepEqual(
|
for (const historicalHost of [historicalRecetteHost, historicalProductionHost]) {
|
||||||
loadPortal('portail.recette.santinova-soft.org').redirects,
|
const historicalPortal = loadPortal(historicalHost);
|
||||||
['https://portail-santinova.recette.santinova-soft.org/'],
|
assert.equal(historicalPortal.sandbox.PORTAL, null, `${historicalHost} ne doit plus être reconnu comme portail`);
|
||||||
'l’ancienne URL recette doit rediriger vers le portail Santinova'
|
assert.deepEqual(historicalPortal.redirects, [], `${historicalHost} ne doit plus rediriger vers un portail`);
|
||||||
);
|
}
|
||||||
assert.deepEqual(
|
|
||||||
loadPortal('portail.santinova-soft.org').redirects,
|
|
||||||
['https://portail-santinova.santinova-soft.org/'],
|
|
||||||
'l’ancienne URL production doit rediriger vers le portail Santinova'
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('OK portal-contract');
|
console.log('OK portal-contract');
|
||||||
|
|||||||
Reference in New Issue
Block a user