From 20a2cbc810016ecbda0f6fb507a109addc682afa Mon Sep 17 00:00:00 2001 From: za-creature Date: Thu, 11 Apr 2013 22:47:32 +0300 Subject: [PATCH] Update creation-tests.js added unittest for urlencoded components --- test/unit/connection-parameters/creation-tests.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/unit/connection-parameters/creation-tests.js b/test/unit/connection-parameters/creation-tests.js index 6e73f7c..2a4689a 100644 --- a/test/unit/connection-parameters/creation-tests.js +++ b/test/unit/connection-parameters/creation-tests.js @@ -138,12 +138,21 @@ test('libpq connection string building', function() { assert.equal(subject.password, sourceConfig.password); }); - test('password contains weird characters', function() { - var strang = 'pg://my first name:is&%awesome!@localhost:9000'; + test('username or password contains weird characters', function() { + var strang = 'pg://my f%irst name:is&%awesome!@localhost:9000'; var subject = new ConnectionParameters(strang); - assert.equal(subject.user, 'my first name'); + assert.equal(subject.user, 'my f%irst name'); assert.equal(subject.password, 'is&%awesome!'); assert.equal(subject.host, 'localhost'); }); + + test("url is properly encoded", function() { + var encoded = "pg://bi%25na%25%25ry%20:s%40f%23@localhost/%20u%2520rl"; + var subject = new ConnectionParameters(encoded); + assert.equal(subject.user, "bi%na%%ry "); + assert.equal(subject.password, "s@f#"); + assert.equal(subject.host, 'localhost'); + assert.equal(subject.path, " u%20rl"); + }); });