Home / File/ compile-image-service.test.js — astro Source File

compile-image-service.test.js — astro Source File

Architecture documentation for compile-image-service.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  fd4af722_4ae0_67f5_e5af_f6262c76050a["compile-image-service.test.js"]
  635e1221_67bb_e784_624a_d6d63643872b["_test-utils.js"]
  fd4af722_4ae0_67f5_e5af_f6262c76050a --> 635e1221_67bb_e784_624a_d6d63643872b
  33b9a01d_12ac_568f_9775_9e80b35139cb["loadFixture"]
  fd4af722_4ae0_67f5_e5af_f6262c76050a --> 33b9a01d_12ac_568f_9775_9e80b35139cb
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  fd4af722_4ae0_67f5_e5af_f6262c76050a --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  fd4af722_4ae0_67f5_e5af_f6262c76050a --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style fd4af722_4ae0_67f5_e5af_f6262c76050a 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 { loadFixture } from './_test-utils.js';

describe('CompileImageService', () => {
	let fixture;
	let previewServer;

	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/compile-image-service/',
		});
		await fixture.build();
		previewServer = await fixture.preview();
	});

	after(async () => {
		await previewServer.stop();
	});

	it('forbids http://', async () => {
		const res = await fixture.fetch('/_image?href=http://placehold.co/600x400');
		const html = await res.text();
		const status = res.status;
		assert.equal(html, 'Forbidden');
		assert.equal(status, 403);
	});

	it('forbids https://', async () => {
		const res = await fixture.fetch('/_image?href=https://placehold.co/600x400');
		const html = await res.text();
		const status = res.status;
		assert.equal(html, 'Forbidden');
		assert.equal(status, 403);
	});

	it('forbids //', async () => {
		const res = await fixture.fetch('/_image?href=//placehold.co/600x400');
		const html = await res.text();
		const status = res.status;
		assert.equal(html, 'Blocked');
		assert.equal(status, 403);
	});

	it('allows trusted with redirect', async () => {
		const res = await fixture.fetch(
			'/_image?href=https://astro.build/_astro/HeroBackground.B0iWl89K_2hpsgp.webp',
			{ redirect: 'manual' },
		);
		const header = res.headers.get('location');
		const status = res.status;
		assert.equal(header, 'https://astro.build/_astro/HeroBackground.B0iWl89K_2hpsgp.webp');
		assert.equal(status, 302);
	});

	it('allows local', async () => {
		const res = await fixture.fetch('/_image?href=/_astro/placeholder.gLBdjEDe.jpg');
		const blob = await res.blob();
		const status = res.status;
		assert.equal(blob.type, 'image/jpeg');
		assert.equal(status, 200);
	});
});

Domain

Dependencies

Frequently Asked Questions

What does compile-image-service.test.js do?
compile-image-service.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does compile-image-service.test.js depend on?
compile-image-service.test.js imports 4 module(s): _test-utils.js, loadFixture, node:test, strict.
Where is compile-image-service.test.js in the architecture?
compile-image-service.test.js is located at packages/integrations/cloudflare/test/compile-image-service.test.js (domain: CoreAstro, directory: packages/integrations/cloudflare/test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free