2 I will now stress the authentication layer of the ORM
6 !record {model: res.users, id: res_user_test_a1}:
9 password: 'base-test-passwd'
12 I will prepare the context
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)
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:
24 context['test_xmlrpc_url'] = 'http://%s:%d/xmlrpc/' % (host, port)
26 I will commit the cursor and try to login.
28 !python {model: res.users }: |
29 from xmlrpclib import ServerProxy
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!"
38 I will just try to read something as that user
40 !python {model: res.users }: |
41 from xmlrpclib import ServerProxy
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!"
51 I will now disable the user.
53 !record {model: res.users, id: res_user_test_a1}:
56 I will commit the cursor.
58 !python {model: res.users }: |
61 I will try to read again, connecting as the disabled user.
63 !python {model: res.users }: |
64 from xmlrpclib import ServerProxy
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!")
72 if e.faultCode != 'AccessDenied':