Skip to content

Commit

Permalink
[IMP] keychain: get_password must not be accessible from outside
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Feb 6, 2018
1 parent e359616 commit f3df07a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion keychain/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Keychain",
"summary": "Store accounts and credentials",
"version": "11.0.1.0.0",
"version": "11.0.2.0.0",
"category": "Uncategorized",
"website": "https://akretion.com/",
"author": "Akretion, Odoo Community Association (OCA)",
Expand Down
2 changes: 1 addition & 1 deletion keychain/models/keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _compute_password(self):
# 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)
Expand Down
16 changes: 8 additions & 8 deletions keychain/tests/test_keychain.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_password(self):
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."""
Expand All @@ -77,7 +77,7 @@ def test_wrong_key(self):
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')
Expand Down Expand Up @@ -133,13 +133,13 @@ def test_multienv(self):
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):
Expand All @@ -153,12 +153,12 @@ def test_multienv_blank(self):
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):
Expand All @@ -177,12 +177,12 @@ def test_multienv_force(self):

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):
Expand Down

0 comments on commit f3df07a

Please sign in to comment.