Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Dec 29, 2024
1 parent 4ba64b1 commit 6c649b7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/fix-GHSA-v2v2-hph8-q5xp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { describe, after, it } = require('node:test')
const fastify = require('fastify')
const fastifyFrom = require('..')
const { isIPv6 } = require('node:net')

describe('GHSA-v2v2-hph8-q5xp', function () {
it('should not parse the body if it is an object', async function (t) {
Expand All @@ -19,14 +20,21 @@ describe('GHSA-v2v2-hph8-q5xp', function () {

await upstream.listen({ port: 0 })


Check failure on line 23 in test/fix-GHSA-v2v2-hph8-q5xp.test.js

View workflow job for this annotation

GitHub Actions / test / Lint Code

More than 1 blank line not allowed
let upstreamAdress = upstream.server.address().address

if (isIPv6(upstreamAdress)) {
upstreamAdress = `[${upstreamAdress}]`
}

const app = fastify()
app.register(fastifyFrom)

app.post('/test', (request, reply) => {
if (request.body.method === 'invalid_method') {
return reply.code(400).send({ message: 'payload contains invalid method' })
}
reply.from(`http://${upstream.server.address().address}:${upstream.server.address().port}/test`)
reply.from(`http://${upstreamAdress}:${upstream.server.address().port}/test`)
})

await app.listen({ port: 0 })
Expand All @@ -36,8 +44,14 @@ describe('GHSA-v2v2-hph8-q5xp', function () {
app.close()
})

const appAddress = app.server.address().address

if (isIPv6(appAddress)) {
appAddress = `[${appAddress}]`

Check failure on line 50 in test/fix-GHSA-v2v2-hph8-q5xp.test.js

View workflow job for this annotation

GitHub Actions / test / Lint Code

'appAddress' is constant
}

const response = await fetch(
`http://${app.server.address().address}:${app.server.address().port}/test`,
`http://${appAddress}:${app.server.address().port}/test`,
{
headers: { 'content-type': 'application/json ; charset=utf-8' },
// eslint-disable-next-line no-useless-escape
Expand Down

0 comments on commit 6c649b7

Please sign in to comment.