mirror of
https://github.com/oven-sh/bun
synced 2026-02-15 21:32:05 +00:00
Add more passing tests
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
|
||||
{
|
||||
assert.throws(
|
||||
() => { tls.createSecureContext({ clientCertEngine: 0 }); },
|
||||
{ code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: / Received type number \(0\)/ });
|
||||
}
|
||||
58
test/js/node/test/parallel/test-tls-no-sslv23.js
Normal file
58
test/js/node/test/parallel/test-tls-no-sslv23.js
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
|
||||
assert.throws(function() {
|
||||
tls.createSecureContext({ secureProtocol: 'blargh' });
|
||||
}, {
|
||||
code: 'ERR_TLS_INVALID_PROTOCOL_METHOD',
|
||||
message: 'Unknown method: blargh',
|
||||
});
|
||||
|
||||
const errMessageSSLv2 = /SSLv2 methods disabled/;
|
||||
|
||||
assert.throws(function() {
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv2_method' });
|
||||
}, errMessageSSLv2);
|
||||
|
||||
assert.throws(function() {
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv2_client_method' });
|
||||
}, errMessageSSLv2);
|
||||
|
||||
assert.throws(function() {
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv2_server_method' });
|
||||
}, errMessageSSLv2);
|
||||
|
||||
const errMessageSSLv3 = /SSLv3 methods disabled/;
|
||||
|
||||
assert.throws(function() {
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv3_method' });
|
||||
}, errMessageSSLv3);
|
||||
|
||||
assert.throws(function() {
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv3_client_method' });
|
||||
}, errMessageSSLv3);
|
||||
|
||||
assert.throws(function() {
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv3_server_method' });
|
||||
}, errMessageSSLv3);
|
||||
|
||||
// Note that SSLv2 and SSLv3 are disallowed but SSLv2_method and friends are
|
||||
// still accepted. They are OpenSSL's way of saying that all known protocols
|
||||
// are supported unless explicitly disabled (which we do for SSLv2 and SSLv3.)
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv23_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv23_client_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'SSLv23_server_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_client_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_server_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_1_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_1_client_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_1_server_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_2_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_2_client_method' });
|
||||
tls.createSecureContext({ secureProtocol: 'TLSv1_2_server_method' });
|
||||
@@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const tls = require('tls');
|
||||
const util = require('util');
|
||||
const fixtures = require('../common/fixtures');
|
||||
|
||||
const sent = 'hello world';
|
||||
const serverOptions = {
|
||||
isServer: true,
|
||||
key: fixtures.readKey('agent1-key.pem'),
|
||||
cert: fixtures.readKey('agent1-cert.pem')
|
||||
};
|
||||
|
||||
let ssl = null;
|
||||
|
||||
process.on('exit', function() {
|
||||
assert.ok(ssl !== null);
|
||||
// If the internal pointer to stream_ isn't cleared properly then this
|
||||
// will abort.
|
||||
util.inspect(ssl);
|
||||
});
|
||||
|
||||
const server = tls.createServer(serverOptions, function(s) {
|
||||
s.on('data', function() { });
|
||||
s.on('end', function() {
|
||||
server.close();
|
||||
s.destroy();
|
||||
});
|
||||
}).listen(0, function() {
|
||||
const c = new tls.TLSSocket();
|
||||
ssl = c.ssl;
|
||||
c.connect(this.address().port, function() {
|
||||
c.end(sent);
|
||||
});
|
||||
});
|
||||
24
test/js/node/test/parallel/test-tls-snicallback-error.js
Normal file
24
test/js/node/test/parallel/test-tls-snicallback-error.js
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
|
||||
const assert = require('assert');
|
||||
const net = require('net');
|
||||
const tls = require('tls');
|
||||
|
||||
for (const SNICallback of ['fhqwhgads', 42, {}, []]) {
|
||||
assert.throws(() => {
|
||||
tls.createServer({ SNICallback });
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError',
|
||||
});
|
||||
|
||||
assert.throws(() => {
|
||||
new tls.TLSSocket(new net.Socket(), { isServer: true, SNICallback });
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
name: 'TypeError',
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user