mirror of
https://gitlab.com/flectra-community/server-ux.git
synced 2024-11-22 22:22:05 +00:00
31 lines
859 B
Python
31 lines
859 B
Python
|
# Copyright 2018 Onestein
|
||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||
|
|
||
|
from flectra import http
|
||
|
from flectra.tests.common import TransactionCase
|
||
|
from flectra.addons.easy_switch_user.controllers.main import SwitchController
|
||
|
|
||
|
|
||
|
class FakeRequest(object):
|
||
|
def __init__(self, env):
|
||
|
self.db = env.cr.dbname
|
||
|
self.session = FakeSession()
|
||
|
|
||
|
|
||
|
class FakeSession(object):
|
||
|
def authenticate(self, db, login, password):
|
||
|
return False
|
||
|
|
||
|
|
||
|
class TestController(TransactionCase):
|
||
|
def setUp(self):
|
||
|
super(TestController, self).setUp()
|
||
|
self.ctrl = SwitchController()
|
||
|
|
||
|
def test_switch(self):
|
||
|
old_request = http.request
|
||
|
http.request = FakeRequest(self.env)
|
||
|
with self.assertRaises(Exception):
|
||
|
self.ctrl.switch('unknown_user', '1234567890')
|
||
|
http.request = old_request
|