https.test.js — fastify Source File
Architecture documentation for https.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const { request } = require('undici')
const Fastify = require('../..')
const { buildCertificate } = require('../build-certificate')
const { Agent } = require('undici')
test.before(buildCertificate)
test('https', async (t) => {
t.plan(3)
let fastify
try {
fastify = Fastify({
https: {
key: global.context.key,
cert: global.context.cert
}
})
t.assert.ok('Key/cert successfully loaded')
} catch (e) {
t.assert.fail('Key/cert loading failed')
}
fastify.get('/', function (req, reply) {
reply.code(200).send({ hello: 'world' })
})
fastify.get('/proto', function (req, reply) {
reply.code(200).send({ proto: req.protocol })
})
await fastify.listen({ port: 0 })
t.after(() => { fastify.close() })
await t.test('https get request', async t => {
t.plan(4)
const result = await fetch('https://localhost:' + fastify.server.address().port, {
dispatcher: new Agent({
connect: {
rejectUnauthorized: false
}
})
})
t.assert.ok(result.ok)
t.assert.strictEqual(result.status, 200)
const body = await result.text()
t.assert.strictEqual(result.headers.get('content-length'), '' + body.length)
t.assert.deepStrictEqual(JSON.parse(body), { hello: 'world' })
})
await t.test('https get request without trust proxy - protocol', async t => {
t.plan(3)
const result1 = await fetch(`${'https://localhost:' + fastify.server.address().port}/proto`, {
dispatcher: new Agent({
connect: {
rejectUnauthorized: false
// ... (77 more lines)
Source
Frequently Asked Questions
What does https.test.js do?
https.test.js is a source file in the fastify codebase, written in javascript.
Where is https.test.js in the architecture?
https.test.js is located at test/https/https.test.js (directory: test/https).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free