/usr/lib/python2.7/dist-packages/trytond/tests/test_user.py is in tryton-server 3.4.0-3+deb8u3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # This file is part of Tryton. The COPYRIGHT file at the top level of this
# repository contains the full copyright notices and license terms.
import unittest
from trytond.transaction import Transaction
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, \
install_module
from trytond.res.user import bcrypt
class UserTestCase(unittest.TestCase):
'Test User'
def setUp(self):
install_module('res')
self.user = POOL.get('res.user')
def create_user(self, login, password, hash_method=None):
user, = self.user.create([{
'name': login,
'login': login,
}])
if hash_method:
hash = getattr(self.user, 'hash_' + hash_method)
self.user.write([user], {
'password_hash': hash(password),
})
else:
self.user.write([user], {
'password': password,
})
return user
def check_user(self, login, password):
user, = self.user.search([('login', '=', login)])
user_id = self.user.get_login(login, password)
self.assertEqual(user_id, user.id)
bad_user_id = self.user.get_login(login, password + 'wrong')
self.assertEqual(bad_user_id, 0)
def test0010test_hash(self):
'Test default hash password'
with Transaction().start(DB_NAME, USER, CONTEXT):
self.create_user('user', '12345')
self.check_user('user', '12345')
def test0011test_sha1(self):
'Test sha1 password'
with Transaction().start(DB_NAME, USER, CONTEXT):
self.create_user('user', '12345', 'sha1')
self.check_user('user', '12345')
@unittest.skipIf(bcrypt is None, 'requires bcrypt')
def test0012test_bcrypt(self):
'Test bcrypt password'
with Transaction().start(DB_NAME, USER, CONTEXT):
self.create_user('user', '12345', 'bcrypt')
self.check_user('user', '12345')
@with_transaction()
def test_read_password_hash(self):
"Test password_hash can not be read"
user = self.create_user('user', '12345')
self.assertIsNone(user.password_hash)
def suite():
return unittest.TestLoader().loadTestsFromTestCase(UserTestCase)
|