[IMP] keychain: get_password must not be accessible from outside
This commit is contained in:
parent
f54438b3cd
commit
a7203d408d
|
|
@ -3,7 +3,7 @@
|
||||||
{
|
{
|
||||||
"name": "Keychain",
|
"name": "Keychain",
|
||||||
"summary": "Store accounts and credentials",
|
"summary": "Store accounts and credentials",
|
||||||
"version": "11.0.1.0.0",
|
"version": "11.0.2.0.0",
|
||||||
"category": "Uncategorized",
|
"category": "Uncategorized",
|
||||||
"website": "https://akretion.com/",
|
"website": "https://akretion.com/",
|
||||||
"author": "Akretion, Odoo Community Association (OCA)",
|
"author": "Akretion, Odoo Community Association (OCA)",
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class KeychainAccount(models.Model):
|
||||||
# Only needed in v8 for _description_searchable issues
|
# Only needed in v8 for _description_searchable issues
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_password(self):
|
def _get_password(self):
|
||||||
"""Password in clear text."""
|
"""Password in clear text."""
|
||||||
try:
|
try:
|
||||||
return self._decode_password(self.password)
|
return self._decode_password(self.password)
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ class TestKeychain(TransactionCase):
|
||||||
account.clear_password = password
|
account.clear_password = password
|
||||||
account._inverse_set_password()
|
account._inverse_set_password()
|
||||||
self.assertTrue(account.clear_password != account.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):
|
def test_wrong_key(self):
|
||||||
"""It should raise an exception when encoded key != decoded."""
|
"""It should raise an exception when encoded key != decoded."""
|
||||||
|
|
@ -77,7 +77,7 @@ class TestKeychain(TransactionCase):
|
||||||
account._inverse_set_password()
|
account._inverse_set_password()
|
||||||
config['keychain_key'] = Fernet.generate_key()
|
config['keychain_key'] = Fernet.generate_key()
|
||||||
try:
|
try:
|
||||||
account.get_password()
|
account._get_password()
|
||||||
self.assertTrue(False, 'It should not work with another key')
|
self.assertTrue(False, 'It should not work with another key')
|
||||||
except Warning as err:
|
except Warning as err:
|
||||||
self.assertTrue(True, 'It should raise a Warning')
|
self.assertTrue(True, 'It should raise a Warning')
|
||||||
|
|
@ -133,13 +133,13 @@ class TestKeychain(TransactionCase):
|
||||||
account.clear_password = 'abc'
|
account.clear_password = 'abc'
|
||||||
account._inverse_set_password()
|
account._inverse_set_password()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
account.get_password(),
|
account._get_password(),
|
||||||
'abc', 'Should work with dev')
|
'abc', 'Should work with dev')
|
||||||
|
|
||||||
config['running_env'] = 'prod'
|
config['running_env'] = 'prod'
|
||||||
with self.assertRaises(Warning):
|
with self.assertRaises(Warning):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
account.get_password(),
|
account._get_password(),
|
||||||
'abc', 'Should not work with prod key')
|
'abc', 'Should not work with prod key')
|
||||||
|
|
||||||
def test_multienv_blank(self):
|
def test_multienv_blank(self):
|
||||||
|
|
@ -153,12 +153,12 @@ class TestKeychain(TransactionCase):
|
||||||
account.clear_password = 'abc'
|
account.clear_password = 'abc'
|
||||||
account._inverse_set_password()
|
account._inverse_set_password()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
account.get_password(),
|
account._get_password(),
|
||||||
'abc', 'Should work with dev')
|
'abc', 'Should work with dev')
|
||||||
|
|
||||||
config['running_env'] = 'prod'
|
config['running_env'] = 'prod'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
account.get_password(),
|
account._get_password(),
|
||||||
'abc', 'Should work with prod')
|
'abc', 'Should work with prod')
|
||||||
|
|
||||||
def test_multienv_force(self):
|
def test_multienv_force(self):
|
||||||
|
|
@ -177,12 +177,12 @@ class TestKeychain(TransactionCase):
|
||||||
|
|
||||||
with self.assertRaises(Warning):
|
with self.assertRaises(Warning):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
account.get_password(),
|
account._get_password(),
|
||||||
'abc', 'Should not work with dev')
|
'abc', 'Should not work with dev')
|
||||||
|
|
||||||
config['running_env'] = 'prod'
|
config['running_env'] = 'prod'
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
account.get_password(),
|
account._get_password(),
|
||||||
'abc', 'Should work with prod')
|
'abc', 'Should work with prod')
|
||||||
|
|
||||||
def test_wrong_json(self):
|
def test_wrong_json(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue