Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27b5ea251c
|
||
|
|
553c69dafe
|
||
|
|
faa296937d
|
||
|
|
22e235e76a
|
||
|
|
d7ab575550
|
||
|
|
7595dcb95a
|
||
|
|
8384d1b510
|
||
|
|
7d568e416d
|
No files matched your search
+2
-3
@@ -75,9 +75,8 @@ GITEA_WEBHOOK_SECRET=
|
||||
# Site d'administration servi par le bot : `npm run setup` pour l'assistant .env,
|
||||
# puis http://WEB_HOST:WEB_PORT une fois le bot démarré.
|
||||
WEB_ENABLED=false
|
||||
# 127.0.0.1 derrière un reverse proxy installé sur la même machine.
|
||||
# 0.0.0.0 dans un conteneur ou sur un panel d'hébergement (Pterodactyl, Docker) :
|
||||
# sinon le site n'écoute que sur la boucle locale et reste injoignable.
|
||||
# 127.0.0.1 par défaut : n'expose rien hors de la machine. Mettre 0.0.0.0 seulement
|
||||
# derrière un reverse proxy HTTPS.
|
||||
WEB_HOST=127.0.0.1
|
||||
WEB_PORT=3080
|
||||
# URL publique du tableau de bord, utilisée pour la redirection OAuth2 Discord.
|
||||
|
||||
@@ -27,15 +27,6 @@ await registerEvents(client);
|
||||
const webServer = env.web.enabled ? startWebServer({ client }) : null;
|
||||
const webhookServer = env.webhook.enabled && !webhookSharesWebPort() ? startWebhookServer(client) : null;
|
||||
|
||||
// Saying nothing when the dashboard is off is how an afternoon gets lost
|
||||
// looking for a site that was never asked to start.
|
||||
if (!env.web.enabled) {
|
||||
logger.warn(
|
||||
'Le tableau de bord est désactivé : `WEB_ENABLED` ne vaut pas `true`. ' +
|
||||
'Aucun site ne sera servi. Mets `WEB_ENABLED=true` dans le .env puis redémarre.',
|
||||
);
|
||||
}
|
||||
|
||||
process.on('unhandledRejection', (reason) => logger.error('Unhandled promise rejection', reason));
|
||||
process.on('uncaughtException', (error) => logger.error('Uncaught exception', error));
|
||||
|
||||
|
||||
+1
-13
@@ -132,7 +132,7 @@ export function clientIp(request) {
|
||||
* Serves a file from `root`, refusing anything that escapes it.
|
||||
* Returns false when the file does not exist, so the caller can fall back.
|
||||
*/
|
||||
export async function sendStatic(response, root, requestPath, { fallback = null, request = null } = {}) {
|
||||
export async function sendStatic(response, root, requestPath, { fallback = null } = {}) {
|
||||
const relative = decodeURIComponent(requestPath).replace(/^\/+/, '');
|
||||
const resolved = path.resolve(root, relative || 'index.html');
|
||||
const target = resolved.startsWith(path.resolve(root)) ? resolved : null;
|
||||
@@ -150,24 +150,12 @@ export async function sendStatic(response, root, requestPath, { fallback = null,
|
||||
if (!info?.isFile()) return false;
|
||||
|
||||
const extension = path.extname(file).toLowerCase();
|
||||
// `no-cache` alone tells a cache to revalidate, but without a validator it has
|
||||
// nothing to revalidate against — which is how a browser or a CDN ends up
|
||||
// serving a front-end older than the API it talks to.
|
||||
const etag = `"${info.size.toString(16)}-${Math.floor(info.mtimeMs).toString(16)}"`;
|
||||
|
||||
if (request?.headers?.['if-none-match'] === etag) {
|
||||
response.writeHead(304, { ...SECURITY_HEADERS, ETag: etag }).end();
|
||||
return true;
|
||||
}
|
||||
|
||||
response.writeHead(200, {
|
||||
...SECURITY_HEADERS,
|
||||
'Content-Type': MIME_TYPES[extension] ?? 'application/octet-stream',
|
||||
'Content-Length': info.size,
|
||||
// The SPA shell must never be cached, its modules are revalidated on each load.
|
||||
'Cache-Control': extension === '.html' ? 'no-store' : 'no-cache',
|
||||
ETag: etag,
|
||||
'Last-Modified': new Date(info.mtimeMs).toUTCString(),
|
||||
});
|
||||
createReadStream(file).pipe(response);
|
||||
return true;
|
||||
|
||||
@@ -310,8 +310,7 @@ async function renderView(host) {
|
||||
const module = await import(route.module);
|
||||
await module.render(host, { params: segments.slice(1), state });
|
||||
} catch (error) {
|
||||
const { errorBox } = await import('./core/ui.js');
|
||||
mount(host, errorBox(error.message, { retry: () => renderView(host) }));
|
||||
mount(host, h('div', { class: 'notice notice-error' }, h('p', { text: error.message })));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ export function toggle(checked, onChange, label) {
|
||||
* Renders a table. Each column is `{ key, label, render?, className? }`;
|
||||
* `render` returns a Node or a string.
|
||||
*/
|
||||
export function table(columns, rows, { empty = 'Rien à afficher pour le moment.', rowHref = null } = {}) {
|
||||
export function table(columns, rows, { empty = 'Rien à afficher pour le moment.' } = {}) {
|
||||
if (!rows || rows.length === 0) {
|
||||
// An empty state is where people look for the action that fills it, so it
|
||||
// accepts a node and not only a sentence.
|
||||
@@ -107,11 +107,10 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
|
||||
h(
|
||||
'tbody',
|
||||
{},
|
||||
rows.map((row) => {
|
||||
const target = rowHref?.(row) ?? null;
|
||||
const line = h(
|
||||
rows.map((row) =>
|
||||
h(
|
||||
'tr',
|
||||
target ? { class: 'row-link', tabindex: '0', role: 'link' } : {},
|
||||
{},
|
||||
columns.map((column) => {
|
||||
const cell = h('td', { class: column.className ?? '' });
|
||||
const value = column.render ? column.render(row) : row[column.key];
|
||||
@@ -119,25 +118,8 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
|
||||
else cell.textContent = value === null || value === undefined ? '—' : String(value);
|
||||
return cell;
|
||||
}),
|
||||
);
|
||||
|
||||
if (target) {
|
||||
// A control inside the row keeps its own behaviour; only the empty
|
||||
// space navigates.
|
||||
const open = (event) => {
|
||||
if (event.target.closest('a, button, input, select, textarea, label')) return;
|
||||
window.location.hash = target.replace(/^#/, '');
|
||||
};
|
||||
line.addEventListener('click', open);
|
||||
line.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
event.preventDefault();
|
||||
open(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
return line;
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -146,28 +128,11 @@ export function table(columns, rows, { empty = 'Rien à afficher pour le moment.
|
||||
export const spinner = (label = 'Chargement…') =>
|
||||
h('div', { class: 'loading' }, h('span', { class: 'spinner' }), h('span', { text: label }));
|
||||
|
||||
/**
|
||||
* A `undefined is not a function` reaching the screen almost always means the
|
||||
* page and the API disagree on the shape of the data — which reads as a broken
|
||||
* feature unless the box says otherwise.
|
||||
*/
|
||||
const looksLikeVersionMismatch = (message) =>
|
||||
/Cannot read propert|undefined is not|is not a function|of undefined/i.test(String(message));
|
||||
|
||||
export const errorBox = (message, { retry } = {}) =>
|
||||
h(
|
||||
'div',
|
||||
{ class: 'notice notice-error' },
|
||||
h(
|
||||
'div',
|
||||
{},
|
||||
h('p', { text: message }),
|
||||
looksLikeVersionMismatch(message) &&
|
||||
h('p', {
|
||||
class: 'muted',
|
||||
text: 'Cette erreur vient en général d’une interface plus ancienne que l’API : recharge avec Ctrl+Shift+R, et si elle persiste, re-téléverse le dossier src/web/public.',
|
||||
}),
|
||||
),
|
||||
h('p', { text: message }),
|
||||
retry && button('Réessayer', retry, { tone: 'ghost' }),
|
||||
);
|
||||
|
||||
|
||||
@@ -535,14 +535,6 @@ pre code {
|
||||
.table tbody tr:hover {
|
||||
background: color-mix(in srgb, var(--blue) 6%, transparent);
|
||||
}
|
||||
.table tbody tr.row-link {
|
||||
cursor: pointer;
|
||||
}
|
||||
.table tbody tr.row-link:focus-visible {
|
||||
outline: 2px solid var(--blue);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.num {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
|
||||
@@ -164,7 +164,7 @@ export function render(host, { state }) {
|
||||
|
||||
card(
|
||||
'Dépôts',
|
||||
{ subtitle: 'Clique sur une ligne pour gérer le dépôt en détail.' },
|
||||
{ subtitle: 'Clique sur un dépôt pour le gérer en détail.' },
|
||||
table(
|
||||
[
|
||||
{
|
||||
@@ -207,10 +207,7 @@ export function render(host, { state }) {
|
||||
},
|
||||
],
|
||||
data.repositories,
|
||||
{
|
||||
empty: 'Aucun dépôt dans cette organisation.',
|
||||
rowHref: (repository) => `#/repos/${repository.fullName}`,
|
||||
},
|
||||
{ empty: 'Aucun dépôt dans cette organisation.' },
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
@@ -96,7 +96,6 @@ function giteaCard(gitea) {
|
||||
},
|
||||
],
|
||||
gitea.repositories,
|
||||
{ rowHref: (repository) => `#/repos/${repository.fullName}` },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ function settingControl(setting, value, apply) {
|
||||
);
|
||||
}
|
||||
|
||||
if (setting.type === 'enum' && Array.isArray(setting.options)) {
|
||||
if (setting.type === 'enum') {
|
||||
return field(
|
||||
setting.label,
|
||||
select(
|
||||
@@ -76,27 +76,20 @@ function settingControl(setting, value, apply) {
|
||||
|
||||
function behaviourCard(data, level, reload) {
|
||||
const editable = level >= LEVELS.DEV;
|
||||
const schema = Array.isArray(data.schema) ? data.schema : [];
|
||||
const values = data.values ?? {};
|
||||
|
||||
// Falling back to one section keeps the page useful against an API that does
|
||||
// not group its settings, rather than rendering nothing at all.
|
||||
const sections = Array.isArray(data.sections)
|
||||
? data.sections
|
||||
: [{ id: null, title: 'Comportement du bot', summary: null }];
|
||||
const sections = data.sections ?? [];
|
||||
|
||||
return h(
|
||||
'div',
|
||||
{ class: 'stack' },
|
||||
...sections.map((section) => {
|
||||
const settings = section.id ? schema.filter((setting) => setting.section === section.id) : schema;
|
||||
const settings = data.schema.filter((setting) => setting.section === section.id);
|
||||
if (settings.length === 0) return null;
|
||||
|
||||
return card(
|
||||
section.title,
|
||||
{ subtitle: section.summary },
|
||||
...settings.map((setting) => {
|
||||
const value = values[setting.key];
|
||||
const value = data.values[setting.key];
|
||||
|
||||
if (!editable) {
|
||||
return h(
|
||||
@@ -112,7 +105,7 @@ function behaviourCard(data, level, reload) {
|
||||
try {
|
||||
const saved = await api.put(`/api/settings/values/${setting.key}`, { value: next });
|
||||
toast(`« ${setting.label} » enregistré.`);
|
||||
values[setting.key] = saved.value;
|
||||
data.values[setting.key] = saved.value;
|
||||
} catch (error) {
|
||||
toast(error.message, 'error');
|
||||
}
|
||||
@@ -138,13 +131,7 @@ const testButton = (service, label) =>
|
||||
{ tone: 'ghost' },
|
||||
);
|
||||
|
||||
function connectionsCard(raw) {
|
||||
const data = {
|
||||
discord: raw.discord ?? {},
|
||||
gitea: raw.gitea ?? {},
|
||||
webhook: raw.webhook ?? {},
|
||||
web: raw.web ?? {},
|
||||
};
|
||||
function connectionsCard(data) {
|
||||
return h(
|
||||
'div',
|
||||
{ class: 'stack' },
|
||||
@@ -162,13 +149,13 @@ function connectionsCard(raw) {
|
||||
h(
|
||||
'div',
|
||||
{ class: 'advanced-only' },
|
||||
keyValue(Object.entries(data.discord.roles ?? {}).map(([label, value]) => ({ label, value }))),
|
||||
keyValue(Object.entries(data.discord.roles).map(([label, value]) => ({ label, value }))),
|
||||
),
|
||||
h('h3', { class: 'advanced-only', text: 'Salons' }),
|
||||
h(
|
||||
'div',
|
||||
{ class: 'advanced-only' },
|
||||
keyValue(Object.entries(data.discord.channels ?? {}).map(([label, value]) => ({ label, value }))),
|
||||
keyValue(Object.entries(data.discord.channels).map(([label, value]) => ({ label, value }))),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -410,15 +397,14 @@ function tokensCard(reload) {
|
||||
}
|
||||
|
||||
function maintenanceCard(data) {
|
||||
const runtime = data.runtime ?? {};
|
||||
return card(
|
||||
'Maintenance',
|
||||
{ subtitle: `Base : ${runtime.databasePath ?? '—'}` },
|
||||
{ subtitle: `Base : ${data.runtime.databasePath}` },
|
||||
grid(
|
||||
stat('Environnement', runtime.nodeEnv),
|
||||
stat('Niveau de log', runtime.logLevel),
|
||||
stat('Rétention', `${runtime.logRetentionDays ?? '—'} jours`),
|
||||
stat('PID', runtime.pid),
|
||||
stat('Environnement', data.runtime.nodeEnv),
|
||||
stat('Niveau de log', data.runtime.logLevel),
|
||||
stat('Rétention', `${data.runtime.logRetentionDays} jours`),
|
||||
stat('PID', data.runtime.pid),
|
||||
),
|
||||
h(
|
||||
'div',
|
||||
@@ -439,7 +425,7 @@ function maintenanceCard(data) {
|
||||
},
|
||||
{ tone: 'ghost' },
|
||||
),
|
||||
data.web?.allowRestart &&
|
||||
data.web.allowRestart &&
|
||||
button(
|
||||
'Redémarrer le bot',
|
||||
async () => {
|
||||
@@ -455,13 +441,12 @@ function maintenanceCard(data) {
|
||||
{ tone: 'danger' },
|
||||
),
|
||||
),
|
||||
!data.web?.allowRestart &&
|
||||
!data.web.allowRestart &&
|
||||
h('p', { class: 'muted', text: 'Le redémarrage depuis le site est désactivé (`WEB_ALLOW_RESTART`).' }),
|
||||
);
|
||||
}
|
||||
|
||||
function referenceCard(data) {
|
||||
const reference = data.reference ?? {};
|
||||
return card(
|
||||
'Référence',
|
||||
{ advanced: true, subtitle: 'Ce que le bot connaît, pour se repérer.' },
|
||||
@@ -472,7 +457,7 @@ function referenceCard(data) {
|
||||
{ label: 'Valeur', className: 'num', key: 'value' },
|
||||
{ label: 'Libellé Discord', key: 'label' },
|
||||
],
|
||||
reference.accessLevels ?? [],
|
||||
data.reference.accessLevels,
|
||||
),
|
||||
h('h3', { text: 'Catégories de tickets' }),
|
||||
table(
|
||||
@@ -481,13 +466,13 @@ function referenceCard(data) {
|
||||
{ label: 'Libellé', key: 'label' },
|
||||
{ label: 'Visible par', render: (category) => category.scope.join(', ') },
|
||||
],
|
||||
reference.ticketCategories ?? [],
|
||||
data.reference.ticketCategories,
|
||||
),
|
||||
h('h3', { text: 'Types de notification' }),
|
||||
h(
|
||||
'div',
|
||||
{ class: 'row' },
|
||||
(reference.notificationTypes ?? []).map((type) => badge(type, 'info')),
|
||||
data.reference.notificationTypes.map((type) => badge(type, 'info')),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -518,11 +503,7 @@ export function render(host, { state }) {
|
||||
}),
|
||||
),
|
||||
level >= LEVELS.OWNER &&
|
||||
h('a', {
|
||||
class: 'btn btn-primary',
|
||||
href: '#/setup',
|
||||
text: 'Assistant de configuration .env',
|
||||
}),
|
||||
h('a', { class: 'btn btn-primary', href: '#/setup', text: 'Assistant de configuration .env' }),
|
||||
),
|
||||
|
||||
level >= LEVELS.OWNER &&
|
||||
|
||||
+2
-26
@@ -75,7 +75,7 @@ export function createHandler({ client = null, setupOnly = false, startedAt = Da
|
||||
// The wiki is a separate public page: it must never fall back to the
|
||||
// dashboard shell, which would send a visitor to a login screen.
|
||||
const fallback = pathname === '/wiki' || pathname.startsWith('/wiki/') ? 'wiki.html' : 'index.html';
|
||||
const served = await sendStatic(response, publicDir, pathname, { fallback, request });
|
||||
const served = await sendStatic(response, publicDir, pathname, { fallback });
|
||||
if (!served) sendEmpty(response, 404);
|
||||
return;
|
||||
}
|
||||
@@ -143,32 +143,8 @@ export function startWebServer({ client = null, setupOnly = false } = {}) {
|
||||
server.listen(env.web.port, env.web.host, () => {
|
||||
const url = env.web.publicUrl || `http://${env.web.host}:${env.web.port}`;
|
||||
log.info(`Dashboard listening on ${env.web.host}:${env.web.port}`, { url, setupOnly });
|
||||
|
||||
// Inside a container, binding a port that is not published succeeds and is
|
||||
// still unreachable from outside, which looks exactly like a crash from the
|
||||
// browser. Say it once, here, where the port is known.
|
||||
if (env.web.host === '0.0.0.0') {
|
||||
log.info(
|
||||
`Le tableau de bord écoute sur le port ${env.web.port}. Dans un conteneur ou sur un panel, ` +
|
||||
'ce port doit aussi faire partie des allocations publiées, sinon il reste injoignable de l’extérieur.',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
server.on('error', (error) => {
|
||||
const causes = {
|
||||
EADDRINUSE: `le port ${env.web.port} est déjà pris par un autre processus`,
|
||||
EACCES: `le port ${env.web.port} est interdit à ce processus (port privilégié, ou restreint par l’hôte)`,
|
||||
EADDRNOTAVAIL: `l’adresse ${env.web.host} n’existe pas sur cette machine`,
|
||||
};
|
||||
const cause = causes[error.code] ?? error.message;
|
||||
|
||||
log.error(
|
||||
`Le tableau de bord n'a pas pu démarrer sur ${env.web.host}:${env.web.port} — ${cause}. ` +
|
||||
'Le bot continue sans le site : corrige `WEB_HOST` ou `WEB_PORT`, puis redémarre.',
|
||||
error,
|
||||
);
|
||||
});
|
||||
server.on('error', (error) => log.error('Dashboard server error', error));
|
||||
// Open event streams would otherwise keep the server from closing.
|
||||
server.on('close', closeEventStreams);
|
||||
return server;
|
||||
|
||||
@@ -101,7 +101,7 @@ export const SECTIONS = Object.freeze([
|
||||
'Toujours dans **OAuth2 → Redirects**, ajoute exactement l’URL affichée dans **Paramètres → Tableau de bord** : c’est l’adresse par laquelle tu ouvres le site, suivie de `/auth/callback`.',
|
||||
'Si le site répond sur un port différent de celui annoncé par ton hébergeur, c’est bien le port que tu utilises dans le navigateur qu’il faut déclarer.',
|
||||
'Génère `WEB_SESSION_SECRET` avec le bouton ci-dessous.',
|
||||
'Choisis `WEB_HOST` : `127.0.0.1` derrière un reverse proxy local, `0.0.0.0` dans un conteneur ou sur un panel d’hébergement.',
|
||||
'Laisse `WEB_HOST` sur `127.0.0.1` et place un reverse proxy HTTPS devant, sauf en développement local.',
|
||||
],
|
||||
links: [{ label: 'OAuth2 du Developer Portal', url: 'https://discord.com/developers/applications' }],
|
||||
},
|
||||
@@ -438,7 +438,7 @@ export const VARIABLES = Object.freeze([
|
||||
key: 'WEB_HOST',
|
||||
section: 'web',
|
||||
label: 'Interface d’écoute',
|
||||
help: 'Derrière un reverse proxy installé sur la même machine, garde `127.0.0.1`. Dans un conteneur ou sur un panel d’hébergement (Pterodactyl, Docker…), il faut `0.0.0.0` : sinon le site n’écoute que sur la boucle locale et reste injoignable de l’extérieur.',
|
||||
help: 'Garde `127.0.0.1` et place un reverse proxy HTTPS devant. `0.0.0.0` expose le site sur le réseau.',
|
||||
type: 'text',
|
||||
default: '127.0.0.1',
|
||||
restartRequired: true,
|
||||
@@ -711,21 +711,6 @@ export function crossCheck(values) {
|
||||
if (!read('WEB_SESSION_SECRET')) {
|
||||
warnings.push('Sans `WEB_SESSION_SECRET`, toutes les sessions sont perdues à chaque redémarrage.');
|
||||
}
|
||||
const publicHost = (() => {
|
||||
try {
|
||||
return new URL(read('WEB_PUBLIC_URL')).hostname;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
})();
|
||||
const localOnly = ['127.0.0.1', 'localhost', '::1'];
|
||||
|
||||
if (read('WEB_HOST') === '127.0.0.1' && publicHost && !localOnly.includes(publicHost)) {
|
||||
warnings.push(
|
||||
`\`WEB_HOST=127.0.0.1\` n'écoute que sur la boucle locale, alors que le site est annoncé sur « ${publicHost} » : il sera injoignable, sauf si un reverse proxy tourne sur la même machine. Dans un conteneur ou sur un panel d'hébergement, mets \`0.0.0.0\`.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (read('WEB_HOST') === '0.0.0.0' && !read('WEB_PUBLIC_URL').startsWith('https://')) {
|
||||
warnings.push('`WEB_HOST=0.0.0.0` sans HTTPS expose les cookies de session en clair sur le réseau.');
|
||||
}
|
||||
|
||||
@@ -88,30 +88,6 @@ describe('env schema', () => {
|
||||
assert.ok(warnings.some((warning) => warning.includes('rejetés')));
|
||||
});
|
||||
|
||||
it('warns when a public address is announced but only loopback is bound', () => {
|
||||
// The failure it prevents: the site answers on the loopback while a domain
|
||||
// points at it, so every request times out and nothing says why.
|
||||
const warnings = crossCheck({
|
||||
WEB_ENABLED: 'true',
|
||||
WEB_HOST: '127.0.0.1',
|
||||
WEB_PUBLIC_URL: 'https://bot.example.org',
|
||||
DISCORD_CLIENT_SECRET: 'x',
|
||||
WEB_SESSION_SECRET: 'y',
|
||||
});
|
||||
assert.ok(warnings.some((warning) => warning.includes('boucle locale')));
|
||||
});
|
||||
|
||||
it('stays quiet when the loopback matches the announced address', () => {
|
||||
const warnings = crossCheck({
|
||||
WEB_ENABLED: 'true',
|
||||
WEB_HOST: '127.0.0.1',
|
||||
WEB_PUBLIC_URL: 'http://localhost:3080',
|
||||
DISCORD_CLIENT_SECRET: 'x',
|
||||
WEB_SESSION_SECRET: 'y',
|
||||
});
|
||||
assert.ok(!warnings.some((warning) => warning.includes('boucle locale')));
|
||||
});
|
||||
|
||||
it('warns when the dashboard is exposed without HTTPS', () => {
|
||||
const warnings = crossCheck({
|
||||
WEB_ENABLED: 'true',
|
||||
|
||||
@@ -95,27 +95,6 @@ describe('dashboard server', () => {
|
||||
assert.match(response.headers.get('content-type'), /javascript/);
|
||||
});
|
||||
|
||||
it('gives its assets a validator so a cache can revalidate', async () => {
|
||||
const response = await app.fetch('/core/dom.js');
|
||||
assert.ok(response.headers.get('etag'), 'no ETag on a static asset');
|
||||
assert.ok(response.headers.get('last-modified'), 'no Last-Modified on a static asset');
|
||||
});
|
||||
|
||||
it('answers 304 when the cached copy is still current', async () => {
|
||||
const first = await app.fetch('/core/dom.js');
|
||||
const etag = first.headers.get('etag');
|
||||
|
||||
const second = await app.fetch('/core/dom.js', { headers: { 'If-None-Match': etag } });
|
||||
assert.equal(second.status, 304);
|
||||
assert.equal(await second.text(), '');
|
||||
});
|
||||
|
||||
it('sends the file again when the validator does not match', async () => {
|
||||
const response = await app.fetch('/core/dom.js', { headers: { 'If-None-Match': '"stale"' } });
|
||||
assert.equal(response.status, 200);
|
||||
assert.ok((await response.text()).length > 0);
|
||||
});
|
||||
|
||||
it('sends the security headers on every response', async () => {
|
||||
const response = await app.fetch('/');
|
||||
assert.equal(response.headers.get('x-frame-options'), 'DENY');
|
||||
|
||||
Reference in new issue
Block a user