|
@ -4,7 +4,7 @@ |
|
|
|
|
|
|
|
|
from odoo.tests.common import TransactionCase |
|
|
from odoo.tests.common import TransactionCase |
|
|
from odoo.tools.config import config |
|
|
from odoo.tools.config import config |
|
|
from odoo.exceptions import ValidationError |
|
|
|
|
|
|
|
|
from odoo.exceptions import ValidationError, UserError |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import logging |
|
|
import logging |
|
@ -80,20 +80,20 @@ class TestKeychain(TransactionCase): |
|
|
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: |
|
|
|
|
|
self.assertTrue(True, 'It should raise a Warning') |
|
|
|
|
|
|
|
|
except UserError as err: |
|
|
|
|
|
self.assertTrue(True, 'It should raise a UserError') |
|
|
self.assertTrue( |
|
|
self.assertTrue( |
|
|
'has been encrypted with a diff' in str(err), |
|
|
'has been encrypted with a diff' in str(err), |
|
|
'It should display the right msg') |
|
|
'It should display the right msg') |
|
|
else: |
|
|
else: |
|
|
self.assertTrue(False, 'It should raise a Warning') |
|
|
|
|
|
|
|
|
self.assertTrue(False, 'It should raise a UserError') |
|
|
|
|
|
|
|
|
def test_no_key(self): |
|
|
def test_no_key(self): |
|
|
"""It should raise an exception when no key is set.""" |
|
|
"""It should raise an exception when no key is set.""" |
|
|
account = self._create_account() |
|
|
account = self._create_account() |
|
|
del config.options['keychain_key'] |
|
|
del config.options['keychain_key'] |
|
|
|
|
|
|
|
|
with self.assertRaises(Warning) as err: |
|
|
|
|
|
|
|
|
with self.assertRaises(UserError) as err: |
|
|
account.clear_password = 'aiuepr' |
|
|
account.clear_password = 'aiuepr' |
|
|
account._inverse_set_password() |
|
|
account._inverse_set_password() |
|
|
self.assertTrue(False, 'It should not work without key') |
|
|
self.assertTrue(False, 'It should not work without key') |
|
@ -106,7 +106,7 @@ class TestKeychain(TransactionCase): |
|
|
account = self._create_account() |
|
|
account = self._create_account() |
|
|
|
|
|
|
|
|
config['keychain_key'] = "" |
|
|
config['keychain_key'] = "" |
|
|
with self.assertRaises(Warning): |
|
|
|
|
|
|
|
|
with self.assertRaises(UserError): |
|
|
account.clear_password = 'aiuepr' |
|
|
account.clear_password = 'aiuepr' |
|
|
account._inverse_set_password() |
|
|
account._inverse_set_password() |
|
|
self.assertTrue(False, 'It should not work missing formated key') |
|
|
self.assertTrue(False, 'It should not work missing formated key') |
|
@ -138,7 +138,7 @@ class TestKeychain(TransactionCase): |
|
|
'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(UserError): |
|
|
self.assertEqual( |
|
|
self.assertEqual( |
|
|
account._get_password(), |
|
|
account._get_password(), |
|
|
'abc', 'Should not work with prod key') |
|
|
'abc', 'Should not work with prod key') |
|
@ -176,7 +176,7 @@ class TestKeychain(TransactionCase): |
|
|
account.clear_password = 'abc' |
|
|
account.clear_password = 'abc' |
|
|
account._inverse_set_password() |
|
|
account._inverse_set_password() |
|
|
|
|
|
|
|
|
with self.assertRaises(Warning): |
|
|
|
|
|
|
|
|
with self.assertRaises(UserError): |
|
|
self.assertEqual( |
|
|
self.assertEqual( |
|
|
account._get_password(), |
|
|
account._get_password(), |
|
|
'abc', 'Should not work with dev') |
|
|
'abc', 'Should not work with dev') |
|
|