Skip to content

Commit 56428eb

Browse files
committed
Add unit test
1 parent 9fb9c88 commit 56428eb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var assert = require('assert');
2+
var common = require('../../common');
3+
var connection = common.createConnection({
4+
port : common.fakeServerPort,
5+
password : 'authswitch'
6+
});
7+
8+
var server = common.createFakeServer();
9+
10+
var connected;
11+
server.listen(common.fakeServerPort, function (err) {
12+
assert.ifError(err);
13+
14+
connection.connect(function (err, result) {
15+
assert.ifError(err);
16+
17+
connected = result;
18+
19+
connection.destroy();
20+
server.destroy();
21+
});
22+
});
23+
24+
server.on('connection', function(incomingConnection) {
25+
incomingConnection.on('authSwitchResponse', function (packet) {
26+
this._sendAuthResponse(packet.data, Buffer.from('authswitch'));
27+
});
28+
29+
incomingConnection.on('clientAuthentication', function () {
30+
this.authSwitchRequest({
31+
authMethodName : 'mysql_clear_password',
32+
authMethodData : Buffer.alloc(0)
33+
});
34+
});
35+
36+
incomingConnection.handshake();
37+
});
38+
39+
process.on('exit', function() {
40+
assert.equal(connected.fieldCount, 0);
41+
});

0 commit comments

Comments
 (0)