static-headers.test.js — astro Source File
Architecture documentation for static-headers.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 918588cc_b821_5326_cd80_4ed1b05ed6fd["static-headers.test.js"] 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc["../dist/index.js"] 918588cc_b821_5326_cd80_4ed1b05ed6fd --> 760b1776_8858_e3bd_06b8_5cc4c1a9cbdc ff334e41_2760_839e_fc38_ab9318c18dfc["test-utils.js"] 918588cc_b821_5326_cd80_4ed1b05ed6fd --> ff334e41_2760_839e_fc38_ab9318c18dfc 0b7a6b11_e910_da4b_c617_1880167f44ef["loadFixture"] 918588cc_b821_5326_cd80_4ed1b05ed6fd --> 0b7a6b11_e910_da4b_c617_1880167f44ef 0f98dbf7_3a77_7344_74c6_cb678c4a98d0["waitServerListen"] 918588cc_b821_5326_cd80_4ed1b05ed6fd --> 0f98dbf7_3a77_7344_74c6_cb678c4a98d0 e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 918588cc_b821_5326_cd80_4ed1b05ed6fd --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 918588cc_b821_5326_cd80_4ed1b05ed6fd --> 6b0635f9_51ea_77aa_767b_7857878e98a6 style 918588cc_b821_5326_cd80_4ed1b05ed6fd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import nodejs from '../dist/index.js';
import { loadFixture, waitServerListen } from './test-utils.js';
describe('Static headers', () => {
let fixture;
before(async () => {
fixture = await loadFixture({ root: './fixtures/static-headers' });
await fixture.build();
});
it('CSP headers are added when CSP is enabled', async () => {
const headers = JSON.parse(await fixture.readFile('../dist/_headers.json'));
const csp = headers
.find((x) => x.pathname === '/')
.headers.find((x) => x.key === 'Content-Security-Policy');
assert.notEqual(csp, undefined, 'the index must have CSP headers');
assert.ok(
csp.value.includes('script-src'),
'must contain the script-src directive because of the server island',
);
});
it('CSP headers are added to the request', async () => {});
});
describe('Static headers', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
let server;
before(async () => {
fixture = await loadFixture({
root: './fixtures/static-headers/',
output: 'server',
adapter: nodejs({ mode: 'standalone', staticHeaders: true }),
});
await fixture.build();
const { startServer } = await fixture.loadAdapterEntryModule();
const res = startServer();
server = res.server;
await waitServerListen(server.server);
});
after(async () => {
await server.stop();
// await fixture.clean();
});
it('CSP headers are added to the request', async () => {
const res = await fetch(`http://${server.host}:${server.port}/`);
const cps = res.headers.get('Content-Security-Policy');
assert.ok(
cps.includes('script-src'),
'should contain script-src directive due to server island',
);
});
it('CSP headers are added to dynamic orute', async () => {
const res = await fetch(`http://${server.host}:${server.port}/one`);
const cps = res.headers.get('Content-Security-Policy');
assert.ok(
cps.includes('script-src'),
'should contain script-src directive due to server island',
);
});
});
Domain
Dependencies
- ../dist/index.js
- loadFixture
- node:test
- strict
- test-utils.js
- waitServerListen
Source
Frequently Asked Questions
What does static-headers.test.js do?
static-headers.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does static-headers.test.js depend on?
static-headers.test.js imports 6 module(s): ../dist/index.js, loadFixture, node:test, strict, test-utils.js, waitServerListen.
Where is static-headers.test.js in the architecture?
static-headers.test.js is located at packages/integrations/node/test/static-headers.test.js (domain: CoreAstro, directory: packages/integrations/node/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free