author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 09 Jul 2012 12:22:43 +0200 | |
changeset 8457 | 69ad9a509bc3 |
parent 8454 | 113184eb4e06 |
child 8463 | a964c40adbe3 |
permissions | -rw-r--r-- |
8452
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
1 |
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5419
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5886 | 18 |
"""functional tests for server'security""" |
19 |
||
0 | 20 |
import sys |
21 |
||
22 |
from logilab.common.testlib import unittest_main, TestCase |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
23 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 24 |
|
6410
2e7a7b0829ed
[test] fix tests broken by transaction behaviour on Unauthorized/ValidationError (no rollback but connection marked as non-commitable)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
25 |
from cubicweb import Unauthorized, ValidationError, QueryError |
8452
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
26 |
from cubicweb.schema import ERQLExpression |
0 | 27 |
from cubicweb.server.querier import check_read_access |
28 |
||
8452
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
29 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
30 |
class BaseSecurityTC(CubicWebTC): |
0 | 31 |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
32 |
def setup_database(self): |
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
33 |
super(BaseSecurityTC, self).setup_database() |
7244
a918f76441ce
fix tests broken by fcb8932082a5 (continued)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
34 |
req = self.request() |
a918f76441ce
fix tests broken by fcb8932082a5 (continued)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
35 |
self.create_user(req, 'iaminusersgrouponly') |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7072
diff
changeset
|
36 |
readoriggroups = self.schema['Personne'].permissions['read'] |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7072
diff
changeset
|
37 |
addoriggroups = self.schema['Personne'].permissions['add'] |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7072
diff
changeset
|
38 |
def fix_perm(): |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7072
diff
changeset
|
39 |
self.schema['Personne'].set_action_permissions('read', readoriggroups) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7072
diff
changeset
|
40 |
self.schema['Personne'].set_action_permissions('add', addoriggroups) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7072
diff
changeset
|
41 |
self.addCleanup(fix_perm) |
0 | 42 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
43 |
|
0 | 44 |
class LowLevelSecurityFunctionTC(BaseSecurityTC): |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
45 |
|
0 | 46 |
def test_check_read_access(self): |
47 |
rql = u'Personne U where U nom "managers"' |
|
3252
c0e10da6f1cf
tests update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
48 |
rqlst = self.repo.vreg.rqlhelper.parse(rql).children[0] |
0 | 49 |
origgroups = self.schema['Personne'].get_groups('read') |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
50 |
self.schema['Personne'].set_action_permissions('read', ('users', 'managers')) |
4711
7ef3b029e10b
[test] we should properly use vreg method to compute solutions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4691
diff
changeset
|
51 |
self.repo.vreg.solutions(self.session, rqlst, None) |
0 | 52 |
solution = rqlst.solutions[0] |
5419
0b7805928a27
[repo security] deal with rewriten constant nodes in check_read_access, necessary when repo is used as an external source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
53 |
check_read_access(self.session, rqlst, solution, {}) |
0 | 54 |
cnx = self.login('anon') |
55 |
cu = cnx.cursor() |
|
56 |
self.assertRaises(Unauthorized, |
|
57 |
check_read_access, |
|
5419
0b7805928a27
[repo security] deal with rewriten constant nodes in check_read_access, necessary when repo is used as an external source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
58 |
self.session, rqlst, solution, {}) |
0 | 59 |
self.assertRaises(Unauthorized, cu.execute, rql) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
60 |
|
0 | 61 |
def test_upassword_not_selectable(self): |
62 |
self.assertRaises(Unauthorized, |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
63 |
self.execute, 'Any X,P WHERE X is CWUser, X upassword P') |
0 | 64 |
self.rollback() |
65 |
cnx = self.login('iaminusersgrouponly') |
|
66 |
cu = cnx.cursor() |
|
67 |
self.assertRaises(Unauthorized, |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
68 |
cu.execute, 'Any X,P WHERE X is CWUser, X upassword P') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
69 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
70 |
|
5888
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
71 |
class SecurityRewritingTC(BaseSecurityTC): |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
72 |
def hijack_source_execute(self): |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
73 |
def syntax_tree_search(*args, **kwargs): |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
74 |
self.query = (args, kwargs) |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
75 |
return [] |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
76 |
self.repo.system_source.syntax_tree_search = syntax_tree_search |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
77 |
|
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
78 |
def tearDown(self): |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
79 |
self.repo.system_source.__dict__.pop('syntax_tree_search', None) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
80 |
super(SecurityRewritingTC, self).tearDown() |
5888
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
81 |
|
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
82 |
def test_not_relation_read_security(self): |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
83 |
cnx = self.login('iaminusersgrouponly') |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
84 |
self.hijack_source_execute() |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
85 |
self.execute('Any U WHERE NOT A todo_by U, A is Affaire') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
86 |
self.assertEqual(self.query[0][1].as_string(), |
5888
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
87 |
'Any U WHERE NOT EXISTS(A todo_by U), A is Affaire') |
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
88 |
self.execute('Any U WHERE NOT EXISTS(A todo_by U), A is Affaire') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
89 |
self.assertEqual(self.query[0][1].as_string(), |
5888
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
90 |
'Any U WHERE NOT EXISTS(A todo_by U), A is Affaire') |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
91 |
cnx.close() |
5888
3ee80d487f11
[security] fix read rql expression insertion: we should not insert rql expr on variables only referenced in neged relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5886
diff
changeset
|
92 |
|
0 | 93 |
class SecurityTC(BaseSecurityTC): |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
94 |
|
0 | 95 |
def setUp(self): |
96 |
BaseSecurityTC.setUp(self) |
|
97 |
# implicitly test manager can add some entities |
|
98 |
self.execute("INSERT Affaire X: X sujet 'cool'") |
|
99 |
self.execute("INSERT Societe X: X nom 'logilab'") |
|
100 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
101 |
self.execute('INSERT CWGroup X: X name "staff"') |
0 | 102 |
self.commit() |
103 |
||
104 |
def test_insert_security(self): |
|
105 |
cnx = self.login('anon') |
|
106 |
cu = cnx.cursor() |
|
107 |
cu.execute("INSERT Personne X: X nom 'bidule'") |
|
108 |
self.assertRaises(Unauthorized, cnx.commit) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
109 |
self.assertEqual(cu.execute('Personne X').rowcount, 1) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
110 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
111 |
|
0 | 112 |
def test_insert_rql_permission(self): |
113 |
# test user can only add une affaire related to a societe he owns |
|
114 |
cnx = self.login('iaminusersgrouponly') |
|
115 |
cu = cnx.cursor() |
|
116 |
cu.execute("INSERT Affaire X: X sujet 'cool'") |
|
117 |
self.assertRaises(Unauthorized, cnx.commit) |
|
118 |
# test nothing has actually been inserted |
|
119 |
self.restore_connection() |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
120 |
self.assertEqual(self.execute('Affaire X').rowcount, 1) |
0 | 121 |
cnx = self.login('iaminusersgrouponly') |
122 |
cu = cnx.cursor() |
|
123 |
cu.execute("INSERT Affaire X: X sujet 'cool'") |
|
124 |
cu.execute("INSERT Societe X: X nom 'chouette'") |
|
125 |
cu.execute("SET A concerne S WHERE A sujet 'cool', S nom 'chouette'") |
|
126 |
cnx.commit() |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
127 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
128 |
|
0 | 129 |
def test_update_security_1(self): |
130 |
cnx = self.login('anon') |
|
131 |
cu = cnx.cursor() |
|
132 |
# local security check |
|
133 |
cu.execute( "SET X nom 'bidulechouette' WHERE X is Personne") |
|
134 |
self.assertRaises(Unauthorized, cnx.commit) |
|
135 |
self.restore_connection() |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
136 |
self.assertEqual(self.execute('Personne X WHERE X nom "bidulechouette"').rowcount, 0) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
137 |
|
0 | 138 |
def test_update_security_2(self): |
139 |
cnx = self.login('anon') |
|
140 |
cu = cnx.cursor() |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
141 |
self.repo.schema['Personne'].set_action_permissions('read', ('users', 'managers')) |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
142 |
self.repo.schema['Personne'].set_action_permissions('add', ('guests', 'users', 'managers')) |
0 | 143 |
self.assertRaises(Unauthorized, cu.execute, "SET X nom 'bidulechouette' WHERE X is Personne") |
144 |
#self.assertRaises(Unauthorized, cnx.commit) |
|
145 |
# test nothing has actually been inserted |
|
146 |
self.restore_connection() |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
147 |
self.assertEqual(self.execute('Personne X WHERE X nom "bidulechouette"').rowcount, 0) |
0 | 148 |
|
149 |
def test_update_security_3(self): |
|
150 |
cnx = self.login('iaminusersgrouponly') |
|
151 |
cu = cnx.cursor() |
|
152 |
cu.execute("INSERT Personne X: X nom 'biduuule'") |
|
153 |
cu.execute("INSERT Societe X: X nom 'looogilab'") |
|
154 |
cu.execute("SET X travaille S WHERE X nom 'biduuule', S nom 'looogilab'") |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
155 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
156 |
|
0 | 157 |
def test_update_rql_permission(self): |
158 |
self.execute("SET A concerne S WHERE A is Affaire, S is Societe") |
|
159 |
self.commit() |
|
160 |
# test user can only update une affaire related to a societe he owns |
|
161 |
cnx = self.login('iaminusersgrouponly') |
|
162 |
cu = cnx.cursor() |
|
163 |
cu.execute("SET X sujet 'pascool' WHERE X is Affaire") |
|
164 |
# this won't actually do anything since the selection query won't return anything |
|
165 |
cnx.commit() |
|
166 |
# to actually get Unauthorized exception, try to update an entity we can read |
|
167 |
cu.execute("SET X nom 'toto' WHERE X is Societe") |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
168 |
self.assertRaises(Unauthorized, cnx.commit) |
0 | 169 |
cu.execute("INSERT Affaire X: X sujet 'pascool'") |
170 |
cu.execute("INSERT Societe X: X nom 'chouette'") |
|
171 |
cu.execute("SET A concerne S WHERE A sujet 'pascool', S nom 'chouette'") |
|
172 |
cu.execute("SET X sujet 'habahsicestcool' WHERE X sujet 'pascool'") |
|
173 |
cnx.commit() |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
174 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
175 |
|
0 | 176 |
def test_delete_security(self): |
177 |
# FIXME: sample below fails because we don't detect "owner" can't delete |
|
178 |
# user anyway, and since no user with login == 'bidule' exists, no |
|
179 |
# exception is raised |
|
180 |
#user._groups = {'guests':1} |
|
181 |
#self.assertRaises(Unauthorized, |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
182 |
# self.o.execute, user, "DELETE CWUser X WHERE X login 'bidule'") |
0 | 183 |
# check local security |
184 |
cnx = self.login('iaminusersgrouponly') |
|
185 |
cu = cnx.cursor() |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
186 |
self.assertRaises(Unauthorized, cu.execute, "DELETE CWGroup Y WHERE Y name 'staff'") |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
187 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
188 |
|
0 | 189 |
def test_delete_rql_permission(self): |
190 |
self.execute("SET A concerne S WHERE A is Affaire, S is Societe") |
|
191 |
self.commit() |
|
192 |
# test user can only dele une affaire related to a societe he owns |
|
193 |
cnx = self.login('iaminusersgrouponly') |
|
194 |
cu = cnx.cursor() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
195 |
# this won't actually do anything since the selection query won't return anything |
0 | 196 |
cu.execute("DELETE Affaire X") |
197 |
cnx.commit() |
|
198 |
# to actually get Unauthorized exception, try to delete an entity we can read |
|
199 |
self.assertRaises(Unauthorized, cu.execute, "DELETE Societe S") |
|
6410
2e7a7b0829ed
[test] fix tests broken by transaction behaviour on Unauthorized/ValidationError (no rollback but connection marked as non-commitable)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
200 |
self.assertRaises(QueryError, cnx.commit) # can't commit anymore |
2e7a7b0829ed
[test] fix tests broken by transaction behaviour on Unauthorized/ValidationError (no rollback but connection marked as non-commitable)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
201 |
cnx.rollback() # required after Unauthorized |
0 | 202 |
cu.execute("INSERT Affaire X: X sujet 'pascool'") |
203 |
cu.execute("INSERT Societe X: X nom 'chouette'") |
|
204 |
cu.execute("SET A concerne S WHERE A sujet 'pascool', S nom 'chouette'") |
|
205 |
cnx.commit() |
|
206 |
## # this one should fail since it will try to delete two affaires, one authorized |
|
207 |
## # and the other not |
|
208 |
## self.assertRaises(Unauthorized, cu.execute, "DELETE Affaire X") |
|
209 |
cu.execute("DELETE Affaire X WHERE X sujet 'pascool'") |
|
210 |
cnx.commit() |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
211 |
cnx.close() |
0 | 212 |
|
213 |
||
214 |
def test_insert_relation_rql_permission(self): |
|
215 |
cnx = self.login('iaminusersgrouponly') |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
216 |
session = self.session |
0 | 217 |
cu = cnx.cursor(session) |
218 |
cu.execute("SET A concerne S WHERE A is Affaire, S is Societe") |
|
219 |
# should raise Unauthorized since user don't own S |
|
220 |
# though this won't actually do anything since the selection query won't return anything |
|
221 |
cnx.commit() |
|
222 |
# to actually get Unauthorized exception, try to insert a relation were we can read both entities |
|
223 |
rset = cu.execute('Personne P') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
224 |
self.assertEqual(len(rset), 1) |
0 | 225 |
ent = rset.get_entity(0, 0) |
7398
26695dd703d8
[repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7244
diff
changeset
|
226 |
session.set_cnxset() # necessary |
5557
1a534c596bff
[entity] continue cleanup of Entity/AnyEntity namespace
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
227 |
self.assertRaises(Unauthorized, ent.cw_check_perm, 'update') |
0 | 228 |
self.assertRaises(Unauthorized, |
229 |
cu.execute, "SET P travaille S WHERE P is Personne, S is Societe") |
|
6410
2e7a7b0829ed
[test] fix tests broken by transaction behaviour on Unauthorized/ValidationError (no rollback but connection marked as non-commitable)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
230 |
self.assertRaises(QueryError, cnx.commit) # can't commit anymore |
2e7a7b0829ed
[test] fix tests broken by transaction behaviour on Unauthorized/ValidationError (no rollback but connection marked as non-commitable)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
231 |
cnx.rollback() |
0 | 232 |
# test nothing has actually been inserted: |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
233 |
self.assertEqual(cu.execute('Any P,S WHERE P travaille S,P is Personne, S is Societe').rowcount, 0) |
0 | 234 |
cu.execute("INSERT Societe X: X nom 'chouette'") |
235 |
cu.execute("SET A concerne S WHERE A is Affaire, S nom 'chouette'") |
|
236 |
cnx.commit() |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
237 |
cnx.close() |
0 | 238 |
|
239 |
def test_delete_relation_rql_permission(self): |
|
240 |
self.execute("SET A concerne S WHERE A is Affaire, S is Societe") |
|
241 |
self.commit() |
|
242 |
cnx = self.login('iaminusersgrouponly') |
|
243 |
cu = cnx.cursor() |
|
244 |
# this won't actually do anything since the selection query won't return anything |
|
245 |
cu.execute("DELETE A concerne S") |
|
246 |
cnx.commit() |
|
247 |
# to actually get Unauthorized exception, try to delete a relation we can read |
|
248 |
self.restore_connection() |
|
249 |
eid = self.execute("INSERT Affaire X: X sujet 'pascool'")[0][0] |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
250 |
self.execute('SET X owned_by U WHERE X eid %(x)s, U login "iaminusersgrouponly"', {'x': eid}) |
0 | 251 |
self.execute("SET A concerne S WHERE A sujet 'pascool', S is Societe") |
252 |
self.commit() |
|
253 |
cnx = self.login('iaminusersgrouponly') |
|
254 |
cu = cnx.cursor() |
|
255 |
self.assertRaises(Unauthorized, cu.execute, "DELETE A concerne S") |
|
6410
2e7a7b0829ed
[test] fix tests broken by transaction behaviour on Unauthorized/ValidationError (no rollback but connection marked as non-commitable)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
256 |
self.assertRaises(QueryError, cnx.commit) # can't commit anymore |
2e7a7b0829ed
[test] fix tests broken by transaction behaviour on Unauthorized/ValidationError (no rollback but connection marked as non-commitable)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
257 |
cnx.rollback() # required after Unauthorized |
0 | 258 |
cu.execute("INSERT Societe X: X nom 'chouette'") |
259 |
cu.execute("SET A concerne S WHERE A is Affaire, S nom 'chouette'") |
|
260 |
cnx.commit() |
|
261 |
cu.execute("DELETE A concerne S WHERE S nom 'chouette'") |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
262 |
cnx.close() |
0 | 263 |
|
264 |
||
265 |
def test_user_can_change_its_upassword(self): |
|
7244
a918f76441ce
fix tests broken by fcb8932082a5 (continued)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
266 |
req = self.request() |
a918f76441ce
fix tests broken by fcb8932082a5 (continued)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
267 |
ueid = self.create_user(req, 'user').eid |
0 | 268 |
cnx = self.login('user') |
269 |
cu = cnx.cursor() |
|
270 |
cu.execute('SET X upassword %(passwd)s WHERE X eid %(x)s', |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
271 |
{'x': ueid, 'passwd': 'newpwd'}) |
0 | 272 |
cnx.commit() |
273 |
cnx.close() |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
274 |
cnx = self.login('user', password='newpwd') |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
275 |
cnx.close() |
0 | 276 |
|
277 |
def test_user_cant_change_other_upassword(self): |
|
7244
a918f76441ce
fix tests broken by fcb8932082a5 (continued)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
278 |
req = self.request() |
a918f76441ce
fix tests broken by fcb8932082a5 (continued)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7078
diff
changeset
|
279 |
ueid = self.create_user(req, 'otheruser').eid |
0 | 280 |
cnx = self.login('iaminusersgrouponly') |
281 |
cu = cnx.cursor() |
|
282 |
cu.execute('SET X upassword %(passwd)s WHERE X eid %(x)s', |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
283 |
{'x': ueid, 'passwd': 'newpwd'}) |
0 | 284 |
self.assertRaises(Unauthorized, cnx.commit) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
285 |
cnx.close() |
0 | 286 |
|
287 |
# read security test |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
288 |
|
0 | 289 |
def test_read_base(self): |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
290 |
self.schema['Personne'].set_action_permissions('read', ('users', 'managers')) |
0 | 291 |
cnx = self.login('anon') |
292 |
cu = cnx.cursor() |
|
293 |
self.assertRaises(Unauthorized, |
|
294 |
cu.execute, 'Personne U where U nom "managers"') |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
295 |
cnx.close() |
0 | 296 |
|
321
247947250382
fix security bug w/ query using 'NOT X eid 123'
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
297 |
def test_read_erqlexpr_base(self): |
0 | 298 |
eid = self.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
299 |
self.commit() |
|
300 |
cnx = self.login('iaminusersgrouponly') |
|
301 |
cu = cnx.cursor() |
|
302 |
rset = cu.execute('Affaire X') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
303 |
self.assertEqual(rset.rows, []) |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
304 |
self.assertRaises(Unauthorized, cu.execute, 'Any X WHERE X eid %(x)s', {'x': eid}) |
321
247947250382
fix security bug w/ query using 'NOT X eid 123'
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
305 |
# cache test |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
306 |
self.assertRaises(Unauthorized, cu.execute, 'Any X WHERE X eid %(x)s', {'x': eid}) |
0 | 307 |
aff2 = cu.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
308 |
soc1 = cu.execute("INSERT Societe X: X nom 'chouette'")[0][0] |
|
309 |
cu.execute("SET A concerne S WHERE A is Affaire, S is Societe") |
|
310 |
cnx.commit() |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
311 |
rset = cu.execute('Any X WHERE X eid %(x)s', {'x': aff2}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
312 |
self.assertEqual(rset.rows, [[aff2]]) |
321
247947250382
fix security bug w/ query using 'NOT X eid 123'
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
313 |
# more cache test w/ NOT eid |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
314 |
rset = cu.execute('Affaire X WHERE NOT X eid %(x)s', {'x': eid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
315 |
self.assertEqual(rset.rows, [[aff2]]) |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
316 |
rset = cu.execute('Affaire X WHERE NOT X eid %(x)s', {'x': aff2}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
317 |
self.assertEqual(rset.rows, []) |
4765 | 318 |
# test can't update an attribute of an entity that can't be readen |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
319 |
self.assertRaises(Unauthorized, cu.execute, 'SET X sujet "hacked" WHERE X eid %(x)s', {'x': eid}) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
320 |
cnx.close() |
4765 | 321 |
|
322 |
||
323 |
def test_entity_created_in_transaction(self): |
|
324 |
affschema = self.schema['Affaire'] |
|
325 |
origperms = affschema.permissions['read'] |
|
326 |
affschema.set_action_permissions('read', affschema.permissions['add']) |
|
327 |
try: |
|
328 |
cnx = self.login('iaminusersgrouponly') |
|
329 |
cu = cnx.cursor() |
|
330 |
aff2 = cu.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
|
331 |
# entity created in transaction are readable *by eid* |
|
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
332 |
self.assertTrue(cu.execute('Any X WHERE X eid %(x)s', {'x':aff2})) |
4765 | 333 |
# XXX would be nice if it worked |
334 |
rset = cu.execute("Affaire X WHERE X sujet 'cool'") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
335 |
self.assertEqual(len(rset), 0) |
4765 | 336 |
finally: |
337 |
affschema.set_action_permissions('read', origperms) |
|
338 |
cnx.close() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
339 |
|
0 | 340 |
def test_read_erqlexpr_has_text1(self): |
341 |
aff1 = self.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
|
342 |
card1 = self.execute("INSERT Card X: X title 'cool'")[0][0] |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
343 |
self.execute('SET X owned_by U WHERE X eid %(x)s, U login "iaminusersgrouponly"', {'x': card1}) |
0 | 344 |
self.commit() |
345 |
cnx = self.login('iaminusersgrouponly') |
|
346 |
cu = cnx.cursor() |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
347 |
aff2 = cu.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
0 | 348 |
soc1 = cu.execute("INSERT Societe X: X nom 'chouette'")[0][0] |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
349 |
cu.execute("SET A concerne S WHERE A eid %(a)s, S eid %(s)s", {'a': aff2, 's': soc1}) |
0 | 350 |
cnx.commit() |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
351 |
self.assertRaises(Unauthorized, cu.execute, 'Any X WHERE X eid %(x)s', {'x':aff1}) |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
352 |
self.assertTrue(cu.execute('Any X WHERE X eid %(x)s', {'x':aff2})) |
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
353 |
self.assertTrue(cu.execute('Any X WHERE X eid %(x)s', {'x':card1})) |
0 | 354 |
rset = cu.execute("Any X WHERE X has_text 'cool'") |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
355 |
self.assertEqual(sorted(eid for eid, in rset.rows), |
0 | 356 |
[card1, aff2]) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
357 |
cnx.close() |
0 | 358 |
|
359 |
def test_read_erqlexpr_has_text2(self): |
|
360 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
361 |
self.execute("INSERT Societe X: X nom 'bidule'") |
|
362 |
self.commit() |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
363 |
self.schema['Personne'].set_action_permissions('read', ('managers',)) |
0 | 364 |
cnx = self.login('iaminusersgrouponly') |
365 |
cu = cnx.cursor() |
|
366 |
rset = cu.execute('Any N WHERE N has_text "bidule"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
367 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
0 | 368 |
rset = cu.execute('Any N WITH N BEING (Any N WHERE N has_text "bidule")') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
369 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
370 |
cnx.close() |
0 | 371 |
|
372 |
def test_read_erqlexpr_optional_rel(self): |
|
373 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
374 |
self.execute("INSERT Societe X: X nom 'bidule'") |
|
375 |
self.commit() |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
376 |
self.schema['Personne'].set_action_permissions('read', ('managers',)) |
0 | 377 |
cnx = self.login('anon') |
378 |
cu = cnx.cursor() |
|
379 |
rset = cu.execute('Any N,U WHERE N has_text "bidule", N owned_by U?') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
380 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
381 |
cnx.close() |
0 | 382 |
|
383 |
def test_read_erqlexpr_aggregat(self): |
|
384 |
self.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
|
385 |
self.commit() |
|
386 |
cnx = self.login('iaminusersgrouponly') |
|
387 |
cu = cnx.cursor() |
|
388 |
rset = cu.execute('Any COUNT(X) WHERE X is Affaire') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
389 |
self.assertEqual(rset.rows, [[0]]) |
0 | 390 |
aff2 = cu.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
391 |
soc1 = cu.execute("INSERT Societe X: X nom 'chouette'")[0][0] |
|
392 |
cu.execute("SET A concerne S WHERE A is Affaire, S is Societe") |
|
393 |
cnx.commit() |
|
394 |
rset = cu.execute('Any COUNT(X) WHERE X is Affaire') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
395 |
self.assertEqual(rset.rows, [[1]]) |
0 | 396 |
rset = cu.execute('Any ETN, COUNT(X) GROUPBY ETN WHERE X is ET, ET name ETN') |
397 |
values = dict(rset) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
398 |
self.assertEqual(values['Affaire'], 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
399 |
self.assertEqual(values['Societe'], 2) |
0 | 400 |
rset = cu.execute('Any ETN, COUNT(X) GROUPBY ETN WHERE X is ET, ET name ETN WITH X BEING ((Affaire X) UNION (Societe X))') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
401 |
self.assertEqual(len(rset), 2) |
0 | 402 |
values = dict(rset) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
403 |
self.assertEqual(values['Affaire'], 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
404 |
self.assertEqual(values['Societe'], 2) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
405 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
406 |
|
0 | 407 |
|
408 |
def test_attribute_security(self): |
|
409 |
# only managers should be able to edit the 'test' attribute of Personne entities |
|
410 |
eid = self.execute("INSERT Personne X: X nom 'bidule', X web 'http://www.debian.org', X test TRUE")[0][0] |
|
411 |
self.commit() |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
412 |
self.execute('SET X test FALSE WHERE X eid %(x)s', {'x': eid}) |
0 | 413 |
self.commit() |
414 |
cnx = self.login('iaminusersgrouponly') |
|
415 |
cu = cnx.cursor() |
|
416 |
cu.execute("INSERT Personne X: X nom 'bidule', X web 'http://www.debian.org', X test TRUE") |
|
417 |
self.assertRaises(Unauthorized, cnx.commit) |
|
418 |
cu.execute("INSERT Personne X: X nom 'bidule', X web 'http://www.debian.org', X test FALSE") |
|
419 |
self.assertRaises(Unauthorized, cnx.commit) |
|
420 |
eid = cu.execute("INSERT Personne X: X nom 'bidule', X web 'http://www.debian.org'")[0][0] |
|
421 |
cnx.commit() |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
422 |
cu.execute('SET X test FALSE WHERE X eid %(x)s', {'x': eid}) |
0 | 423 |
self.assertRaises(Unauthorized, cnx.commit) |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
424 |
cu.execute('SET X test TRUE WHERE X eid %(x)s', {'x': eid}) |
0 | 425 |
self.assertRaises(Unauthorized, cnx.commit) |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
426 |
cu.execute('SET X web "http://www.logilab.org" WHERE X eid %(x)s', {'x': eid}) |
0 | 427 |
cnx.commit() |
428 |
cnx.close() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
429 |
|
0 | 430 |
def test_attribute_security_rqlexpr(self): |
431 |
# Note.para attribute editable by managers or if the note is in "todo" state |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
432 |
note = self.execute("INSERT Note X: X para 'bidule'").get_entity(0, 0) |
0 | 433 |
self.commit() |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
434 |
note.cw_adapt_to('IWorkflowable').fire_transition('markasdone') |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
435 |
self.execute('SET X para "truc" WHERE X eid %(x)s', {'x': note.eid}) |
0 | 436 |
self.commit() |
437 |
cnx = self.login('iaminusersgrouponly') |
|
438 |
cu = cnx.cursor() |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
439 |
cu.execute("SET X para 'chouette' WHERE X eid %(x)s", {'x': note.eid}) |
0 | 440 |
self.assertRaises(Unauthorized, cnx.commit) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
441 |
note2 = cu.execute("INSERT Note X: X para 'bidule'").get_entity(0, 0) |
0 | 442 |
cnx.commit() |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
443 |
note2.cw_adapt_to('IWorkflowable').fire_transition('markasdone') |
0 | 444 |
cnx.commit() |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
445 |
self.assertEqual(len(cu.execute('Any X WHERE X in_state S, S name "todo", X eid %(x)s', {'x': note2.eid})), |
0 | 446 |
0) |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
447 |
cu.execute("SET X para 'chouette' WHERE X eid %(x)s", {'x': note2.eid}) |
0 | 448 |
self.assertRaises(Unauthorized, cnx.commit) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
449 |
note2.cw_adapt_to('IWorkflowable').fire_transition('redoit') |
0 | 450 |
cnx.commit() |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
451 |
cu.execute("SET X para 'chouette' WHERE X eid %(x)s", {'x': note2.eid}) |
0 | 452 |
cnx.commit() |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
453 |
cnx.close() |
0 | 454 |
|
455 |
def test_attribute_read_security(self): |
|
456 |
# anon not allowed to see users'login, but they can see users |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
457 |
self.repo.schema['CWUser'].set_action_permissions('read', ('guests', 'users', 'managers')) |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
458 |
self.repo.schema['CWUser'].rdef('login').set_action_permissions('read', ('users', 'managers')) |
0 | 459 |
cnx = self.login('anon') |
460 |
cu = cnx.cursor() |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
461 |
rset = cu.execute('CWUser X') |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
462 |
self.assertTrue(rset) |
0 | 463 |
x = rset.get_entity(0, 0) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
464 |
self.assertEqual(x.login, None) |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
465 |
self.assertTrue(x.creation_date) |
0 | 466 |
x = rset.get_entity(1, 0) |
467 |
x.complete() |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
468 |
self.assertEqual(x.login, None) |
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
469 |
self.assertTrue(x.creation_date) |
0 | 470 |
cnx.rollback() |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
471 |
cnx.close() |
0 | 472 |
|
8452
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
473 |
def test_yams_inheritance_and_security_bug(self): |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
474 |
oldperms = self.schema['Division'].permissions |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
475 |
try: |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
476 |
self.schema['Division'].permissions = { |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
477 |
'read': ('managers', ERQLExpression('X owned_by U')), |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
478 |
'add': ('managers', 'users'), |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
479 |
'update': ('managers', 'owners'), |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
480 |
'delete': ('managers', 'owners')} |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
481 |
self.login('iaminusersgrouponly') |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
482 |
querier = self.repo.querier |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
483 |
rqlst = querier.parse('Any X WHERE X is_instance_of Societe') |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
484 |
querier.solutions(self.session, rqlst, {}) |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
485 |
querier._annotate(rqlst) |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
486 |
plan = querier.plan_factory(rqlst, {}, self.session) |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
487 |
plan.preprocess(rqlst) |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
488 |
self.assertEqual( |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
489 |
rqlst.as_string(), |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
490 |
'(Any X WHERE X is IN(SubDivision, Societe)) UNION (Any X WHERE X is Division, EXISTS(X owned_by %(B)s))') |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
491 |
finally: |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
492 |
self.schema['Division'].permissions = oldperms |
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
493 |
|
1ad42383a9ec
[rql security] fix rql bug when using yams inheritance and read permissions (closes #2410156)
Florent Cayré <florent.cayre@logilab.fr>
parents:
8075
diff
changeset
|
494 |
|
0 | 495 |
class BaseSchemaSecurityTC(BaseSecurityTC): |
496 |
"""tests related to the base schema permission configuration""" |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
497 |
|
0 | 498 |
def test_user_can_delete_object_he_created(self): |
499 |
# even if some other user have changed object'state |
|
500 |
cnx = self.login('iaminusersgrouponly') |
|
501 |
cu = cnx.cursor() |
|
502 |
# due to security test, affaire has to concerne a societe the user owns |
|
503 |
cu.execute('INSERT Societe X: X nom "ARCTIA"') |
|
504 |
cu.execute('INSERT Affaire X: X ref "ARCT01", X concerne S WHERE S nom "ARCTIA"') |
|
505 |
cnx.commit() |
|
506 |
self.restore_connection() |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
507 |
affaire = self.execute('Any X WHERE X ref "ARCT01"').get_entity(0, 0) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
508 |
affaire.cw_adapt_to('IWorkflowable').fire_transition('abort') |
0 | 509 |
self.commit() |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
510 |
self.assertEqual(len(self.execute('TrInfo X WHERE X wf_info_for A, A ref "ARCT01"')), |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
511 |
1) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
512 |
self.assertEqual(len(self.execute('TrInfo X WHERE X wf_info_for A, A ref "ARCT01",' |
0 | 513 |
'X owned_by U, U login "admin"')), |
514 |
1) # TrInfo at the above state change |
|
515 |
cnx = self.login('iaminusersgrouponly') |
|
516 |
cu = cnx.cursor() |
|
517 |
cu.execute('DELETE Affaire X WHERE X ref "ARCT01"') |
|
518 |
cnx.commit() |
|
7791
31bb51ea5485
[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7398
diff
changeset
|
519 |
self.assertFalse(cu.execute('Affaire X')) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
520 |
cnx.close() |
0 | 521 |
|
522 |
def test_users_and_groups_non_readable_by_guests(self): |
|
523 |
cnx = self.login('anon') |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
524 |
anon = cnx.user(self.session) |
0 | 525 |
cu = cnx.cursor() |
526 |
# anonymous user can only read itself |
|
527 |
rset = cu.execute('Any L WHERE X owned_by U, U login L') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
528 |
self.assertEqual(rset.rows, [['anon']]) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
529 |
rset = cu.execute('CWUser X') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
530 |
self.assertEqual(rset.rows, [[anon.eid]]) |
0 | 531 |
# anonymous user can read groups (necessary to check allowed transitions for instance) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
389
diff
changeset
|
532 |
self.assert_(cu.execute('CWGroup X')) |
0 | 533 |
# should only be able to read the anonymous user, not another one |
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
534 |
origuser = self.adminsession.user |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
535 |
self.assertRaises(Unauthorized, |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
536 |
cu.execute, 'CWUser X WHERE X eid %(x)s', {'x': origuser.eid}) |
0 | 537 |
# nothing selected, nothing updated, no exception raised |
538 |
#self.assertRaises(Unauthorized, |
|
539 |
# cu.execute, 'SET X login "toto" WHERE X eid %(x)s', |
|
540 |
# {'x': self.user.eid}) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
541 |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
542 |
rset = cu.execute('CWUser X WHERE X eid %(x)s', {'x': anon.eid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
543 |
self.assertEqual(rset.rows, [[anon.eid]]) |
0 | 544 |
# but can't modify it |
4915
d657b89df9f4
fix test broken by recent rql rewrite / querier changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4787
diff
changeset
|
545 |
cu.execute('SET X login "toto" WHERE X eid %(x)s', {'x': anon.eid}) |
d657b89df9f4
fix test broken by recent rql rewrite / querier changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4787
diff
changeset
|
546 |
self.assertRaises(Unauthorized, cnx.commit) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
547 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
548 |
|
0 | 549 |
def test_in_group_relation(self): |
550 |
cnx = self.login('iaminusersgrouponly') |
|
551 |
cu = cnx.cursor() |
|
552 |
rql = u"DELETE U in_group G WHERE U login 'admin'" |
|
553 |
self.assertRaises(Unauthorized, cu.execute, rql) |
|
554 |
rql = u"SET U in_group G WHERE U login 'admin', G name 'users'" |
|
555 |
self.assertRaises(Unauthorized, cu.execute, rql) |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
556 |
cnx.close() |
0 | 557 |
|
558 |
def test_owned_by(self): |
|
559 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
560 |
self.commit() |
|
561 |
cnx = self.login('iaminusersgrouponly') |
|
562 |
cu = cnx.cursor() |
|
563 |
rql = u"SET X owned_by U WHERE U login 'iaminusersgrouponly', X is Personne" |
|
564 |
self.assertRaises(Unauthorized, cu.execute, rql) |
|
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
565 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
566 |
|
0 | 567 |
def test_bookmarked_by_guests_security(self): |
568 |
beid1 = self.execute('INSERT Bookmark B: B path "?vid=manage", B title "manage"')[0][0] |
|
569 |
beid2 = self.execute('INSERT Bookmark B: B path "?vid=index", B title "index", B bookmarked_by U WHERE U login "anon"')[0][0] |
|
570 |
self.commit() |
|
571 |
cnx = self.login('anon') |
|
572 |
cu = cnx.cursor() |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
573 |
anoneid = self.session.user.eid |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
574 |
self.assertEqual(cu.execute('Any T,P ORDERBY lower(T) WHERE B is Bookmark,B title T,B path P,' |
0 | 575 |
'B bookmarked_by U, U eid %s' % anoneid).rows, |
576 |
[['index', '?vid=index']]) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
577 |
self.assertEqual(cu.execute('Any T,P ORDERBY lower(T) WHERE B is Bookmark,B title T,B path P,' |
0 | 578 |
'B bookmarked_by U, U eid %(x)s', {'x': anoneid}).rows, |
579 |
[['index', '?vid=index']]) |
|
580 |
# can read others bookmarks as well |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
581 |
self.assertEqual(cu.execute('Any B where B is Bookmark, NOT B bookmarked_by U').rows, |
0 | 582 |
[[beid1]]) |
583 |
self.assertRaises(Unauthorized, cu.execute,'DELETE B bookmarked_by U') |
|
584 |
self.assertRaises(Unauthorized, |
|
585 |
cu.execute, 'SET B bookmarked_by U WHERE U eid %(x)s, B eid %(b)s', |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
586 |
{'x': anoneid, 'b': beid1}) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
587 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
588 |
|
0 | 589 |
|
590 |
def test_ambigous_ordered(self): |
|
591 |
cnx = self.login('anon') |
|
592 |
cu = cnx.cursor() |
|
593 |
names = [t for t, in cu.execute('Any N ORDERBY lower(N) WHERE X name N')] |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
594 |
self.assertEqual(names, sorted(names, key=lambda x: x.lower())) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
595 |
cnx.close() |
0 | 596 |
|
8075
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
597 |
def test_restrict_is_instance_ok(self): |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
598 |
from rql import RQLException |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
599 |
rset = self.execute('Any X WHERE X is_instance_of BaseTransition') |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
600 |
rqlst = rset.syntax_tree() |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
601 |
select = rqlst.children[0] |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
602 |
x = select.get_selected_variables().next() |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
603 |
self.assertRaises(RQLException, select.add_type_restriction, |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
604 |
x.variable, 'CWUser') |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
605 |
select.add_type_restriction(x.variable, 'BaseTransition') |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
606 |
select.add_type_restriction(x.variable, 'WorkflowTransition') |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
607 |
self.assertEqual(rqlst.as_string(), 'Any X WHERE X is_instance_of WorkflowTransition') |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
608 |
|
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
609 |
def test_restrict_is_instance_no_supported(self): |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
610 |
rset = self.execute('Any X WHERE X is_instance_of IN(CWUser, CWGroup)') |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
611 |
rqlst = rset.syntax_tree() |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
612 |
select = rqlst.children[0] |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
613 |
x = select.get_selected_variables().next() |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
614 |
self.assertRaises(NotImplementedError, select.add_type_restriction, |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
615 |
x.variable, 'WorkflowTransition') |
f57ffbfe90fe
[test] add some tests for rql's add_type_restriction
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7791
diff
changeset
|
616 |
|
0 | 617 |
def test_in_state_without_update_perm(self): |
618 |
"""check a user change in_state without having update permission on the |
|
619 |
subject |
|
620 |
""" |
|
621 |
eid = self.execute('INSERT Affaire X: X ref "ARCT01"')[0][0] |
|
622 |
self.commit() |
|
623 |
cnx = self.login('iaminusersgrouponly') |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
624 |
session = self.session |
0 | 625 |
# needed to avoid check_perm error |
7398
26695dd703d8
[repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7244
diff
changeset
|
626 |
session.set_cnxset() |
0 | 627 |
# needed to remove rql expr granting update perm to the user |
4691
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
628 |
affaire_perms = self.schema['Affaire'].permissions.copy() |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3252
diff
changeset
|
629 |
self.schema['Affaire'].set_action_permissions('update', self.schema['Affaire'].get_groups('update')) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
630 |
try: |
4691
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
631 |
self.assertRaises(Unauthorized, |
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
632 |
self.schema['Affaire'].check_perm, session, 'update', eid=eid) |
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
633 |
cu = cnx.cursor() |
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
634 |
self.schema['Affaire'].set_action_permissions('read', ('users',)) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
635 |
aff = cu.execute('Any X WHERE X ref "ARCT01"').get_entity(0, 0) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
636 |
aff.cw_adapt_to('IWorkflowable').fire_transition('abort') |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
637 |
cnx.commit() |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
638 |
# though changing a user state (even logged user) is reserved to managers |
3447 | 639 |
user = cnx.user(self.session) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
640 |
# XXX wether it should raise Unauthorized or ValidationError is not clear |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
641 |
# the best would probably ValidationError if the transition doesn't exist |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
642 |
# from the current state but Unauthorized if it exists but user can't pass it |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
643 |
self.assertRaises(ValidationError, |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
644 |
user.cw_adapt_to('IWorkflowable').fire_transition, 'deactivate') |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
645 |
finally: |
4691
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
646 |
# restore orig perms |
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
647 |
for action, perms in affaire_perms.iteritems(): |
ae468fae9965
[test] fix test inter-dependancies pb. Pytest ok in each individual test dir, though not yet for whole cubicweb, but for different reasons
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
648 |
self.schema['Affaire'].set_action_permissions(action, perms) |
7072
bcf96f2a4c5d
[test] properly close connections
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6410
diff
changeset
|
649 |
cnx.close() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
650 |
|
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
651 |
def test_trinfo_security(self): |
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
652 |
aff = self.execute('INSERT Affaire X: X ref "ARCT01"').get_entity(0, 0) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
653 |
iworkflowable = aff.cw_adapt_to('IWorkflowable') |
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
654 |
self.commit() |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
655 |
iworkflowable.fire_transition('abort') |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
656 |
self.commit() |
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
657 |
# can change tr info comment |
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
658 |
self.execute('SET TI comment %(c)s WHERE TI wf_info_for X, X ref "ARCT01"', |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
659 |
{'c': u'bouh!'}) |
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
660 |
self.commit() |
5557
1a534c596bff
[entity] continue cleanup of Entity/AnyEntity namespace
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
661 |
aff.cw_clear_relation_cache('wf_info_for', 'object') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
662 |
trinfo = iworkflowable.latest_trinfo() |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
663 |
self.assertEqual(trinfo.comment, 'bouh!') |
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
664 |
# but not from_state/to_state |
5557
1a534c596bff
[entity] continue cleanup of Entity/AnyEntity namespace
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
665 |
aff.cw_clear_relation_cache('wf_info_for', role='object') |
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
666 |
self.assertRaises(Unauthorized, |
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
667 |
self.execute, 'SET TI from_state S WHERE TI eid %(ti)s, S name "ben non"', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
668 |
{'ti': trinfo.eid}) |
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
669 |
self.assertRaises(Unauthorized, |
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
670 |
self.execute, 'SET TI to_state S WHERE TI eid %(ti)s, S name "pitetre"', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4915
diff
changeset
|
671 |
{'ti': trinfo.eid}) |
2501
fa86d99c2c3a
test and fix wf history security
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2500
diff
changeset
|
672 |
|
8161
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
673 |
def test_emailaddress_security(self): |
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
674 |
self.execute('INSERT EmailAddress X: X address "hop"').get_entity(0, 0) |
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
675 |
self.execute('INSERT EmailAddress X: X address "anon", U use_email X WHERE U login "anon"').get_entity(0, 0) |
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
676 |
self.commit() |
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
677 |
self.assertEqual(len(self.execute('Any X WHERE X is EmailAddress')), 2) |
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
678 |
self.login('anon') |
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
679 |
self.assertEqual(len(self.execute('Any X WHERE X is EmailAddress')), 1) |
6f4229eb8178
[test] fix test broken by 8158:2ee254e74382 and add a test for that change
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8075
diff
changeset
|
680 |
|
0 | 681 |
if __name__ == '__main__': |
682 |
unittest_main() |