diff options
author | Pavel Savchenko <asfaltboy@gmail.com> | 2016-04-27 17:58:16 +0200 |
---|---|---|
committer | Pavel Savchenko <asfaltboy@gmail.com> | 2016-04-27 17:58:16 +0200 |
commit | 1dabd3be63b31ffe8760fb879a330f945d2367e8 (patch) | |
tree | 7d3f6f85e11aa276e124f12900f6208679e8b94d /tests/test_main.py | |
parent | 64c50cfd35016b24d09f1fcf60e8d6fc2d0685b4 (diff) |
Unquote URI parts prior to using in connection
As you know [RFC-3986][1] allows passing "disallowed" characters
as long as these are percent encoded.
Since we deal with the url parsing, we can expect this to happen
and need to use the values after they have been decoded.
[1]: https://tools.ietf.org/html/rfc3986#section-2.1
Diffstat (limited to 'tests/test_main.py')
-rw-r--r-- | tests/test_main.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_main.py b/tests/test_main.py index df4bf71f..08fd471e 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,6 +1,7 @@ import os import platform import stat +import mock import pytest try: @@ -83,3 +84,10 @@ def test_missing_rc_dir(tmpdir): PGCli(pgclirc_file=rcfile) assert os.path.exists(rcfile) + + +def test_quoted_db_uri(tmpdir): + with mock.patch.object(PGCli, 'connect') as mock_connect: + cli = PGCli(pgclirc_file=str(tmpdir.join("rcfile"))) + cli.connect_uri('postgres://bar%5E:%5Dfoo@baz.com/testdb%5B') + mock_connect.assert_called_with('testdb[', 'baz.com', 'bar^', None, ']foo') |