Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: port balanced-pool, ca-fingerprint, client-abort tests to node:test #2584

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ca-fingerprint
  • Loading branch information
sosukesuzuki committed Jan 3, 2024
commit e45f756dee5dac201ee5aed55eacbcf777bd0f62
29 changes: 17 additions & 12 deletions test/ca-fingerprint.js → test/node-test/ca-fingerprint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

const crypto = require('crypto')
const https = require('https')
const { test } = require('tap')
const { Client, buildConnector } = require('..')
const { test } = require('node:test')
const { Client, buildConnector } = require('../..')
const pem = require('https-pem')
const { tspl } = require('@matteo.collina/tspl')

const caFingerprint = getFingerprint(pem.cert.toString()
.split('\n')
Expand All @@ -13,8 +14,8 @@ const caFingerprint = getFingerprint(pem.cert.toString()
.join('')
)

test('Validate CA fingerprint with a custom connector', t => {
t.plan(2)
test('Validate CA fingerprint with a custom connector', async t => {
const p = tspl(t, { plan: 2 })

const server = https.createServer(pem, (req, res) => {
res.setHeader('Content-Type', 'text/plain')
Expand All @@ -38,7 +39,7 @@ test('Validate CA fingerprint with a custom connector', t => {
}
})

t.teardown(() => {
t.after(() => {
client.close()
server.close()
})
Expand All @@ -47,19 +48,21 @@ test('Validate CA fingerprint with a custom connector', t => {
path: '/',
method: 'GET'
}, (err, data) => {
t.error(err)
p.ifError(err)

data.body
.resume()
.on('end', () => {
t.pass()
p.ok(1)
})
})
})

await p.completed
})

test('Bad CA fingerprint with a custom connector', t => {
t.plan(2)
test('Bad CA fingerprint with a custom connector', async t => {
const p = tspl(t, { plan: 2 })

const server = https.createServer(pem, (req, res) => {
res.setHeader('Content-Type', 'text/plain')
Expand All @@ -83,7 +86,7 @@ test('Bad CA fingerprint with a custom connector', t => {
}
})

t.teardown(() => {
t.after(() => {
client.close()
server.close()
})
Expand All @@ -92,10 +95,12 @@ test('Bad CA fingerprint with a custom connector', t => {
path: '/',
method: 'GET'
}, (err, data) => {
t.equal(err.message, 'Fingerprint does not match')
t.equal(data.body, undefined)
p.strictEqual(err.message, 'Fingerprint does not match')
p.strictEqual(data.body, undefined)
})
})

await p.completed
})

function getIssuerCertificate (socket) {
Expand Down