Commit cc9a151c authored by Sebastiaan Deckers's avatar Sebastiaan Deckers 馃悜

test: check that the Server signature header is reported

parent a35d3015
Pipeline #37883678 failed with stages
in 2 minutes and 19 seconds
......@@ -6,7 +6,7 @@ Default: `true`
Boolean value that adds the `Server:` header to all HTTP responses if `true`, and omits that header if `false`.
The value of the header identifies the versions of the server, Node.js, nghttp2, and the operating system.
The value of the header identifies the versions of the server, Node.js, and the operating system.
Often disabled for reasons of paranoia or placebo performance tuning.
......
......@@ -3,12 +3,11 @@ const osName = require('os-name')
function serverHeader () {
const { pkg } = readPkgUp({ cwd: __dirname })
const { name, version } = pkg
const { node, nghttp2 } = process.versions
const { version } = pkg
const { node } = process.versions
const products = [
`https://commons.host ${name} ${version}`,
`node ${node}`,
`nghttp2 ${nghttp2}`,
`commonshost ${version}`,
`nodejs ${node}`,
`${osName()}`
]
return products.join(', ')
......
const test = require('blue-tape')
const { Master } = require('..')
const { join } = require('path')
const { h1, h2 } = require('./helpers/receive')
const expected = new RegExp(
'^' +
'commonshost \\d+\\.\\d+\\.\\d+, ' +
'nodejs \\d+\\.\\d+\\.\\d+, ' +
'.+' + // OS name & version
'$'
)
let master
test('start server with Via header pseudonym', async (t) => {
const cwd = join(__dirname, 'fixtures')
const options = { signature: true }
master = new Master({ cwd, options })
await master.listen()
})
test('Server header over plaintext HTTP/1', async (t) => {
const url = 'http://localhost:8080/'
const response = await h1(url)
const actual = response.headers.get('server')
t.ok(expected.test(actual))
})
test('Server header over HTTP/2', async (t) => {
const url = 'https://localhost:8443/'
const response = await h2(url)
const actual = response.headers.get('server')
t.ok(expected.test(actual))
})
test('stop server', async (t) => master.close())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment