From ff657862e606b5ea45c71483530a9334ba256d3a Mon Sep 17 00:00:00 2001 From: Cal Henderson Date: Wed, 1 Sep 2010 15:56:48 -0500 Subject: [PATCH] test a few rounds of the hashPassword function. looks to be buggy right now --- test/fixture/libmysql_password.c | 15 +++++++++------ test/simple/test-auth-old.js | 13 +++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 test/simple/test-auth-old.js diff --git a/test/fixture/libmysql_password.c b/test/fixture/libmysql_password.c index 048d95f85..29dc545d9 100644 --- a/test/fixture/libmysql_password.c +++ b/test/fixture/libmysql_password.c @@ -72,16 +72,19 @@ void scramble_323(char *to, const char *message, const char *password) } int main() { - const char password[] = "root"; - uint password_len = 4; + const char password1[] = "root"; + const char password2[] = "long password test"; + const char password3[] = "saf789yasfbsd89f"; ulong result[2]; - printf("hash_password(\"%s\"):\n", password); + hash_password((ulong*)result, password1, strlen(password1)); + printf("hash_password(\"%s\") = %08x%08x\n", password1, result[0], result[1]); - hash_password(result, password, password_len); + hash_password((ulong*)result, password2, strlen(password2)); + printf("hash_password(\"%s\") = %08x%08x\n", password2, result[0], result[1]); - printf("result 1: %ld\n", result[0]); - printf("result 2: %ld\n", result[1]); + hash_password((ulong*)result, password3, strlen(password3)); + printf("hash_password(\"%s\") = %08x%08x\n", password3, result[0], result[1]); return 23; } diff --git a/test/simple/test-auth-old.js b/test/simple/test-auth-old.js new file mode 100644 index 000000000..c0eea4bf3 --- /dev/null +++ b/test/simple/test-auth-old.js @@ -0,0 +1,13 @@ +require('../common'); + +var auth = require('mysql/auth'); + +function test_hash_password(password, bytes){ + var expected = new Buffer(bytes); + var actual = auth.hashPassword(password); + assert.deepEqual(actual, expected); // , 'hashPassword('+password+') failed'); +} + +test_hash_password('root', [0x67, 0x45, 0x7E, 0x22, 0x6a, 0x1a, 0x15, 0xbd]); +test_hash_password('long password test', [0x6c, 0x24, 0x68, 0x41, 0x2c, 0xa6, 0x86, 0x56]); +test_hash_password('saf789yasfbsd89f', [0x6c, 0x9b, 0x2f, 0x07, 0x17, 0xeb, 0x95, 0xc6]);