diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-05-20 21:18:36 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-05-20 21:18:36 +0100 |
| commit | 9cf658ec6e2844c50fb7824a42f71cf965e607c8 (patch) | |
| tree | 943f35adc8110267fcba884eeca81a10758ef4a9 /tests | |
| parent | abca14d6015dc88a8e66c4baa374ab7102798ee4 (diff) | |
| download | psycopg2-9cf658ec6e2844c50fb7824a42f71cf965e607c8.tar.gz | |
Fixed refcount handling in encrypt_password
Added tests to check bad types, which discovered the above problem: on
type error we would have decref'd on exit something that was only
borrowed (because we wouldn't have performed matching increfs).
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/test_connection.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/test_connection.py b/tests/test_connection.py index 7861ab7..13635f1 100755 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -1482,6 +1482,17 @@ class TestEncryptPassword(ConnectingTestCase): password='psycopg2', user='ashesh', scope=self.conn, algorithm='scram-sha-256') + def test_bad_types(self): + self.assertRaises(TypeError, ext.encrypt_password) + self.assertRaises(TypeError, ext.encrypt_password, + 'password', 42, self.conn, 'md5') + self.assertRaises(TypeError, ext.encrypt_password, + 42, 'user', self.conn, 'md5') + self.assertRaises(TypeError, ext.encrypt_password, + 42, 'user', 'wat', 'abc') + self.assertRaises(TypeError, ext.encrypt_password, + 'password', 'user', 'wat', 42) + class AutocommitTests(ConnectingTestCase): def test_closed(self): |
