[MERGE] base: raise an exception if the format of the bank account is wrong
[odoo/odoo.git] / openerp / addons / base / test / test_auth.yml
1 -
2   I will now stress the authentication layer of the ORM
3 -
4   I create a test user.
5 -
6   !record {model: res.users, id: res_user_test_a1}:
7       name: Test Auth User 1
8       login: test_base_a1
9       password: 'base-test-passwd'
10       active: True
11 -
12   I will prepare the context
13 -
14   !python {model: res.users }: |
15     from tools import config
16     host = config.get_misc('httpd', 'interface')
17     port = config.get_misc('httpd', 'port', 8069)
18     if not host:
19         host = config.get('xmlrpc_interface')
20         port = config.get('xmlrpc_port') or self.port
21     if host == '0.0.0.0' or not host:
22         host = '127.0.0.1'
23     port = int(port)
24     context['test_xmlrpc_url'] = 'http://%s:%d/xmlrpc/' % (host, port)
25 -
26   I will commit the cursor and try to login.
27 -
28   !python {model: res.users }: |
29     from xmlrpclib import ServerProxy
30     cr.commit()
31     try:
32         logsock = ServerProxy(context['test_xmlrpc_url']+'common')
33         luid = logsock.login(cr.dbname, 'test_base_a1', 'base-test-passwd')
34         assert luid, "User is not activated after res.users commit!"
35     except Exception:
36         raise
37 -
38   I will just try to read something as that user
39 -
40   !python {model: res.users }: |
41     from xmlrpclib import ServerProxy
42     cr.commit()
43     try:
44         logsock = ServerProxy(context['test_xmlrpc_url']+'object')
45         luid = ref('res_user_test_a1')
46         res = logsock.execute(cr.dbname, luid, 'base-test-passwd', 'res.users', 'read', luid, ['name',])
47         assert res and res['name'], "User cannot read its name!"
48     except Exception:
49         raise
50 -
51   I will now disable the user.
52 -
53   !record {model: res.users, id: res_user_test_a1}:
54       active: False
55 -
56   I will commit the cursor.
57 -
58   !python {model: res.users }: |
59     cr.commit()
60 -
61   I will try to read again, connecting as the disabled user.
62 -
63   !python {model: res.users }: |
64     from xmlrpclib import ServerProxy
65     cr.commit()
66     try:
67         logsock = ServerProxy(context['test_xmlrpc_url']+'object')
68         luid = ref('res_user_test_a1')
69         res = logsock.execute(cr.dbname, luid, 'base-test-passwd', 'res.users', 'read', luid, ['name',])
70         raise AssertionError("User should not be enabled!")
71     except Fault, e:
72         if e.faultCode != 'AccessDenied':
73             raise