author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 30 Mar 2010 11:17:21 +0200 | |
branch | stable |
changeset 5074 | bc481dab93d4 |
parent 5038 | 90493551b1eb |
child 5174 | 78438ad513ca |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: iso-8859-1 -*- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
2 |
"""unit tests for cubicweb.web.application |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3801
diff
changeset
|
5 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
8 |
""" |
0 | 9 |
|
10 |
import base64, Cookie |
|
11 |
import sys |
|
12 |
from urllib import unquote |
|
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
13 |
|
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
14 |
from logilab.common.testlib import TestCase, unittest_main |
0 | 15 |
from logilab.common.decorators import clear_cache |
16 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
17 |
from cubicweb.devtools.testlib import CubicWebTC |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
18 |
from cubicweb.devtools.fake import FakeRequest |
0 | 19 |
from cubicweb.web import Redirect, AuthenticationError, ExplicitLogin, INTERNAL_FIELD_VALUE |
20 |
from cubicweb.web.views.basecontrollers import ViewController |
|
21 |
||
22 |
class FakeMapping: |
|
23 |
"""emulates a mapping module""" |
|
24 |
def __init__(self): |
|
25 |
self.ENTITIES_MAP = {} |
|
26 |
self.ATTRIBUTES_MAP = {} |
|
27 |
self.RELATIONS_MAP = {} |
|
28 |
||
29 |
class MockCursor: |
|
30 |
def __init__(self): |
|
31 |
self.executed = [] |
|
32 |
def execute(self, rql, args=None, cachekey=None): |
|
33 |
args = args or {} |
|
34 |
self.executed.append(rql % args) |
|
35 |
||
36 |
||
37 |
class FakeController(ViewController): |
|
38 |
||
39 |
def __init__(self, form=None): |
|
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
40 |
self._cw = FakeRequest() |
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
41 |
self._cw.form = form or {} |
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
42 |
self._cursor = self._cw.cursor = MockCursor() |
0 | 43 |
|
44 |
def new_cursor(self): |
|
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
45 |
self._cursor = self._cw.cursor = MockCursor() |
0 | 46 |
|
47 |
def set_form(self, form): |
|
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
48 |
self._cw.form = form |
0 | 49 |
|
50 |
||
51 |
class RequestBaseTC(TestCase): |
|
52 |
def setUp(self): |
|
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
53 |
self._cw = FakeRequest() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
54 |
|
0 | 55 |
|
56 |
def test_list_arg(self): |
|
57 |
"""tests the list_arg() function""" |
|
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
58 |
list_arg = self._cw.list_form_param |
0 | 59 |
self.assertEquals(list_arg('arg3', {}), []) |
60 |
d = {'arg1' : "value1", |
|
61 |
'arg2' : ('foo', INTERNAL_FIELD_VALUE,), |
|
62 |
'arg3' : ['bar']} |
|
63 |
self.assertEquals(list_arg('arg1', d, True), ['value1']) |
|
64 |
self.assertEquals(d, {'arg2' : ('foo', INTERNAL_FIELD_VALUE), 'arg3' : ['bar'],}) |
|
65 |
self.assertEquals(list_arg('arg2', d, True), ['foo']) |
|
66 |
self.assertEquals({'arg3' : ['bar'],}, d) |
|
67 |
self.assertEquals(list_arg('arg3', d), ['bar',]) |
|
68 |
self.assertEquals({'arg3' : ['bar'],}, d) |
|
69 |
||
70 |
||
71 |
def test_from_controller(self): |
|
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
72 |
self._cw.vreg['controllers'] = {'view': 1, 'login': 1} |
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
73 |
self.assertEquals(self._cw.from_controller(), 'view') |
0 | 74 |
req = FakeRequest(url='project?vid=list') |
3265
96c8363b8f64
test update, no more a FakeVReg, needs to hack it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
75 |
req.vreg['controllers'] = {'view': 1, 'login': 1} |
0 | 76 |
# this assertion is just to make sure that relative_path can be |
77 |
# correctly computed as it is used in from_controller() |
|
78 |
self.assertEquals(req.relative_path(False), 'project') |
|
79 |
self.assertEquals(req.from_controller(), 'view') |
|
80 |
# test on a valid non-view controller |
|
81 |
req = FakeRequest(url='login?x=1&y=2') |
|
3265
96c8363b8f64
test update, no more a FakeVReg, needs to hack it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
82 |
req.vreg['controllers'] = {'view': 1, 'login': 1} |
0 | 83 |
self.assertEquals(req.relative_path(False), 'login') |
84 |
self.assertEquals(req.from_controller(), 'login') |
|
85 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
86 |
|
0 | 87 |
class UtilsTC(TestCase): |
88 |
"""test suite for misc application utilities""" |
|
89 |
||
90 |
def setUp(self): |
|
91 |
self.ctrl = FakeController() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
92 |
|
0 | 93 |
#def test_which_mapping(self): |
94 |
# """tests which mapping is used (application or core)""" |
|
95 |
# init_mapping() |
|
96 |
# from cubicweb.common import mapping |
|
97 |
# self.assertEquals(mapping.MAPPING_USED, 'core') |
|
98 |
# sys.modules['mapping'] = FakeMapping() |
|
99 |
# init_mapping() |
|
100 |
# self.assertEquals(mapping.MAPPING_USED, 'application') |
|
101 |
# del sys.modules['mapping'] |
|
102 |
||
103 |
def test_execute_linkto(self): |
|
104 |
"""tests the execute_linkto() function""" |
|
105 |
self.assertEquals(self.ctrl.execute_linkto(), None) |
|
106 |
self.assertEquals(self.ctrl._cursor.executed, |
|
107 |
[]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
108 |
|
0 | 109 |
self.ctrl.set_form({'__linkto' : 'works_for:12_13_14:object', |
110 |
'eid': 8}) |
|
111 |
self.ctrl.execute_linkto() |
|
112 |
self.assertEquals(self.ctrl._cursor.executed, |
|
113 |
['SET Y works_for X WHERE X eid 8, Y eid %s' % i |
|
114 |
for i in (12, 13, 14)]) |
|
115 |
||
116 |
self.ctrl.new_cursor() |
|
117 |
self.ctrl.set_form({'__linkto' : 'works_for:12_13_14:subject', |
|
118 |
'eid': 8}) |
|
119 |
self.ctrl.execute_linkto() |
|
120 |
self.assertEquals(self.ctrl._cursor.executed, |
|
121 |
['SET X works_for Y WHERE X eid 8, Y eid %s' % i |
|
122 |
for i in (12, 13, 14)]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
123 |
|
0 | 124 |
|
125 |
self.ctrl.new_cursor() |
|
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3293
diff
changeset
|
126 |
self.ctrl._cw.form = {'__linkto' : 'works_for:12_13_14:object'} |
0 | 127 |
self.ctrl.execute_linkto(eid=8) |
128 |
self.assertEquals(self.ctrl._cursor.executed, |
|
129 |
['SET Y works_for X WHERE X eid 8, Y eid %s' % i |
|
130 |
for i in (12, 13, 14)]) |
|
131 |
||
132 |
self.ctrl.new_cursor() |
|
133 |
self.ctrl.set_form({'__linkto' : 'works_for:12_13_14:subject'}) |
|
134 |
self.ctrl.execute_linkto(eid=8) |
|
135 |
self.assertEquals(self.ctrl._cursor.executed, |
|
136 |
['SET X works_for Y WHERE X eid 8, Y eid %s' % i |
|
137 |
for i in (12, 13, 14)]) |
|
138 |
||
139 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
140 |
class ApplicationTC(CubicWebTC): |
3523
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
141 |
def setUp(self): |
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
142 |
super(ApplicationTC, self).setUp() |
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
143 |
def raise_hdlr(*args, **kwargs): |
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
144 |
raise |
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
145 |
self.app.error_handler = raise_hdlr |
0 | 146 |
|
147 |
def test_cnx_user_groups_sync(self): |
|
148 |
user = self.user() |
|
149 |
self.assertEquals(user.groups, set(('managers',))) |
|
150 |
self.execute('SET X in_group G WHERE X eid %s, G name "guests"' % user.eid) |
|
151 |
user = self.user() |
|
152 |
self.assertEquals(user.groups, set(('managers',))) |
|
153 |
self.commit() |
|
154 |
user = self.user() |
|
155 |
self.assertEquals(user.groups, set(('managers', 'guests'))) |
|
156 |
# cleanup |
|
157 |
self.execute('DELETE X in_group G WHERE X eid %s, G name "guests"' % user.eid) |
|
158 |
self.commit() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
159 |
|
0 | 160 |
def test_nonregr_publish1(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
161 |
req = self.request(u'CWEType X WHERE X final FALSE, X meta FALSE') |
0 | 162 |
self.app.publish('view', req) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
163 |
|
0 | 164 |
def test_nonregr_publish2(self): |
165 |
req = self.request(u'Any count(N) WHERE N todo_by U, N is Note, U eid %s' |
|
166 |
% self.user().eid) |
|
167 |
self.app.publish('view', req) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
168 |
|
0 | 169 |
def test_publish_validation_error(self): |
170 |
req = self.request() |
|
171 |
user = self.user() |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
172 |
eid = unicode(user.eid) |
0 | 173 |
req.form = { |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
174 |
'eid': eid, |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
175 |
'__type:'+eid: 'CWUser', '_cw_edited_fields:'+eid: 'login-subject', |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
176 |
'login-subject:'+eid: '', # ERROR: no login specified |
0 | 177 |
# just a sample, missing some necessary information for real life |
178 |
'__errorurl': 'view?vid=edition...' |
|
179 |
} |
|
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
180 |
path, params = self.expect_redirect(lambda x: self.app_publish(x, 'edit'), req) |
0 | 181 |
forminfo = req.get_session_data('view?vid=edition...') |
182 |
eidmap = forminfo['eidmap'] |
|
183 |
self.assertEquals(eidmap, {}) |
|
184 |
values = forminfo['values'] |
|
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
185 |
self.assertEquals(values['login-subject:'+eid], '') |
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
186 |
self.assertEquals(values['eid'], eid) |
4276 | 187 |
error = forminfo['error'] |
188 |
self.assertEquals(error.entity, user.eid) |
|
5038
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
189 |
self.assertEquals(error.errors['login-subject'], 'required field') |
0 | 190 |
|
191 |
||
5038
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
192 |
def test_validation_error_dont_loose_subentity_data_ctrl(self): |
0 | 193 |
"""test creation of two linked entities |
5038
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
194 |
|
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
195 |
error occurs on the web controller |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
196 |
""" |
0 | 197 |
req = self.request() |
5038
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
198 |
# set Y before X to ensure both entities are edited, not only X |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
199 |
req.form = {'eid': ['Y', 'X'], '__maineid': 'X', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
200 |
'__type:X': 'CWUser', '_cw_edited_fields:X': 'login-subject', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
201 |
# missing required field |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
202 |
'login-subject:X': u'', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
203 |
# but email address is set |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
204 |
'__type:Y': 'EmailAddress', '_cw_edited_fields:Y': 'address-subject', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
205 |
'address-subject:Y': u'bougloup@logilab.fr', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
206 |
'use_email-object:Y': 'X', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
207 |
# necessary to get validation error handling |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
208 |
'__errorurl': 'view?vid=edition...', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
209 |
} |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
210 |
path, params = self.expect_redirect(lambda x: self.app_publish(x, 'edit'), req) |
0 | 211 |
forminfo = req.get_session_data('view?vid=edition...') |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
212 |
self.assertEquals(set(forminfo['eidmap']), set('XY')) |
5038
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
213 |
self.assertEquals(forminfo['eidmap']['X'], None) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
214 |
self.assertIsInstance(forminfo['eidmap']['Y'], int) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
215 |
self.assertEquals(forminfo['error'].entity, 'X') |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
216 |
self.assertEquals(forminfo['error'].errors, |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
217 |
{'login-subject': 'required field'}) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
218 |
self.assertEquals(forminfo['values'], req.form) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
219 |
|
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
220 |
|
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
221 |
def test_validation_error_dont_loose_subentity_data_repo(self): |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
222 |
"""test creation of two linked entities |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
223 |
|
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
224 |
error occurs on the repository |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
225 |
""" |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
226 |
req = self.request() |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
227 |
# set Y before X to ensure both entities are edited, not only X |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
228 |
req.form = {'eid': ['Y', 'X'], '__maineid': 'X', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
229 |
'__type:X': 'CWUser', '_cw_edited_fields:X': 'login-subject,upassword-subject', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
230 |
# already existent user |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
231 |
'login-subject:X': u'admin', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
232 |
'upassword-subject:X': u'admin', 'upassword-subject-confirm:X': u'admin', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
233 |
'__type:Y': 'EmailAddress', '_cw_edited_fields:Y': 'address-subject', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
234 |
'address-subject:Y': u'bougloup@logilab.fr', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
235 |
'use_email-object:Y': 'X', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
236 |
# necessary to get validation error handling |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
237 |
'__errorurl': 'view?vid=edition...', |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
238 |
} |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
239 |
path, params = self.expect_redirect(lambda x: self.app_publish(x, 'edit'), req) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
240 |
forminfo = req.get_session_data('view?vid=edition...') |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
241 |
self.assertEquals(set(forminfo['eidmap']), set('XY')) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
242 |
self.assertIsInstance(forminfo['eidmap']['X'], int) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
243 |
self.assertIsInstance(forminfo['eidmap']['Y'], int) |
4276 | 244 |
self.assertEquals(forminfo['error'].entity, forminfo['eidmap']['X']) |
5030
5238d9a8dfee
[form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4276
diff
changeset
|
245 |
self.assertEquals(forminfo['error'].errors, |
5038
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
246 |
{'login-subject': u'the value "admin" is already used, use another one'}) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
247 |
self.assertEquals(forminfo['values'], req.form) |
90493551b1eb
[form] fix validation error handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5030
diff
changeset
|
248 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
249 |
|
0 | 250 |
def _test_cleaned(self, kwargs, injected, cleaned): |
251 |
req = self.request(**kwargs) |
|
252 |
page = self.app.publish('view', req) |
|
253 |
self.failIf(injected in page, (kwargs, injected)) |
|
254 |
self.failUnless(cleaned in page, (kwargs, cleaned)) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
255 |
|
0 | 256 |
def test_nonregr_script_kiddies(self): |
257 |
"""test against current script injection""" |
|
258 |
injected = '<i>toto</i>' |
|
259 |
cleaned = 'toto' |
|
260 |
for kwargs in ({'__message': injected}, |
|
261 |
{'vid': injected}, |
|
262 |
{'vtitle': injected}, |
|
263 |
): |
|
264 |
yield self._test_cleaned, kwargs, injected, cleaned |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
265 |
|
0 | 266 |
def test_site_wide_eproperties_sync(self): |
267 |
# XXX work in all-in-one configuration but not in twisted for instance |
|
268 |
# in which case we need a kindof repo -> http server notification |
|
269 |
# protocol |
|
270 |
vreg = self.app.vreg |
|
271 |
# default value |
|
272 |
self.assertEquals(vreg.property_value('ui.language'), 'en') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
273 |
self.execute('INSERT CWProperty X: X value "fr", X pkey "ui.language"') |
0 | 274 |
self.assertEquals(vreg.property_value('ui.language'), 'en') |
275 |
self.commit() |
|
276 |
self.assertEquals(vreg.property_value('ui.language'), 'fr') |
|
277 |
self.execute('SET X value "de" WHERE X pkey "ui.language"') |
|
278 |
self.assertEquals(vreg.property_value('ui.language'), 'fr') |
|
279 |
self.commit() |
|
280 |
self.assertEquals(vreg.property_value('ui.language'), 'de') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
281 |
self.execute('DELETE CWProperty X WHERE X pkey "ui.language"') |
0 | 282 |
self.assertEquals(vreg.property_value('ui.language'), 'de') |
283 |
self.commit() |
|
284 |
self.assertEquals(vreg.property_value('ui.language'), 'en') |
|
285 |
||
286 |
def test_fb_login_concept(self): |
|
287 |
"""see data/views.py""" |
|
288 |
self.set_option('auth-mode', 'cookie') |
|
289 |
self.set_option('anonymous-user', 'anon') |
|
290 |
self.login('anon') |
|
291 |
req = self.request() |
|
292 |
origcnx = req.cnx |
|
293 |
req.form['__fblogin'] = u'turlututu' |
|
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
294 |
page = self.app_publish(req) |
0 | 295 |
self.failIf(req.cnx is origcnx) |
296 |
self.assertEquals(req.user.login, 'turlututu') |
|
297 |
self.failUnless('turlututu' in page, page) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
298 |
|
0 | 299 |
# authentication tests #################################################### |
300 |
||
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
301 |
def test_http_auth_no_anon(self): |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
302 |
req, origcnx = self.init_authentication('http') |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
303 |
self.assertAuthFailure(req) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
304 |
self.assertRaises(ExplicitLogin, self.app_publish, req, 'login') |
0 | 305 |
self.assertEquals(req.cnx, None) |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
306 |
authstr = base64.encodestring('%s:%s' % (origcnx.login, origcnx.authinfo['password'])) |
0 | 307 |
req._headers['Authorization'] = 'basic %s' % authstr |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
308 |
self.assertAuthSuccess(req, origcnx) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
309 |
self.assertEquals(req.cnx.authinfo, {'password': origcnx.authinfo['password']}) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
310 |
self.assertRaises(AuthenticationError, self.app_publish, req, 'logout') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
311 |
self.assertEquals(len(self.open_sessions), 0) |
0 | 312 |
|
313 |
def test_cookie_auth_no_anon(self): |
|
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
314 |
req, origcnx = self.init_authentication('cookie') |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
315 |
self.assertAuthFailure(req) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
316 |
form = self.app_publish(req, 'login') |
0 | 317 |
self.failUnless('__login' in form) |
318 |
self.failUnless('__password' in form) |
|
319 |
self.assertEquals(req.cnx, None) |
|
320 |
req.form['__login'] = origcnx.login |
|
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
321 |
req.form['__password'] = origcnx.authinfo['password'] |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
322 |
self.assertAuthSuccess(req, origcnx) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
323 |
self.assertEquals(req.cnx.authinfo, {'password': origcnx.authinfo['password']}) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
324 |
self.assertRaises(AuthenticationError, self.app_publish, req, 'logout') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
325 |
self.assertEquals(len(self.open_sessions), 0) |
0 | 326 |
|
1490
6b024694d493
add allow-email-login option
Florent <florent@secondweb.fr>
parents:
1489
diff
changeset
|
327 |
def test_login_by_email(self): |
1489
08acef58ad08
add a test regarding login with a primary email
Florent <florent@secondweb.fr>
parents:
1398
diff
changeset
|
328 |
login = self.request().user.login |
08acef58ad08
add a test regarding login with a primary email
Florent <florent@secondweb.fr>
parents:
1398
diff
changeset
|
329 |
address = login + u'@localhost' |
08acef58ad08
add a test regarding login with a primary email
Florent <florent@secondweb.fr>
parents:
1398
diff
changeset
|
330 |
self.execute('INSERT EmailAddress X: X address %(address)s, U primary_email X ' |
08acef58ad08
add a test regarding login with a primary email
Florent <florent@secondweb.fr>
parents:
1398
diff
changeset
|
331 |
'WHERE U login %(login)s', {'address': address, 'login': login}) |
08acef58ad08
add a test regarding login with a primary email
Florent <florent@secondweb.fr>
parents:
1398
diff
changeset
|
332 |
self.commit() |
1490
6b024694d493
add allow-email-login option
Florent <florent@secondweb.fr>
parents:
1489
diff
changeset
|
333 |
# option allow-email-login not set |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
334 |
req, origcnx = self.init_authentication('cookie') |
1490
6b024694d493
add allow-email-login option
Florent <florent@secondweb.fr>
parents:
1489
diff
changeset
|
335 |
req.form['__login'] = address |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
336 |
req.form['__password'] = origcnx.authinfo['password'] |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
337 |
self.assertAuthFailure(req) |
1490
6b024694d493
add allow-email-login option
Florent <florent@secondweb.fr>
parents:
1489
diff
changeset
|
338 |
# option allow-email-login set |
2267
e1d2df3f1091
move login by email functionnality on the repository side to avoid buggy call to internal_session from the web interface side
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
339 |
origcnx.login = address |
1490
6b024694d493
add allow-email-login option
Florent <florent@secondweb.fr>
parents:
1489
diff
changeset
|
340 |
self.set_option('allow-email-login', True) |
1489
08acef58ad08
add a test regarding login with a primary email
Florent <florent@secondweb.fr>
parents:
1398
diff
changeset
|
341 |
req.form['__login'] = address |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
342 |
req.form['__password'] = origcnx.authinfo['password'] |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
343 |
self.assertAuthSuccess(req, origcnx) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
344 |
self.assertEquals(req.cnx.authinfo, {'password': origcnx.authinfo['password']}) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
345 |
self.assertRaises(AuthenticationError, self.app_publish, req, 'logout') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
346 |
self.assertEquals(len(self.open_sessions), 0) |
1489
08acef58ad08
add a test regarding login with a primary email
Florent <florent@secondweb.fr>
parents:
1398
diff
changeset
|
347 |
|
0 | 348 |
def _reset_cookie(self, req): |
349 |
# preparing the suite of the test |
|
350 |
# set session id in cookie |
|
351 |
cookie = Cookie.SimpleCookie() |
|
352 |
cookie['__session'] = req.cnx.sessionid |
|
353 |
req._headers['Cookie'] = cookie['__session'].OutputString() |
|
354 |
clear_cache(req, 'get_authorization') |
|
355 |
# reset cnx as if it was a new incoming request |
|
356 |
req.cnx = None |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
357 |
|
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
358 |
def _test_auth_anon(self, req): |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
359 |
self.app.connect(req) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
360 |
acnx = req.cnx |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
361 |
self.assertEquals(len(self.open_sessions), 1) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
362 |
self.assertEquals(acnx.login, 'anon') |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
363 |
self.assertEquals(acnx.authinfo['password'], 'anon') |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
364 |
self.failUnless(acnx.anonymous_connection) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
365 |
self._reset_cookie(req) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
366 |
|
0 | 367 |
def _test_anon_auth_fail(self, req): |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
368 |
self.assertEquals(len(self.open_sessions), 1) |
0 | 369 |
self.app.connect(req) |
370 |
self.assertEquals(req.message, 'authentication failure') |
|
371 |
self.assertEquals(req.cnx.anonymous_connection, True) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
372 |
self.assertEquals(len(self.open_sessions), 1) |
0 | 373 |
self._reset_cookie(req) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
374 |
|
0 | 375 |
def test_http_auth_anon_allowed(self): |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
376 |
req, origcnx = self.init_authentication('http', 'anon') |
0 | 377 |
self._test_auth_anon(req) |
378 |
authstr = base64.encodestring('toto:pouet') |
|
379 |
req._headers['Authorization'] = 'basic %s' % authstr |
|
380 |
self._test_anon_auth_fail(req) |
|
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
381 |
authstr = base64.encodestring('%s:%s' % (origcnx.login, origcnx.authinfo['password'])) |
0 | 382 |
req._headers['Authorization'] = 'basic %s' % authstr |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
383 |
self.assertAuthSuccess(req, origcnx) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
384 |
self.assertEquals(req.cnx.authinfo, {'password': origcnx.authinfo['password']}) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
385 |
self.assertRaises(AuthenticationError, self.app_publish, req, 'logout') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
386 |
self.assertEquals(len(self.open_sessions), 0) |
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
387 |
|
0 | 388 |
def test_cookie_auth_anon_allowed(self): |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
389 |
req, origcnx = self.init_authentication('cookie', 'anon') |
0 | 390 |
self._test_auth_anon(req) |
391 |
req.form['__login'] = 'toto' |
|
392 |
req.form['__password'] = 'pouet' |
|
393 |
self._test_anon_auth_fail(req) |
|
394 |
req.form['__login'] = origcnx.login |
|
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
395 |
req.form['__password'] = origcnx.authinfo['password'] |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
396 |
self.assertAuthSuccess(req, origcnx) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
397 |
self.assertEquals(req.cnx.authinfo, {'password': origcnx.authinfo['password']}) |
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
398 |
self.assertRaises(AuthenticationError, self.app_publish, req, 'logout') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
399 |
self.assertEquals(len(self.open_sessions), 0) |
0 | 400 |
|
3523
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
401 |
def test_non_regr_optional_first_var(self): |
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
402 |
req = self.request() |
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
403 |
# expect a rset with None in [0][0] |
16880e7ee3fa
don't accept None to avoid error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3265
diff
changeset
|
404 |
req.form['rql'] = 'rql:Any OV1, X WHERE X custom_workflow OV1?' |
3657
706d7bf0ae3d
factor out code reusable for authentication tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3524
diff
changeset
|
405 |
self.app_publish(req) |
0 | 406 |
|
407 |
if __name__ == '__main__': |
|
408 |
unittest_main() |