2010-10-24 08:21:01 +08:00
|
|
|
require(__dirname + '/test-helper')
|
|
|
|
test('md5 authentication', function() {
|
|
|
|
var client = createClient();
|
|
|
|
client.password = "!";
|
|
|
|
var salt = Buffer([1, 2, 3, 4]);
|
|
|
|
client.connection.emit('authenticationMD5Password', {salt: salt});
|
|
|
|
|
|
|
|
test('responds', function() {
|
2011-10-11 08:21:06 +08:00
|
|
|
assert.lengthIs(client.connection.stream.packets, 1);
|
2010-10-24 08:21:01 +08:00
|
|
|
test('should have correct encrypted data', function() {
|
2010-10-24 09:26:24 +08:00
|
|
|
var encrypted = Client.md5(client.password + client.user);
|
|
|
|
encrypted = Client.md5(encrypted + salt.toString('binary'));
|
2010-10-24 08:21:01 +08:00
|
|
|
var password = "md5" + encrypted
|
|
|
|
//how do we want to test this?
|
2010-10-25 11:52:12 +08:00
|
|
|
assert.equalBuffers(client.connection.stream.packets[0], new BufferList()
|
2010-10-24 08:21:01 +08:00
|
|
|
.addCString(password).join(true,'p'))
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|