def test_wrongpw(self): # User.authenticate raises but RPC.authenticate returns False uid = auth.dispatch('authenticate', [self.env.cr.dbname, 'byl', 'aws', {}]) self.assertFalse(uid) with self.assertRaises(AccessDenied): model.dispatch('execute_kw', [ self.env.cr.dbname, self._user.id, 'aws', 'res.users', 'context_get', [] ])
def test_disabled(self): env = self.env(user=self._user) k = env['res.users.apikeys.description'].create({'name': 'b',}).make_key()['context']['default_key'] self._user.active = False with self.assertRaises(AccessDenied): model.dispatch('execute_kw', [ self.env.cr.dbname, self._user.id, 'ananananan', 'res.users', 'context_get', [] ]) with self.assertRaises(AccessDenied): model.dispatch('execute_kw', [ self.env.cr.dbname, self._user.id, k, 'res.users', 'context_get', [] ])
def test_trivial(self): uid = auth.dispatch('authenticate', [self.env.cr.dbname, 'byl', 'ananananan', {}]) self.assertEqual(uid, self._user.id) ctx = model.dispatch('execute_kw', [ self.env.cr.dbname, uid, 'ananananan', 'res.users', 'context_get', [] ]) self.assertEqual(ctx['tz'], 'Australia/Eucla')
def test_key(self): env = self.env(user=self._user) r = env['res.users.apikeys.description'].create({ 'name': 'a', }).make_key() k = r['context']['default_key'] uid = auth.dispatch('authenticate', [self.env.cr.dbname, 'byl', 'ananananan', {}]) self.assertEqual(uid, self._user.id) uid = auth.dispatch('authenticate', [self.env.cr.dbname, 'byl', k, {}]) self.assertEqual(uid, self._user.id) ctx = model.dispatch( 'execute_kw', [self.env.cr.dbname, uid, k, 'res.users', 'context_get', []]) self.assertEqual(ctx['tz'], 'Australia/Eucla')