8000 tests: set server SSL option in tests directly as needed · mysqljs/mysql@74fbc4d · GitHub
[go: up one dir, main page]

Skip to content

Commit 74fbc4d

Browse files
committed
tests: set server SSL option in te 8000 sts directly as needed
1 parent be18e04 commit 74fbc4d

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

test/FakeServer.js

-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ var Util = require('util');
1818

1919
module.exports = FakeServer;
2020
Util.inherits(FakeServer, EventEmitter);
21-
function FakeServer() {
21+
function FakeServer(options) {
2222
EventEmitter.call(this);
2323

24-
this._server = null;
2524
this._connections = [];
25+
this._options = options || {};
26+
this._server = null;
2627
}
2728

2829
FakeServer.prototype.listen = function(port, cb) {
@@ -35,7 +36,7 @@ FakeServer.prototype.port = function() {
3536
};
3637

3738
FakeServer.prototype._handleConnection = function(socket) {
38-
var connection = new FakeConnection(socket);
39+
var connection = new FakeConnection(this, socket);
3940

4041
if (!this.emit('connection', connection)) {
4142
connection.handshake();
@@ -57,13 +58,14 @@ FakeServer.prototype.destroy = function() {
5758
};
5859

5960
Util.inherits(FakeConnection, EventEmitter);
60-
function FakeConnection(socket) {
61+
function FakeConnection(server, socket) {
6162
EventEmitter.call(this);
6263

6364
this.database = null;
6465
this.user = null;
6566

6667
this._cipher = null;
68+
this._server = server;
6769
this._socket = socket;
6870
this._stream = socket;
6971
this._parser = new Parser({onPacket: this._parsePacket.bind(this)});
@@ -439,7 +441,7 @@ if (tls.TLSSocket) {
439441
this._socket.removeAllListeners('data');
440442

441443
// socket <-> encrypted
442-
var secureContext = tls.createSecureContext(common.getSSLConfig());
444+
var secureContext = tls.createSecureContext(common.getSSLConfig(this._server._options.ssl));
443445
var secureSocket = new tls.TLSSocket(this._socket, {
444446
secureContext : secureContext,
445447
isServer : true

test/common.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ common.getTestConfig = function(config) {
142142
}, config);
143143
};
144144

145-
common.getSSLConfig = function() {
146-
return {
147-
ca : fs.readFileSync(path.join(common.fixtures, 'server.crt'), 'ascii'),
148-
cert : fs.readFileSync(path.join(common.fixtures, 'server.crt'), 'ascii'),
149-
ciphers : 'ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:AES128-SHA:HIGH:!MD5:!aNULL:!EDH',
150-
key 8000 : fs.readFileSync(path.join(common.fixtures, 'server.key'), 'ascii')
151-
};
145+
common.getSSLConfig = function getSSLConfig(config) {
146+
return common.extend({
147+
ca : fs.readFileSync(path.join(common.fixtures, 'server.crt'), 'ascii'),
148+
cert : fs.readFileSync(path.join(common.fixtures, 'server.crt'), 'ascii'),
149+
key : fs.readFileSync(path.join(common.fixtures, 'server.key'), 'ascii')
150+
}, config);
152151
};

test/unit/connection/test-connection-ssl-ciphers.js

Lines changed: 5 additions & 1 deletion
4E7E
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
var assert = require('assert');
22
var common = require('../../common');
33

4-
var server = common.createFakeServer();
4+
var server = common.createFakeServer({
5+
ssl: {
6+
ciphers: 'ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:AES128-SHA:HIGH:!MD5:!aNULL:!EDH'
7+
}
8+
});
59

610
server.listen(0, function (err) {
711
assert.ifError(err);

0 commit comments

Comments
 (0)
0