From 7ad09cac48ba1bdba7f448fe8129f58b42e036d7 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Wed, 18 Sep 2024 20:35:20 +0000 Subject: [PATCH 1/2] test: add asserts to validate test assumptions Refs: https://github.com/nodejs/node/pull/54968 Refs: https://github.com/nodejs/node/issues/53382 Add additional asserts as suggestd by Richard in: https://github.com/nodejs/node/pull/54968 Signed-off-by: Michael Dawson --- test/parallel/test-tls-cert-regression.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/parallel/test-tls-cert-regression.js b/test/parallel/test-tls-cert-regression.js index c58998e594ba58..1f47c6248ffa2c 100644 --- a/test/parallel/test-tls-cert-regression.js +++ b/test/parallel/test-tls-cert-regression.js @@ -22,6 +22,7 @@ 'use strict'; const common = require('../common'); const fixtures = require('../common/fixtures'); +const assert = require('assert'); if (!common.hasCrypto) common.skip('missing crypto'); @@ -43,6 +44,8 @@ while (cert[cert.length - 1 - i] === 0x0a) i++; if (i !== 0) cert = cert.slice(0, cert.length - i); function test(cert, key, cb) { + assert.notStrictEqual(cert[cert.length - 1], 0x0a); + assert.notStrictEqual(key[key.length - 1], 0x0a); const server = tls.createServer({ cert, key From 38bb9d6f0b7280be15df201b35f30e49e65d0e83 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Thu, 19 Sep 2024 11:58:58 -0400 Subject: [PATCH 2/2] Update test/parallel/test-tls-cert-regression.js Co-authored-by: Richard Lau --- test/parallel/test-tls-cert-regression.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tls-cert-regression.js b/test/parallel/test-tls-cert-regression.js index 1f47c6248ffa2c..5dab23401302ed 100644 --- a/test/parallel/test-tls-cert-regression.js +++ b/test/parallel/test-tls-cert-regression.js @@ -44,8 +44,8 @@ while (cert[cert.length - 1 - i] === 0x0a) i++; if (i !== 0) cert = cert.slice(0, cert.length - i); function test(cert, key, cb) { - assert.notStrictEqual(cert[cert.length - 1], 0x0a); - assert.notStrictEqual(key[key.length - 1], 0x0a); + assert.notStrictEqual(cert.at(-1), 0x0a); + assert.notStrictEqual(key.at(-1), 0x0a); const server = tls.createServer({ cert, key