From e0f6ff100f112d956995adbb18b112a8fa8eed59 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 11 Mar 2025 17:07:59 -0700 Subject: [PATCH] node: fix test-tls-connect-pipe.js --- .../test/parallel/test-tls-connect-pipe.js | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/js/node/test/parallel/test-tls-connect-pipe.js diff --git a/test/js/node/test/parallel/test-tls-connect-pipe.js b/test/js/node/test/parallel/test-tls-connect-pipe.js new file mode 100644 index 00000000000000..88e78b7a2b2e59 --- /dev/null +++ b/test/js/node/test/parallel/test-tls-connect-pipe.js @@ -0,0 +1,47 @@ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +'use strict'; +const common = require('../common'); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +const tls = require('tls'); +const fixtures = require('../common/fixtures'); + +const options = { + key: fixtures.readKey('agent1-key.pem'), + cert: fixtures.readKey('agent1-cert.pem') +}; + +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); + +const server = tls.Server(options, common.mustCall(function(socket) { + server.close(); +})); +server.listen(common.PIPE, common.mustCall(function() { + const options = { rejectUnauthorized: false }; + const client = tls.connect(common.PIPE, options, common.mustCall(function() { + client.end(); + })); +}));