From 68c7116d4961b6b04dc3775add6f4300698a4149 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Mon, 5 Feb 2018 10:30:08 +0100 Subject: [PATCH] [IMP] keychain: get_password must not be accessible from outside --- keychain/models/keychain.py | 2 +- keychain/tests/test_keychain.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/keychain/models/keychain.py b/keychain/models/keychain.py index 0008adb3c..dbdaf13ff 100644 --- a/keychain/models/keychain.py +++ b/keychain/models/keychain.py @@ -60,7 +60,7 @@ class KeychainAccount(models.Model): # Only needed in v8 for _description_searchable issues return True - def get_password(self): + def _get_password(self): """Password in clear text.""" try: return self._decode_password(self.password) diff --git a/keychain/tests/test_keychain.py b/keychain/tests/test_keychain.py index 164a0a781..ff4a04bfb 100644 --- a/keychain/tests/test_keychain.py +++ b/keychain/tests/test_keychain.py @@ -65,7 +65,7 @@ class TestKeychain(TransactionCase): account.clear_password = password account._inverse_set_password() self.assertTrue(account.clear_password != account.password) - self.assertEqual(account.get_password(), password) + self.assertEqual(account._get_password(), password) def test_wrong_key(self): """It should raise an exception when encoded key != decoded.""" @@ -75,7 +75,7 @@ class TestKeychain(TransactionCase): account._inverse_set_password() config['keychain_key'] = Fernet.generate_key() try: - account.get_password() + account._get_password() self.assertTrue(False, 'It should not work with another key') except Warning as err: self.assertTrue(True, 'It should raise a Warning') @@ -131,13 +131,13 @@ class TestKeychain(TransactionCase): account.clear_password = 'abc' account._inverse_set_password() self.assertEqual( - account.get_password(), + account._get_password(), 'abc', 'Should work with dev') config['running_env'] = 'prod' with self.assertRaises(Warning): self.assertEqual( - account.get_password(), + account._get_password(), 'abc', 'Should not work with prod key') def test_multienv_blank(self): @@ -151,12 +151,12 @@ class TestKeychain(TransactionCase): account.clear_password = 'abc' account._inverse_set_password() self.assertEqual( - account.get_password(), + account._get_password(), 'abc', 'Should work with dev') config['running_env'] = 'prod' self.assertEqual( - account.get_password(), + account._get_password(), 'abc', 'Should work with prod') def test_multienv_force(self): @@ -175,12 +175,12 @@ class TestKeychain(TransactionCase): with self.assertRaises(Warning): self.assertEqual( - account.get_password(), + account._get_password(), 'abc', 'Should not work with dev') config['running_env'] = 'prod' self.assertEqual( - account.get_password(), + account._get_password(), 'abc', 'Should work with prod') def test_wrong_json(self):