141 self.assertEquals(ppi.needsplit, needsplit) |
141 self.assertEquals(ppi.needsplit, needsplit) |
142 |
142 |
143 |
143 |
144 def test_simple_system_only(self): |
144 def test_simple_system_only(self): |
145 """retrieve entities only supported by the system source""" |
145 """retrieve entities only supported by the system source""" |
146 self._test('EGroup X', |
146 self._test('CWGroup X', |
147 {self.system: {'X': s[0]}}, False) |
147 {self.system: {'X': s[0]}}, False) |
148 |
148 |
149 def test_simple_system_ldap(self): |
149 def test_simple_system_ldap(self): |
150 """retrieve EUser X from both sources and return concatenation of results |
150 """retrieve CWUser X from both sources and return concatenation of results |
151 """ |
151 """ |
152 self._test('EUser X', |
152 self._test('CWUser X', |
153 {self.system: {'X': s[0]}, self.ldap: {'X': s[0]}}, False) |
153 {self.system: {'X': s[0]}, self.ldap: {'X': s[0]}}, False) |
154 |
154 |
155 def test_simple_system_rql(self): |
155 def test_simple_system_rql(self): |
156 """retrieve Card X from both sources and return concatenation of results |
156 """retrieve Card X from both sources and return concatenation of results |
157 """ |
157 """ |
158 self._test('Any X, XT WHERE X is Card, X title XT', |
158 self._test('Any X, XT WHERE X is Card, X title XT', |
159 {self.system: {'X': s[0]}, self.rql: {'X': s[0]}}, False) |
159 {self.system: {'X': s[0]}, self.rql: {'X': s[0]}}, False) |
160 |
160 |
161 def test_simple_eid_specified(self): |
161 def test_simple_eid_specified(self): |
162 """retrieve EUser X from system source (eid is specified, can locate the entity) |
162 """retrieve CWUser X from system source (eid is specified, can locate the entity) |
163 """ |
163 """ |
164 ueid = self.session.user.eid |
164 ueid = self.session.user.eid |
165 self._test('Any X,L WHERE X eid %(x)s, X login L', {'x': ueid}, |
165 self._test('Any X,L WHERE X eid %(x)s, X login L', {'x': ueid}, |
166 {self.system: {'X': s[0]}}, False) |
166 {self.system: {'X': s[0]}}, False) |
167 |
167 |
168 def test_simple_eid_invariant(self): |
168 def test_simple_eid_invariant(self): |
169 """retrieve EUser X from system source (eid is specified, can locate the entity) |
169 """retrieve CWUser X from system source (eid is specified, can locate the entity) |
170 """ |
170 """ |
171 ueid = self.session.user.eid |
171 ueid = self.session.user.eid |
172 self._test('Any X WHERE X eid %(x)s', {'x': ueid}, |
172 self._test('Any X WHERE X eid %(x)s', {'x': ueid}, |
173 {self.system: {'x': s[0]}}, False) |
173 {self.system: {'x': s[0]}}, False) |
174 |
174 |
175 def test_simple_invariant(self): |
175 def test_simple_invariant(self): |
176 """retrieve EUser X from system source only (X is invariant and in_group not supported by ldap source) |
176 """retrieve CWUser X from system source only (X is invariant and in_group not supported by ldap source) |
177 """ |
177 """ |
178 self._test('Any X WHERE X is EUser, X in_group G, G name "users"', |
178 self._test('Any X WHERE X is CWUser, X in_group G, G name "users"', |
179 {self.system: {'X': s[0], 'G': s[0], 'in_group': s[0]}}, False) |
179 {self.system: {'X': s[0], 'G': s[0], 'in_group': s[0]}}, False) |
180 |
180 |
181 def test_security_has_text(self): |
181 def test_security_has_text(self): |
182 """retrieve EUser X from system source only (has_text not supported by ldap source) |
182 """retrieve CWUser X from system source only (has_text not supported by ldap source) |
183 """ |
183 """ |
184 # specify EUser instead of any since the way this test is written we aren't well dealing |
184 # specify CWUser instead of any since the way this test is written we aren't well dealing |
185 # with ambigous query (eg only considering the first solution) |
185 # with ambigous query (eg only considering the first solution) |
186 self._test('EUser X WHERE X has_text "bla"', |
186 self._test('CWUser X WHERE X has_text "bla"', |
187 {self.system: {'X': s[0]}}, False) |
187 {self.system: {'X': s[0]}}, False) |
188 |
188 |
189 def test_complex_base(self): |
189 def test_complex_base(self): |
190 """ |
190 """ |
191 1. retrieve Any X, L WHERE X is EUser, X login L from system and ldap sources, store |
191 1. retrieve Any X, L WHERE X is CWUser, X login L from system and ldap sources, store |
192 concatenation of results into a temporary table |
192 concatenation of results into a temporary table |
193 2. return the result of Any X, L WHERE X is TMP, X login L, X in_group G, |
193 2. return the result of Any X, L WHERE X is TMP, X login L, X in_group G, |
194 G name 'users' on the system source |
194 G name 'users' on the system source |
195 """ |
195 """ |
196 self._test('Any X,L WHERE X is EUser, X in_group G, X login L, G name "users"', |
196 self._test('Any X,L WHERE X is CWUser, X in_group G, X login L, G name "users"', |
197 {self.system: {'X': s[0], 'G': s[0], 'in_group': s[0]}, |
197 {self.system: {'X': s[0], 'G': s[0], 'in_group': s[0]}, |
198 self.ldap : {'X': s[0]}}, True) |
198 self.ldap : {'X': s[0]}}, True) |
199 |
199 |
200 def test_complex_invariant_ordered(self): |
200 def test_complex_invariant_ordered(self): |
201 """ |
201 """ |
368 _test = test_plan |
368 _test = test_plan |
369 |
369 |
370 def test_simple_system_only(self): |
370 def test_simple_system_only(self): |
371 """retrieve entities only supported by the system source |
371 """retrieve entities only supported by the system source |
372 """ |
372 """ |
373 self._test('EGroup X', |
373 self._test('CWGroup X', |
374 [('OneFetchStep', [('Any X WHERE X is EGroup', [{'X': 'EGroup'}])], |
374 [('OneFetchStep', [('Any X WHERE X is CWGroup', [{'X': 'CWGroup'}])], |
375 None, None, [self.system], {}, [])]) |
375 None, None, [self.system], {}, [])]) |
376 |
376 |
377 def test_simple_system_only_limit(self): |
377 def test_simple_system_only_limit(self): |
378 """retrieve entities only supported by the system source |
378 """retrieve entities only supported by the system source |
379 """ |
379 """ |
380 self._test('EGroup X LIMIT 10', |
380 self._test('CWGroup X LIMIT 10', |
381 [('OneFetchStep', [('Any X LIMIT 10 WHERE X is EGroup', [{'X': 'EGroup'}])], |
381 [('OneFetchStep', [('Any X LIMIT 10 WHERE X is CWGroup', [{'X': 'CWGroup'}])], |
382 10, None, [self.system], {}, [])]) |
382 10, None, [self.system], {}, [])]) |
383 |
383 |
384 def test_simple_system_only_limit_offset(self): |
384 def test_simple_system_only_limit_offset(self): |
385 """retrieve entities only supported by the system source |
385 """retrieve entities only supported by the system source |
386 """ |
386 """ |
387 self._test('EGroup X LIMIT 10 OFFSET 10', |
387 self._test('CWGroup X LIMIT 10 OFFSET 10', |
388 [('OneFetchStep', [('Any X LIMIT 10 OFFSET 10 WHERE X is EGroup', [{'X': 'EGroup'}])], |
388 [('OneFetchStep', [('Any X LIMIT 10 OFFSET 10 WHERE X is CWGroup', [{'X': 'CWGroup'}])], |
389 10, 10, [self.system], {}, [])]) |
389 10, 10, [self.system], {}, [])]) |
390 |
390 |
391 def test_simple_system_ldap(self): |
391 def test_simple_system_ldap(self): |
392 """retrieve EUser X from both sources and return concatenation of results |
392 """retrieve CWUser X from both sources and return concatenation of results |
393 """ |
393 """ |
394 self._test('EUser X', |
394 self._test('CWUser X', |
395 [('OneFetchStep', [('Any X WHERE X is EUser', [{'X': 'EUser'}])], |
395 [('OneFetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])], |
396 None, None, [self.ldap, self.system], {}, [])]) |
396 None, None, [self.ldap, self.system], {}, [])]) |
397 |
397 |
398 def test_simple_system_ldap_limit(self): |
398 def test_simple_system_ldap_limit(self): |
399 """retrieve EUser X from both sources and return concatenation of results |
399 """retrieve CWUser X from both sources and return concatenation of results |
400 """ |
400 """ |
401 self._test('EUser X LIMIT 10', |
401 self._test('CWUser X LIMIT 10', |
402 [('OneFetchStep', [('Any X LIMIT 10 WHERE X is EUser', [{'X': 'EUser'}])], |
402 [('OneFetchStep', [('Any X LIMIT 10 WHERE X is CWUser', [{'X': 'CWUser'}])], |
403 10, None, [self.ldap, self.system], {}, [])]) |
403 10, None, [self.ldap, self.system], {}, [])]) |
404 |
404 |
405 def test_simple_system_ldap_limit_offset(self): |
405 def test_simple_system_ldap_limit_offset(self): |
406 """retrieve EUser X from both sources and return concatenation of results |
406 """retrieve CWUser X from both sources and return concatenation of results |
407 """ |
407 """ |
408 self._test('EUser X LIMIT 10 OFFSET 10', |
408 self._test('CWUser X LIMIT 10 OFFSET 10', |
409 [('OneFetchStep', [('Any X LIMIT 10 OFFSET 10 WHERE X is EUser', [{'X': 'EUser'}])], |
409 [('OneFetchStep', [('Any X LIMIT 10 OFFSET 10 WHERE X is CWUser', [{'X': 'CWUser'}])], |
410 10, 10, [self.ldap, self.system], {}, [])]) |
410 10, 10, [self.ldap, self.system], {}, [])]) |
411 |
411 |
412 def test_simple_system_ldap_ordered_limit_offset(self): |
412 def test_simple_system_ldap_ordered_limit_offset(self): |
413 """retrieve EUser X from both sources and return concatenation of results |
413 """retrieve CWUser X from both sources and return concatenation of results |
414 """ |
414 """ |
415 self._test('EUser X ORDERBY X LIMIT 10 OFFSET 10', |
415 self._test('CWUser X ORDERBY X LIMIT 10 OFFSET 10', |
416 [('AggrStep', 'Any X ORDERBY X', 10, 10, 'table0', None, [ |
416 [('AggrStep', 'Any X ORDERBY X', 10, 10, 'table0', None, [ |
417 ('FetchStep', [('Any X WHERE X is EUser', [{'X': 'EUser'}])], |
417 ('FetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])], |
418 [self.ldap, self.system], {}, {'X': 'table0.C0'}, []), |
418 [self.ldap, self.system], {}, {'X': 'table0.C0'}, []), |
419 ]), |
419 ]), |
420 ]) |
420 ]) |
421 def test_simple_system_ldap_aggregat(self): |
421 def test_simple_system_ldap_aggregat(self): |
422 """retrieve EUser X from both sources and return concatenation of results |
422 """retrieve CWUser X from both sources and return concatenation of results |
423 """ |
423 """ |
424 # COUNT(X) is kept in sub-step and transformed into SUM(X) in the AggrStep |
424 # COUNT(X) is kept in sub-step and transformed into SUM(X) in the AggrStep |
425 self._test('Any COUNT(X) WHERE X is EUser', |
425 self._test('Any COUNT(X) WHERE X is CWUser', |
426 [('AggrStep', 'Any COUNT(X)', None, None, 'table0', None, [ |
426 [('AggrStep', 'Any COUNT(X)', None, None, 'table0', None, [ |
427 ('FetchStep', [('Any COUNT(X) WHERE X is EUser', [{'X': 'EUser'}])], |
427 ('FetchStep', [('Any COUNT(X) WHERE X is CWUser', [{'X': 'CWUser'}])], |
428 [self.ldap, self.system], {}, {'COUNT(X)': 'table0.C0'}, []), |
428 [self.ldap, self.system], {}, {'COUNT(X)': 'table0.C0'}, []), |
429 ]), |
429 ]), |
430 ]) |
430 ]) |
431 |
431 |
432 def test_simple_system_rql(self): |
432 def test_simple_system_rql(self): |
435 self._test('Any X, XT WHERE X is Card, X title XT', |
435 self._test('Any X, XT WHERE X is Card, X title XT', |
436 [('OneFetchStep', [('Any X,XT WHERE X is Card, X title XT', [{'X': 'Card', 'XT': 'String'}])], |
436 [('OneFetchStep', [('Any X,XT WHERE X is Card, X title XT', [{'X': 'Card', 'XT': 'String'}])], |
437 None, None, [self.rql, self.system], {}, [])]) |
437 None, None, [self.rql, self.system], {}, [])]) |
438 |
438 |
439 def test_simple_eid_specified(self): |
439 def test_simple_eid_specified(self): |
440 """retrieve EUser X from system source (eid is specified, can locate the entity) |
440 """retrieve CWUser X from system source (eid is specified, can locate the entity) |
441 """ |
441 """ |
442 ueid = self.session.user.eid |
442 ueid = self.session.user.eid |
443 self._test('Any X,L WHERE X eid %(x)s, X login L', |
443 self._test('Any X,L WHERE X eid %(x)s, X login L', |
444 [('OneFetchStep', [('Any X,L WHERE X eid %s, X login L'%ueid, [{'X': 'EUser', 'L': 'String'}])], |
444 [('OneFetchStep', [('Any X,L WHERE X eid %s, X login L'%ueid, [{'X': 'CWUser', 'L': 'String'}])], |
445 None, None, [self.system], {}, [])], |
445 None, None, [self.system], {}, [])], |
446 {'x': ueid}) |
446 {'x': ueid}) |
447 |
447 |
448 def test_simple_eid_invariant(self): |
448 def test_simple_eid_invariant(self): |
449 """retrieve EUser X from system source (eid is specified, can locate the entity) |
449 """retrieve CWUser X from system source (eid is specified, can locate the entity) |
450 """ |
450 """ |
451 ueid = self.session.user.eid |
451 ueid = self.session.user.eid |
452 self._test('Any X WHERE X eid %(x)s', |
452 self._test('Any X WHERE X eid %(x)s', |
453 [('OneFetchStep', [('Any %s'%ueid, [{}])], |
453 [('OneFetchStep', [('Any %s'%ueid, [{}])], |
454 None, None, [self.system], {}, [])], |
454 None, None, [self.system], {}, [])], |
455 {'x': ueid}) |
455 {'x': ueid}) |
456 |
456 |
457 def test_simple_invariant(self): |
457 def test_simple_invariant(self): |
458 """retrieve EUser X from system source only (X is invariant and in_group not supported by ldap source) |
458 """retrieve CWUser X from system source only (X is invariant and in_group not supported by ldap source) |
459 """ |
459 """ |
460 self._test('Any X WHERE X is EUser, X in_group G, G name "users"', |
460 self._test('Any X WHERE X is CWUser, X in_group G, G name "users"', |
461 [('OneFetchStep', [('Any X WHERE X is EUser, X in_group G, G name "users"', |
461 [('OneFetchStep', [('Any X WHERE X is CWUser, X in_group G, G name "users"', |
462 [{'X': 'EUser', 'G': 'EGroup'}])], |
462 [{'X': 'CWUser', 'G': 'CWGroup'}])], |
463 None, None, [self.system], {}, [])]) |
463 None, None, [self.system], {}, [])]) |
464 |
464 |
465 def test_complex_base(self): |
465 def test_complex_base(self): |
466 """ |
466 """ |
467 1. retrieve Any X, L WHERE X is EUser, X login L from system and ldap sources, store |
467 1. retrieve Any X, L WHERE X is CWUser, X login L from system and ldap sources, store |
468 concatenation of results into a temporary table |
468 concatenation of results into a temporary table |
469 2. return the result of Any X, L WHERE X is TMP, X login LX in_group G, |
469 2. return the result of Any X, L WHERE X is TMP, X login LX in_group G, |
470 G name 'users' on the system source |
470 G name 'users' on the system source |
471 """ |
471 """ |
472 self._test('Any X,L WHERE X is EUser, X in_group G, X login L, G name "users"', |
472 self._test('Any X,L WHERE X is CWUser, X in_group G, X login L, G name "users"', |
473 [('FetchStep', [('Any X,L WHERE X login L, X is EUser', [{'X': 'EUser', 'L': 'String'}])], |
473 [('FetchStep', [('Any X,L WHERE X login L, X is CWUser', [{'X': 'CWUser', 'L': 'String'}])], |
474 [self.ldap, self.system], None, |
474 [self.ldap, self.system], None, |
475 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []), |
475 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []), |
476 ('OneFetchStep', [('Any X,L WHERE X in_group G, X login L, G name "users", G is EGroup, X is EUser', |
476 ('OneFetchStep', [('Any X,L WHERE X in_group G, X login L, G name "users", G is CWGroup, X is CWUser', |
477 [{'X': 'EUser', 'L': 'String', 'G': 'EGroup'}])], |
477 [{'X': 'CWUser', 'L': 'String', 'G': 'CWGroup'}])], |
478 None, None, [self.system], |
478 None, None, [self.system], |
479 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []) |
479 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []) |
480 ]) |
480 ]) |
481 |
481 |
482 def test_complex_base_limit_offset(self): |
482 def test_complex_base_limit_offset(self): |
483 """ |
483 """ |
484 1. retrieve Any X, L WHERE X is EUser, X login L from system and ldap sources, store |
484 1. retrieve Any X, L WHERE X is CWUser, X login L from system and ldap sources, store |
485 concatenation of results into a temporary table |
485 concatenation of results into a temporary table |
486 2. return the result of Any X, L WHERE X is TMP, X login LX in_group G, |
486 2. return the result of Any X, L WHERE X is TMP, X login LX in_group G, |
487 G name 'users' on the system source |
487 G name 'users' on the system source |
488 """ |
488 """ |
489 self._test('Any X,L LIMIT 10 OFFSET 10 WHERE X is EUser, X in_group G, X login L, G name "users"', |
489 self._test('Any X,L LIMIT 10 OFFSET 10 WHERE X is CWUser, X in_group G, X login L, G name "users"', |
490 [('FetchStep', [('Any X,L WHERE X login L, X is EUser', [{'X': 'EUser', 'L': 'String'}])], |
490 [('FetchStep', [('Any X,L WHERE X login L, X is CWUser', [{'X': 'CWUser', 'L': 'String'}])], |
491 [self.ldap, self.system], None, |
491 [self.ldap, self.system], None, |
492 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []), |
492 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []), |
493 ('OneFetchStep', [('Any X,L LIMIT 10 OFFSET 10 WHERE X in_group G, X login L, G name "users", G is EGroup, X is EUser', |
493 ('OneFetchStep', [('Any X,L LIMIT 10 OFFSET 10 WHERE X in_group G, X login L, G name "users", G is CWGroup, X is CWUser', |
494 [{'X': 'EUser', 'L': 'String', 'G': 'EGroup'}])], |
494 [{'X': 'CWUser', 'L': 'String', 'G': 'CWGroup'}])], |
495 10, 10, |
495 10, 10, |
496 [self.system], {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []) |
496 [self.system], {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []) |
497 ]) |
497 ]) |
498 |
498 |
499 def test_complex_ordered(self): |
499 def test_complex_ordered(self): |
500 self._test('Any L ORDERBY L WHERE X login L', |
500 self._test('Any L ORDERBY L WHERE X login L', |
501 [('AggrStep', 'Any L ORDERBY L', None, None, 'table0', None, |
501 [('AggrStep', 'Any L ORDERBY L', None, None, 'table0', None, |
502 [('FetchStep', [('Any L WHERE X login L, X is EUser', |
502 [('FetchStep', [('Any L WHERE X login L, X is CWUser', |
503 [{'X': 'EUser', 'L': 'String'}])], |
503 [{'X': 'CWUser', 'L': 'String'}])], |
504 [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []), |
504 [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []), |
505 ]) |
505 ]) |
506 ]) |
506 ]) |
507 |
507 |
508 def test_complex_ordered_limit_offset(self): |
508 def test_complex_ordered_limit_offset(self): |
509 self._test('Any L ORDERBY L LIMIT 10 OFFSET 10 WHERE X login L', |
509 self._test('Any L ORDERBY L LIMIT 10 OFFSET 10 WHERE X login L', |
510 [('AggrStep', 'Any L ORDERBY L', 10, 10, 'table0', None, |
510 [('AggrStep', 'Any L ORDERBY L', 10, 10, 'table0', None, |
511 [('FetchStep', [('Any L WHERE X login L, X is EUser', |
511 [('FetchStep', [('Any L WHERE X login L, X is CWUser', |
512 [{'X': 'EUser', 'L': 'String'}])], |
512 [{'X': 'CWUser', 'L': 'String'}])], |
513 [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []), |
513 [self.ldap, self.system], {}, {'X.login': 'table0.C0', 'L': 'table0.C0'}, []), |
514 ]) |
514 ]) |
515 ]) |
515 ]) |
516 |
516 |
517 def test_complex_invariant_ordered(self): |
517 def test_complex_invariant_ordered(self): |
545 2. return the result of Any X,L,AA WHERE %s owned_by X, X login L, X modification_date AA |
545 2. return the result of Any X,L,AA WHERE %s owned_by X, X login L, X modification_date AA |
546 on the system source |
546 on the system source |
547 """ |
547 """ |
548 ueid = self.session.user.eid |
548 ueid = self.session.user.eid |
549 self._test('Any X,L,AA WHERE E eid %(x)s, E owned_by X, X login L, X modification_date AA', |
549 self._test('Any X,L,AA WHERE E eid %(x)s, E owned_by X, X login L, X modification_date AA', |
550 [('FetchStep', [('Any X,L,AA WHERE X login L, X modification_date AA, X is EUser', |
550 [('FetchStep', [('Any X,L,AA WHERE X login L, X modification_date AA, X is CWUser', |
551 [{'AA': 'Datetime', 'X': 'EUser', 'L': 'String'}])], |
551 [{'AA': 'Datetime', 'X': 'CWUser', 'L': 'String'}])], |
552 [self.ldap, self.system], None, |
552 [self.ldap, self.system], None, |
553 {'AA': 'table0.C2', 'X': 'table0.C0', 'X.login': 'table0.C1', 'X.modification_date': 'table0.C2', 'L': 'table0.C1'}, []), |
553 {'AA': 'table0.C2', 'X': 'table0.C0', 'X.login': 'table0.C1', 'X.modification_date': 'table0.C2', 'L': 'table0.C1'}, []), |
554 ('OneFetchStep', [('Any X,L,AA WHERE %s owned_by X, X login L, X modification_date AA, X is EUser'%ueid, |
554 ('OneFetchStep', [('Any X,L,AA WHERE %s owned_by X, X login L, X modification_date AA, X is CWUser'%ueid, |
555 [{'AA': 'Datetime', 'X': 'EUser', 'L': 'String'}])], |
555 [{'AA': 'Datetime', 'X': 'CWUser', 'L': 'String'}])], |
556 None, None, [self.system], |
556 None, None, [self.system], |
557 {'AA': 'table0.C2', 'X': 'table0.C0', 'X.login': 'table0.C1', 'X.modification_date': 'table0.C2', 'L': 'table0.C1'}, [])], |
557 {'AA': 'table0.C2', 'X': 'table0.C0', 'X.login': 'table0.C1', 'X.modification_date': 'table0.C2', 'L': 'table0.C1'}, [])], |
558 {'x': ueid}) |
558 {'x': ueid}) |
559 |
559 |
560 def test_complex_ambigous(self): |
560 def test_complex_ambigous(self): |
561 """retrieve EUser X from system and ldap sources, Person X from system source only |
561 """retrieve CWUser X from system and ldap sources, Person X from system source only |
562 """ |
562 """ |
563 self._test('Any X,F WHERE X firstname F', |
563 self._test('Any X,F WHERE X firstname F', |
564 [('UnionStep', None, None, [ |
564 [('UnionStep', None, None, [ |
565 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is EUser', |
565 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is CWUser', |
566 [{'X': 'EUser', 'F': 'String'}])], |
566 [{'X': 'CWUser', 'F': 'String'}])], |
567 None, None, [self.ldap, self.system], {}, []), |
567 None, None, [self.ldap, self.system], {}, []), |
568 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is Personne', |
568 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is Personne', |
569 [{'X': 'Personne', 'F': 'String'}])], |
569 [{'X': 'Personne', 'F': 'String'}])], |
570 None, None, [self.system], {}, []), |
570 None, None, [self.system], {}, []), |
571 ]), |
571 ]), |
572 ]) |
572 ]) |
573 |
573 |
574 def test_complex_ambigous_limit_offset(self): |
574 def test_complex_ambigous_limit_offset(self): |
575 """retrieve EUser X from system and ldap sources, Person X from system source only |
575 """retrieve CWUser X from system and ldap sources, Person X from system source only |
576 """ |
576 """ |
577 self._test('Any X,F LIMIT 10 OFFSET 10 WHERE X firstname F', |
577 self._test('Any X,F LIMIT 10 OFFSET 10 WHERE X firstname F', |
578 [('UnionStep', 10, 10, [ |
578 [('UnionStep', 10, 10, [ |
579 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is EUser', |
579 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is CWUser', |
580 [{'X': 'EUser', 'F': 'String'}])], |
580 [{'X': 'CWUser', 'F': 'String'}])], |
581 None, None, |
581 None, None, |
582 [self.ldap, self.system], {}, []), |
582 [self.ldap, self.system], {}, []), |
583 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is Personne', |
583 ('OneFetchStep', [('Any X,F WHERE X firstname F, X is Personne', |
584 [{'X': 'Personne', 'F': 'String'}])], |
584 [{'X': 'Personne', 'F': 'String'}])], |
585 None, None, [self.system], {}, []), |
585 None, None, [self.system], {}, []), |
586 ]), |
586 ]), |
587 ]) |
587 ]) |
588 |
588 |
589 def test_complex_ambigous_ordered(self): |
589 def test_complex_ambigous_ordered(self): |
590 """ |
590 """ |
591 1. retrieve EUser X from system and ldap sources, Person X from system source only, store |
591 1. retrieve CWUser X from system and ldap sources, Person X from system source only, store |
592 each result in the same temp table |
592 each result in the same temp table |
593 2. return content of the table sorted |
593 2. return content of the table sorted |
594 """ |
594 """ |
595 self._test('Any X,F ORDERBY F WHERE X firstname F', |
595 self._test('Any X,F ORDERBY F WHERE X firstname F', |
596 [('AggrStep', 'Any X,F ORDERBY F', None, None, 'table0', None, |
596 [('AggrStep', 'Any X,F ORDERBY F', None, None, 'table0', None, |
597 [('FetchStep', [('Any X,F WHERE X firstname F, X is EUser', |
597 [('FetchStep', [('Any X,F WHERE X firstname F, X is CWUser', |
598 [{'X': 'EUser', 'F': 'String'}])], |
598 [{'X': 'CWUser', 'F': 'String'}])], |
599 [self.ldap, self.system], {}, |
599 [self.ldap, self.system], {}, |
600 {'X': 'table0.C0', 'X.firstname': 'table0.C1', 'F': 'table0.C1'}, []), |
600 {'X': 'table0.C0', 'X.firstname': 'table0.C1', 'F': 'table0.C1'}, []), |
601 ('FetchStep', [('Any X,F WHERE X firstname F, X is Personne', |
601 ('FetchStep', [('Any X,F WHERE X firstname F, X is Personne', |
602 [{'X': 'Personne', 'F': 'String'}])], |
602 [{'X': 'Personne', 'F': 'String'}])], |
603 [self.system], {}, |
603 [self.system], {}, |
681 |
681 |
682 def test_complex_optional(self): |
682 def test_complex_optional(self): |
683 ueid = self.session.user.eid |
683 ueid = self.session.user.eid |
684 self._test('Any U WHERE WF wf_info_for X, X eid %(x)s, WF owned_by U?, WF from_state FS', |
684 self._test('Any U WHERE WF wf_info_for X, X eid %(x)s, WF owned_by U?, WF from_state FS', |
685 [('OneFetchStep', [('Any U WHERE WF wf_info_for 5, WF owned_by U?, WF from_state FS', |
685 [('OneFetchStep', [('Any U WHERE WF wf_info_for 5, WF owned_by U?, WF from_state FS', |
686 [{'WF': 'TrInfo', 'FS': 'State', 'U': 'EUser'}])], |
686 [{'WF': 'TrInfo', 'FS': 'State', 'U': 'CWUser'}])], |
687 None, None, [self.system], {}, [])], |
687 None, None, [self.system], {}, [])], |
688 {'x': ueid}) |
688 {'x': ueid}) |
689 |
689 |
690 def test_complex_optional(self): |
690 def test_complex_optional(self): |
691 ueid = self.session.user.eid |
691 ueid = self.session.user.eid |
692 self._test('Any U WHERE WF wf_info_for X, X eid %(x)s, WF owned_by U?, WF from_state FS', |
692 self._test('Any U WHERE WF wf_info_for X, X eid %(x)s, WF owned_by U?, WF from_state FS', |
693 [('OneFetchStep', [('Any U WHERE WF wf_info_for 5, WF owned_by U?, WF from_state FS', |
693 [('OneFetchStep', [('Any U WHERE WF wf_info_for 5, WF owned_by U?, WF from_state FS', |
694 [{'WF': 'TrInfo', 'FS': 'State', 'U': 'EUser'}])], |
694 [{'WF': 'TrInfo', 'FS': 'State', 'U': 'CWUser'}])], |
695 None, None, [self.system], {}, [])], |
695 None, None, [self.system], {}, [])], |
696 {'x': ueid}) |
696 {'x': ueid}) |
697 |
697 |
698 |
698 |
699 def test_3sources_ambigous(self): |
699 def test_3sources_ambigous(self): |
700 self._test('Any X,T WHERE X owned_by U, U login "syt", X title T', |
700 self._test('Any X,T WHERE X owned_by U, U login "syt", X title T', |
701 [('FetchStep', [('Any X,T WHERE X title T, X is Card', [{'X': 'Card', 'T': 'String'}])], |
701 [('FetchStep', [('Any X,T WHERE X title T, X is Card', [{'X': 'Card', 'T': 'String'}])], |
702 [self.rql, self.system], None, |
702 [self.rql, self.system], None, |
703 {'T': 'table0.C1', 'X': 'table0.C0', 'X.title': 'table0.C1'}, []), |
703 {'T': 'table0.C1', 'X': 'table0.C0', 'X.title': 'table0.C1'}, []), |
704 ('FetchStep', [('Any U WHERE U login "syt", U is EUser', [{'U': 'EUser'}])], |
704 ('FetchStep', [('Any U WHERE U login "syt", U is CWUser', [{'U': 'CWUser'}])], |
705 [self.ldap, self.system], None, |
705 [self.ldap, self.system], None, |
706 {'U': 'table1.C0'}, []), |
706 {'U': 'table1.C0'}, []), |
707 ('UnionStep', None, None, [ |
707 ('UnionStep', None, None, [ |
708 ('OneFetchStep', [('Any X,T WHERE X owned_by U, X title T, U is EUser, X is IN(Bookmark, EmailThread)', |
708 ('OneFetchStep', [('Any X,T WHERE X owned_by U, X title T, U is CWUser, X is IN(Bookmark, EmailThread)', |
709 [{'T': 'String', 'U': 'EUser', 'X': 'Bookmark'}, |
709 [{'T': 'String', 'U': 'CWUser', 'X': 'Bookmark'}, |
710 {'T': 'String', 'U': 'EUser', 'X': 'EmailThread'}])], |
710 {'T': 'String', 'U': 'CWUser', 'X': 'EmailThread'}])], |
711 None, None, [self.system], {'U': 'table1.C0'}, []), |
711 None, None, [self.system], {'U': 'table1.C0'}, []), |
712 ('OneFetchStep', [('Any X,T WHERE X owned_by U, X title T, U is EUser, X is Card', |
712 ('OneFetchStep', [('Any X,T WHERE X owned_by U, X title T, U is CWUser, X is Card', |
713 [{'X': 'Card', 'U': 'EUser', 'T': 'String'}])], |
713 [{'X': 'Card', 'U': 'CWUser', 'T': 'String'}])], |
714 None, None, [self.system], |
714 None, None, [self.system], |
715 {'X': 'table0.C0', 'X.title': 'table0.C1', 'T': 'table0.C1', 'U': 'table1.C0'}, []), |
715 {'X': 'table0.C0', 'X.title': 'table0.C1', 'T': 'table0.C1', 'U': 'table1.C0'}, []), |
716 ]), |
716 ]), |
717 ]) |
717 ]) |
718 |
718 |
835 """a guest user trying to see another user: EXISTS(X owned_by U) is automatically inserted""" |
835 """a guest user trying to see another user: EXISTS(X owned_by U) is automatically inserted""" |
836 # use a guest user |
836 # use a guest user |
837 self.session = self._user_session()[1] |
837 self.session = self._user_session()[1] |
838 self._test('Any X WHERE X login "bla"', |
838 self._test('Any X WHERE X login "bla"', |
839 [('FetchStep', |
839 [('FetchStep', |
840 [('Any X WHERE X login "bla", X is EUser', [{'X': 'EUser'}])], |
840 [('Any X WHERE X login "bla", X is CWUser', [{'X': 'CWUser'}])], |
841 [self.ldap, self.system], None, {'X': 'table0.C0'}, []), |
841 [self.ldap, self.system], None, {'X': 'table0.C0'}, []), |
842 ('OneFetchStep', |
842 ('OneFetchStep', |
843 [('Any X WHERE EXISTS(X owned_by 5), X is EUser', [{'X': 'EUser'}])], |
843 [('Any X WHERE EXISTS(X owned_by 5), X is CWUser', [{'X': 'CWUser'}])], |
844 None, None, [self.system], {'X': 'table0.C0'}, [])]) |
844 None, None, [self.system], {'X': 'table0.C0'}, [])]) |
845 |
845 |
846 def test_security_complex_has_text(self): |
846 def test_security_complex_has_text(self): |
847 # use a guest user |
847 # use a guest user |
848 self.session = self._user_session()[1] |
848 self.session = self._user_session()[1] |
849 self._test('Any X WHERE X has_text "bla", X firstname "bla"', |
849 self._test('Any X WHERE X has_text "bla", X firstname "bla"', |
850 [('FetchStep', [('Any X WHERE X firstname "bla", X is EUser', [{'X': 'EUser'}])], |
850 [('FetchStep', [('Any X WHERE X firstname "bla", X is CWUser', [{'X': 'CWUser'}])], |
851 [self.ldap, self.system], None, {'X': 'table0.C0'}, []), |
851 [self.ldap, self.system], None, {'X': 'table0.C0'}, []), |
852 ('UnionStep', None, None, [ |
852 ('UnionStep', None, None, [ |
853 ('OneFetchStep', [('Any X WHERE X has_text "bla", EXISTS(X owned_by 5), X is EUser', [{'X': 'EUser'}])], |
853 ('OneFetchStep', [('Any X WHERE X has_text "bla", EXISTS(X owned_by 5), X is CWUser', [{'X': 'CWUser'}])], |
854 None, None, [self.system], {'X': 'table0.C0'}, []), |
854 None, None, [self.system], {'X': 'table0.C0'}, []), |
855 ('OneFetchStep', [('Any X WHERE X has_text "bla", X firstname "bla", X is Personne', [{'X': 'Personne'}])], |
855 ('OneFetchStep', [('Any X WHERE X has_text "bla", X firstname "bla", X is Personne', [{'X': 'Personne'}])], |
856 None, None, [self.system], {}, []), |
856 None, None, [self.system], {}, []), |
857 ]), |
857 ]), |
858 ]) |
858 ]) |
859 |
859 |
860 def test_security_complex_has_text_limit_offset(self): |
860 def test_security_complex_has_text_limit_offset(self): |
861 # use a guest user |
861 # use a guest user |
862 self.session = self._user_session()[1] |
862 self.session = self._user_session()[1] |
863 self._test('Any X LIMIT 10 OFFSET 10 WHERE X has_text "bla", X firstname "bla"', |
863 self._test('Any X LIMIT 10 OFFSET 10 WHERE X has_text "bla", X firstname "bla"', |
864 [('FetchStep', [('Any X WHERE X firstname "bla", X is EUser', [{'X': 'EUser'}])], |
864 [('FetchStep', [('Any X WHERE X firstname "bla", X is CWUser', [{'X': 'CWUser'}])], |
865 [self.ldap, self.system], None, {'X': 'table1.C0'}, []), |
865 [self.ldap, self.system], None, {'X': 'table1.C0'}, []), |
866 ('UnionFetchStep', [ |
866 ('UnionFetchStep', [ |
867 ('FetchStep', [('Any X WHERE X has_text "bla", EXISTS(X owned_by 5), X is EUser', [{'X': 'EUser'}])], |
867 ('FetchStep', [('Any X WHERE X has_text "bla", EXISTS(X owned_by 5), X is CWUser', [{'X': 'CWUser'}])], |
868 [self.system], {'X': 'table1.C0'}, {'X': 'table0.C0'}, []), |
868 [self.system], {'X': 'table1.C0'}, {'X': 'table0.C0'}, []), |
869 ('FetchStep', [('Any X WHERE X has_text "bla", X firstname "bla", X is Personne', [{'X': 'Personne'}])], |
869 ('FetchStep', [('Any X WHERE X has_text "bla", X firstname "bla", X is Personne', [{'X': 'Personne'}])], |
870 [self.system], {}, {'X': 'table0.C0'}, []), |
870 [self.system], {}, {'X': 'table0.C0'}, []), |
871 ]), |
871 ]), |
872 ('OneFetchStep', |
872 ('OneFetchStep', |
873 [('Any X LIMIT 10 OFFSET 10', [{'X': 'EUser'}, {'X': 'Personne'}])], |
873 [('Any X LIMIT 10 OFFSET 10', [{'X': 'CWUser'}, {'X': 'Personne'}])], |
874 10, 10, [self.system], {'X': 'table0.C0'}, []) |
874 10, 10, [self.system], {'X': 'table0.C0'}, []) |
875 ]) |
875 ]) |
876 |
876 |
877 def test_security_complex_aggregat(self): |
877 def test_security_complex_aggregat(self): |
878 # use a guest user |
878 # use a guest user |
879 self.session = self._user_session()[1] |
879 self.session = self._user_session()[1] |
880 self._test('Any MAX(X)', |
880 self._test('Any MAX(X)', |
881 [('FetchStep', [('Any E WHERE E type "X", E is Note', [{'E': 'Note'}])], |
881 [('FetchStep', [('Any E WHERE E type "X", E is Note', [{'E': 'Note'}])], |
882 [self.rql, self.system], None, {'E': 'table1.C0'}, []), |
882 [self.rql, self.system], None, {'E': 'table1.C0'}, []), |
883 ('FetchStep', [('Any X WHERE X is EUser', [{'X': 'EUser'}])], |
883 ('FetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])], |
884 [self.ldap, self.system], None, {'X': 'table2.C0'}, []), |
884 [self.ldap, self.system], None, {'X': 'table2.C0'}, []), |
885 ('UnionFetchStep', [ |
885 ('UnionFetchStep', [ |
886 ('FetchStep', [('Any X WHERE EXISTS(X owned_by 5), X is Basket', [{'X': 'Basket'}])], |
886 ('FetchStep', [('Any X WHERE EXISTS(X owned_by 5), X is Basket', [{'X': 'Basket'}])], |
887 [self.system], {}, {'X': 'table0.C0'}, []), |
887 [self.system], {}, {'X': 'table0.C0'}, []), |
888 ('UnionFetchStep', |
888 ('UnionFetchStep', |
889 [('FetchStep', [('Any X WHERE X is IN(Card, Note, State)', |
889 [('FetchStep', [('Any X WHERE X is IN(Card, Note, State)', |
890 [{'X': 'Card'}, {'X': 'Note'}, {'X': 'State'}])], |
890 [{'X': 'Card'}, {'X': 'Note'}, {'X': 'State'}])], |
891 [self.rql, self.system], {}, {'X': 'table0.C0'}, []), |
891 [self.rql, self.system], {}, {'X': 'table0.C0'}, []), |
892 ('FetchStep', |
892 ('FetchStep', |
893 [('Any X WHERE X is IN(Bookmark, Comment, Division, ECache, EConstraint, EConstraintType, EEType, EFRDef, EGroup, ENFRDef, EPermission, EProperty, ERType, Email, EmailAddress, EmailPart, EmailThread, File, Folder, Image, Personne, RQLExpression, Societe, SubDivision, Tag, TrInfo, Transition)', |
893 [('Any X WHERE X is IN(Bookmark, Comment, Division, CWCache, CWConstraint, CWConstraintType, CWEType, CWAttribute, CWGroup, CWRelation, CWPermission, CWProperty, CWRType, Email, EmailAddress, EmailPart, EmailThread, File, Folder, Image, Personne, RQLExpression, Societe, SubDivision, Tag, TrInfo, Transition)', |
894 sorted([{'X': 'Bookmark'}, {'X': 'Comment'}, {'X': 'Division'}, |
894 sorted([{'X': 'Bookmark'}, {'X': 'Comment'}, {'X': 'Division'}, |
895 {'X': 'ECache'}, {'X': 'EConstraint'}, {'X': 'EConstraintType'}, |
895 {'X': 'CWCache'}, {'X': 'CWConstraint'}, {'X': 'CWConstraintType'}, |
896 {'X': 'EEType'}, {'X': 'EFRDef'}, {'X': 'EGroup'}, |
896 {'X': 'CWEType'}, {'X': 'CWAttribute'}, {'X': 'CWGroup'}, |
897 {'X': 'ENFRDef'}, {'X': 'EPermission'}, {'X': 'EProperty'}, |
897 {'X': 'CWRelation'}, {'X': 'CWPermission'}, {'X': 'CWProperty'}, |
898 {'X': 'ERType'}, {'X': 'Email'}, {'X': 'EmailAddress'}, |
898 {'X': 'CWRType'}, {'X': 'Email'}, {'X': 'EmailAddress'}, |
899 {'X': 'EmailPart'}, {'X': 'EmailThread'}, {'X': 'File'}, |
899 {'X': 'EmailPart'}, {'X': 'EmailThread'}, {'X': 'File'}, |
900 {'X': 'Folder'}, {'X': 'Image'}, {'X': 'Personne'}, |
900 {'X': 'Folder'}, {'X': 'Image'}, {'X': 'Personne'}, |
901 {'X': 'RQLExpression'}, {'X': 'Societe'}, {'X': 'SubDivision'}, |
901 {'X': 'RQLExpression'}, {'X': 'Societe'}, {'X': 'SubDivision'}, |
902 {'X': 'Tag'}, {'X': 'TrInfo'}, {'X': 'Transition'}]))], |
902 {'X': 'Tag'}, {'X': 'TrInfo'}, {'X': 'Transition'}]))], |
903 [self.system], {}, {'X': 'table0.C0'}, []), |
903 [self.system], {}, {'X': 'table0.C0'}, []), |
904 ]), |
904 ]), |
905 ('FetchStep', [('Any X WHERE EXISTS(X owned_by 5), X is EUser', [{'X': 'EUser'}])], |
905 ('FetchStep', [('Any X WHERE EXISTS(X owned_by 5), X is CWUser', [{'X': 'CWUser'}])], |
906 [self.system], {'X': 'table2.C0'}, {'X': 'table0.C0'}, []), |
906 [self.system], {'X': 'table2.C0'}, {'X': 'table0.C0'}, []), |
907 ('FetchStep', [('Any X WHERE (EXISTS(X owned_by 5)) OR ((((EXISTS(D concerne C?, C owned_by 5, C type "X", X identity D, C is Division, D is Affaire)) OR (EXISTS(H concerne G?, G owned_by 5, G type "X", X identity H, G is SubDivision, H is Affaire))) OR (EXISTS(I concerne F?, F owned_by 5, F type "X", X identity I, F is Societe, I is Affaire))) OR (EXISTS(J concerne E?, E owned_by 5, X identity J, E is Note, J is Affaire))), X is Affaire', |
907 ('FetchStep', [('Any X WHERE (EXISTS(X owned_by 5)) OR ((((EXISTS(D concerne C?, C owned_by 5, C type "X", X identity D, C is Division, D is Affaire)) OR (EXISTS(H concerne G?, G owned_by 5, G type "X", X identity H, G is SubDivision, H is Affaire))) OR (EXISTS(I concerne F?, F owned_by 5, F type "X", X identity I, F is Societe, I is Affaire))) OR (EXISTS(J concerne E?, E owned_by 5, X identity J, E is Note, J is Affaire))), X is Affaire', |
908 [{'C': 'Division', 'E': 'Note', 'D': 'Affaire', 'G': 'SubDivision', 'F': 'Societe', 'I': 'Affaire', 'H': 'Affaire', 'J': 'Affaire', 'X': 'Affaire'}])], |
908 [{'C': 'Division', 'E': 'Note', 'D': 'Affaire', 'G': 'SubDivision', 'F': 'Societe', 'I': 'Affaire', 'H': 'Affaire', 'J': 'Affaire', 'X': 'Affaire'}])], |
909 [self.system], {'E': 'table1.C0'}, {'X': 'table0.C0'}, []), |
909 [self.system], {'E': 'table1.C0'}, {'X': 'table0.C0'}, []), |
910 ]), |
910 ]), |
919 [('FetchStep', [('Any X WHERE X is IN(Card, Note, State)', |
919 [('FetchStep', [('Any X WHERE X is IN(Card, Note, State)', |
920 [{'X': 'Card'}, {'X': 'Note'}, {'X': 'State'}])], |
920 [{'X': 'Card'}, {'X': 'Note'}, {'X': 'State'}])], |
921 [self.rql, self.system], None, {'X': 'table1.C0'}, []), |
921 [self.rql, self.system], None, {'X': 'table1.C0'}, []), |
922 ('FetchStep', [('Any E WHERE E type "X", E is Note', [{'E': 'Note'}])], |
922 ('FetchStep', [('Any E WHERE E type "X", E is Note', [{'E': 'Note'}])], |
923 [self.rql, self.system], None, {'E': 'table2.C0'}, []), |
923 [self.rql, self.system], None, {'E': 'table2.C0'}, []), |
924 ('FetchStep', [('Any X WHERE X is EUser', [{'X': 'EUser'}])], |
924 ('FetchStep', [('Any X WHERE X is CWUser', [{'X': 'CWUser'}])], |
925 [self.ldap, self.system], None, {'X': 'table3.C0'}, []), |
925 [self.ldap, self.system], None, {'X': 'table3.C0'}, []), |
926 ('UnionFetchStep', |
926 ('UnionFetchStep', |
927 [('FetchStep', [('Any ET,X WHERE X is ET, EXISTS(X owned_by 5), ET is EEType, X is Basket', |
927 [('FetchStep', [('Any ET,X WHERE X is ET, EXISTS(X owned_by 5), ET is CWEType, X is Basket', |
928 [{'ET': 'EEType', 'X': 'Basket'}])], |
928 [{'ET': 'CWEType', 'X': 'Basket'}])], |
929 [self.system], {}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
929 [self.system], {}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
930 ('FetchStep', [('Any ET,X WHERE X is ET, (EXISTS(X owned_by 5)) OR ((((EXISTS(D concerne C?, C owned_by 5, C type "X", X identity D, C is Division, D is Affaire)) OR (EXISTS(H concerne G?, G owned_by 5, G type "X", X identity H, G is SubDivision, H is Affaire))) OR (EXISTS(I concerne F?, F owned_by 5, F type "X", X identity I, F is Societe, I is Affaire))) OR (EXISTS(J concerne E?, E owned_by 5, X identity J, E is Note, J is Affaire))), ET is EEType, X is Affaire', |
930 ('FetchStep', [('Any ET,X WHERE X is ET, (EXISTS(X owned_by 5)) OR ((((EXISTS(D concerne C?, C owned_by 5, C type "X", X identity D, C is Division, D is Affaire)) OR (EXISTS(H concerne G?, G owned_by 5, G type "X", X identity H, G is SubDivision, H is Affaire))) OR (EXISTS(I concerne F?, F owned_by 5, F type "X", X identity I, F is Societe, I is Affaire))) OR (EXISTS(J concerne E?, E owned_by 5, X identity J, E is Note, J is Affaire))), ET is CWEType, X is Affaire', |
931 [{'C': 'Division', 'E': 'Note', 'D': 'Affaire', |
931 [{'C': 'Division', 'E': 'Note', 'D': 'Affaire', |
932 'G': 'SubDivision', 'F': 'Societe', 'I': 'Affaire', |
932 'G': 'SubDivision', 'F': 'Societe', 'I': 'Affaire', |
933 'H': 'Affaire', 'J': 'Affaire', 'X': 'Affaire', |
933 'H': 'Affaire', 'J': 'Affaire', 'X': 'Affaire', |
934 'ET': 'EEType'}])], |
934 'ET': 'CWEType'}])], |
935 [self.system], {'E': 'table2.C0'}, {'ET': 'table0.C0', 'X': 'table0.C1'}, |
935 [self.system], {'E': 'table2.C0'}, {'ET': 'table0.C0', 'X': 'table0.C1'}, |
936 []), |
936 []), |
937 ('FetchStep', [('Any ET,X WHERE X is ET, EXISTS(X owned_by 5), ET is EEType, X is EUser', |
937 ('FetchStep', [('Any ET,X WHERE X is ET, EXISTS(X owned_by 5), ET is CWEType, X is CWUser', |
938 [{'ET': 'EEType', 'X': 'EUser'}])], |
938 [{'ET': 'CWEType', 'X': 'CWUser'}])], |
939 [self.system], {'X': 'table3.C0'}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
939 [self.system], {'X': 'table3.C0'}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
940 # extra UnionFetchStep could be avoided but has no cost, so don't care |
940 # extra UnionFetchStep could be avoided but has no cost, so don't care |
941 ('UnionFetchStep', |
941 ('UnionFetchStep', |
942 [('FetchStep', [('Any ET,X WHERE X is ET, ET is EEType, X is IN(Bookmark, Comment, Division, ECache, EConstraint, EConstraintType, EEType, EFRDef, EGroup, ENFRDef, EPermission, EProperty, ERType, Email, EmailAddress, EmailPart, EmailThread, File, Folder, Image, Personne, RQLExpression, Societe, SubDivision, Tag, TrInfo, Transition)', |
942 [('FetchStep', [('Any ET,X WHERE X is ET, ET is CWEType, X is IN(Bookmark, Comment, Division, CWCache, CWConstraint, CWConstraintType, CWEType, CWAttribute, CWGroup, CWRelation, CWPermission, CWProperty, CWRType, Email, EmailAddress, EmailPart, EmailThread, File, Folder, Image, Personne, RQLExpression, Societe, SubDivision, Tag, TrInfo, Transition)', |
943 [{'X': 'Bookmark', 'ET': 'EEType'}, {'X': 'Comment', 'ET': 'EEType'}, |
943 [{'X': 'Bookmark', 'ET': 'CWEType'}, {'X': 'Comment', 'ET': 'CWEType'}, |
944 {'X': 'Division', 'ET': 'EEType'}, {'X': 'ECache', 'ET': 'EEType'}, |
944 {'X': 'Division', 'ET': 'CWEType'}, {'X': 'CWCache', 'ET': 'CWEType'}, |
945 {'X': 'EConstraint', 'ET': 'EEType'}, {'X': 'EConstraintType', 'ET': 'EEType'}, |
945 {'X': 'CWConstraint', 'ET': 'CWEType'}, {'X': 'CWConstraintType', 'ET': 'CWEType'}, |
946 {'X': 'EEType', 'ET': 'EEType'}, {'X': 'EFRDef', 'ET': 'EEType'}, |
946 {'X': 'CWEType', 'ET': 'CWEType'}, {'X': 'CWAttribute', 'ET': 'CWEType'}, |
947 {'X': 'EGroup', 'ET': 'EEType'}, {'X': 'ENFRDef', 'ET': 'EEType'}, |
947 {'X': 'CWGroup', 'ET': 'CWEType'}, {'X': 'CWRelation', 'ET': 'CWEType'}, |
948 {'X': 'EPermission', 'ET': 'EEType'}, {'X': 'EProperty', 'ET': 'EEType'}, |
948 {'X': 'CWPermission', 'ET': 'CWEType'}, {'X': 'CWProperty', 'ET': 'CWEType'}, |
949 {'X': 'ERType', 'ET': 'EEType'}, {'X': 'Email', 'ET': 'EEType'}, |
949 {'X': 'CWRType', 'ET': 'CWEType'}, {'X': 'Email', 'ET': 'CWEType'}, |
950 {'X': 'EmailAddress', 'ET': 'EEType'}, {'X': 'EmailPart', 'ET': 'EEType'}, |
950 {'X': 'EmailAddress', 'ET': 'CWEType'}, {'X': 'EmailPart', 'ET': 'CWEType'}, |
951 {'X': 'EmailThread', 'ET': 'EEType'}, {'X': 'File', 'ET': 'EEType'}, |
951 {'X': 'EmailThread', 'ET': 'CWEType'}, {'X': 'File', 'ET': 'CWEType'}, |
952 {'X': 'Folder', 'ET': 'EEType'}, {'X': 'Image', 'ET': 'EEType'}, |
952 {'X': 'Folder', 'ET': 'CWEType'}, {'X': 'Image', 'ET': 'CWEType'}, |
953 {'X': 'Personne', 'ET': 'EEType'}, {'X': 'RQLExpression', 'ET': 'EEType'}, |
953 {'X': 'Personne', 'ET': 'CWEType'}, {'X': 'RQLExpression', 'ET': 'CWEType'}, |
954 {'X': 'Societe', 'ET': 'EEType'}, {'X': 'SubDivision', 'ET': 'EEType'}, |
954 {'X': 'Societe', 'ET': 'CWEType'}, {'X': 'SubDivision', 'ET': 'CWEType'}, |
955 {'X': 'Tag', 'ET': 'EEType'}, {'X': 'TrInfo', 'ET': 'EEType'}, |
955 {'X': 'Tag', 'ET': 'CWEType'}, {'X': 'TrInfo', 'ET': 'CWEType'}, |
956 {'X': 'Transition', 'ET': 'EEType'}])], |
956 {'X': 'Transition', 'ET': 'CWEType'}])], |
957 [self.system], {}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
957 [self.system], {}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
958 ('FetchStep', |
958 ('FetchStep', |
959 [('Any ET,X WHERE X is ET, ET is EEType, X is IN(Card, Note, State)', |
959 [('Any ET,X WHERE X is ET, ET is CWEType, X is IN(Card, Note, State)', |
960 [{'ET': 'EEType', 'X': 'Card'}, |
960 [{'ET': 'CWEType', 'X': 'Card'}, |
961 {'ET': 'EEType', 'X': 'Note'}, |
961 {'ET': 'CWEType', 'X': 'Note'}, |
962 {'ET': 'EEType', 'X': 'State'}])], |
962 {'ET': 'CWEType', 'X': 'State'}])], |
963 [self.system], {'X': 'table1.C0'}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
963 [self.system], {'X': 'table1.C0'}, {'ET': 'table0.C0', 'X': 'table0.C1'}, []), |
964 ]), |
964 ]), |
965 ]), |
965 ]), |
966 ('OneFetchStep', |
966 ('OneFetchStep', |
967 [('Any ET,COUNT(X) GROUPBY ET ORDERBY ET', |
967 [('Any ET,COUNT(X) GROUPBY ET ORDERBY ET', |
968 sorted([{'ET': 'EEType', 'X': 'Affaire'}, {'ET': 'EEType', 'X': 'Basket'}, |
968 sorted([{'ET': 'CWEType', 'X': 'Affaire'}, {'ET': 'CWEType', 'X': 'Basket'}, |
969 {'ET': 'EEType', 'X': 'Bookmark'}, {'ET': 'EEType', 'X': 'Card'}, |
969 {'ET': 'CWEType', 'X': 'Bookmark'}, {'ET': 'CWEType', 'X': 'Card'}, |
970 {'ET': 'EEType', 'X': 'Comment'}, {'ET': 'EEType', 'X': 'Division'}, |
970 {'ET': 'CWEType', 'X': 'Comment'}, {'ET': 'CWEType', 'X': 'Division'}, |
971 {'ET': 'EEType', 'X': 'ECache'}, {'ET': 'EEType', 'X': 'EConstraint'}, |
971 {'ET': 'CWEType', 'X': 'CWCache'}, {'ET': 'CWEType', 'X': 'CWConstraint'}, |
972 {'ET': 'EEType', 'X': 'EConstraintType'}, {'ET': 'EEType', 'X': 'EEType'}, |
972 {'ET': 'CWEType', 'X': 'CWConstraintType'}, {'ET': 'CWEType', 'X': 'CWEType'}, |
973 {'ET': 'EEType', 'X': 'EFRDef'}, {'ET': 'EEType', 'X': 'EGroup'}, |
973 {'ET': 'CWEType', 'X': 'CWAttribute'}, {'ET': 'CWEType', 'X': 'CWGroup'}, |
974 {'ET': 'EEType', 'X': 'ENFRDef'}, {'ET': 'EEType', 'X': 'EPermission'}, |
974 {'ET': 'CWEType', 'X': 'CWRelation'}, {'ET': 'CWEType', 'X': 'CWPermission'}, |
975 {'ET': 'EEType', 'X': 'EProperty'}, {'ET': 'EEType', 'X': 'ERType'}, |
975 {'ET': 'CWEType', 'X': 'CWProperty'}, {'ET': 'CWEType', 'X': 'CWRType'}, |
976 {'ET': 'EEType', 'X': 'EUser'}, {'ET': 'EEType', 'X': 'Email'}, |
976 {'ET': 'CWEType', 'X': 'CWUser'}, {'ET': 'CWEType', 'X': 'Email'}, |
977 {'ET': 'EEType', 'X': 'EmailAddress'}, {'ET': 'EEType', 'X': 'EmailPart'}, |
977 {'ET': 'CWEType', 'X': 'EmailAddress'}, {'ET': 'CWEType', 'X': 'EmailPart'}, |
978 {'ET': 'EEType', 'X': 'EmailThread'}, {'ET': 'EEType', 'X': 'File'}, |
978 {'ET': 'CWEType', 'X': 'EmailThread'}, {'ET': 'CWEType', 'X': 'File'}, |
979 {'ET': 'EEType', 'X': 'Folder'}, {'ET': 'EEType', 'X': 'Image'}, |
979 {'ET': 'CWEType', 'X': 'Folder'}, {'ET': 'CWEType', 'X': 'Image'}, |
980 {'ET': 'EEType', 'X': 'Note'}, {'ET': 'EEType', 'X': 'Personne'}, |
980 {'ET': 'CWEType', 'X': 'Note'}, {'ET': 'CWEType', 'X': 'Personne'}, |
981 {'ET': 'EEType', 'X': 'RQLExpression'}, {'ET': 'EEType', 'X': 'Societe'}, |
981 {'ET': 'CWEType', 'X': 'RQLExpression'}, {'ET': 'CWEType', 'X': 'Societe'}, |
982 {'ET': 'EEType', 'X': 'State'}, {'ET': 'EEType', 'X': 'SubDivision'}, |
982 {'ET': 'CWEType', 'X': 'State'}, {'ET': 'CWEType', 'X': 'SubDivision'}, |
983 {'ET': 'EEType', 'X': 'Tag'}, {'ET': 'EEType', 'X': 'TrInfo'}, |
983 {'ET': 'CWEType', 'X': 'Tag'}, {'ET': 'CWEType', 'X': 'TrInfo'}, |
984 {'ET': 'EEType', 'X': 'Transition'}]))], |
984 {'ET': 'CWEType', 'X': 'Transition'}]))], |
985 None, None, [self.system], {'ET': 'table0.C0', 'X': 'table0.C1'}, []) |
985 None, None, [self.system], {'ET': 'table0.C0', 'X': 'table0.C1'}, []) |
986 ]) |
986 ]) |
987 |
987 |
988 def test_security_3sources(self): |
988 def test_security_3sources(self): |
989 # use a guest user |
989 # use a guest user |
1044 self._test('Any X, XT LIMIT 10 OFFSET 10 WHERE X is Card, X owned_by U, X title XT, U login "syt"', |
1044 self._test('Any X, XT LIMIT 10 OFFSET 10 WHERE X is Card, X owned_by U, X title XT, U login "syt"', |
1045 [('FetchStep', |
1045 [('FetchStep', |
1046 [('Any X,XT WHERE X title XT, X is Card', [{'X': 'Card', 'XT': 'String'}])], |
1046 [('Any X,XT WHERE X title XT, X is Card', [{'X': 'Card', 'XT': 'String'}])], |
1047 [self.rql, self.system], None, {'X': 'table0.C0', 'X.title': 'table0.C1', 'XT': 'table0.C1'}, []), |
1047 [self.rql, self.system], None, {'X': 'table0.C0', 'X.title': 'table0.C1', 'XT': 'table0.C1'}, []), |
1048 ('FetchStep', |
1048 ('FetchStep', |
1049 [('Any U WHERE U login "syt", U is EUser', [{'U': 'EUser'}])], |
1049 [('Any U WHERE U login "syt", U is CWUser', [{'U': 'CWUser'}])], |
1050 [self.ldap, self.system], None, {'U': 'table1.C0'}, []), |
1050 [self.ldap, self.system], None, {'U': 'table1.C0'}, []), |
1051 ('OneFetchStep', |
1051 ('OneFetchStep', |
1052 [('Any X,XT LIMIT 10 OFFSET 10 WHERE X owned_by U, X title XT, EXISTS(U owned_by 5), U is EUser, X is Card', |
1052 [('Any X,XT LIMIT 10 OFFSET 10 WHERE X owned_by U, X title XT, EXISTS(U owned_by 5), U is CWUser, X is Card', |
1053 [{'X': 'Card', 'U': 'EUser', 'XT': 'String'}])], |
1053 [{'X': 'Card', 'U': 'CWUser', 'XT': 'String'}])], |
1054 10, 10, [self.system], |
1054 10, 10, [self.system], |
1055 {'X': 'table0.C0', 'X.title': 'table0.C1', 'XT': 'table0.C1', 'U': 'table1.C0'}, []) |
1055 {'X': 'table0.C0', 'X.title': 'table0.C1', 'XT': 'table0.C1', 'U': 'table1.C0'}, []) |
1056 ]) |
1056 ]) |
1057 |
1057 |
1058 def test_exists_base(self): |
1058 def test_exists_base(self): |
1059 self._test('Any X,L,S WHERE X in_state S, X login L, EXISTS(X in_group G, G name "bougloup")', |
1059 self._test('Any X,L,S WHERE X in_state S, X login L, EXISTS(X in_group G, G name "bougloup")', |
1060 [('FetchStep', [('Any X,L WHERE X login L, X is EUser', [{'X': 'EUser', 'L': 'String'}])], |
1060 [('FetchStep', [('Any X,L WHERE X login L, X is CWUser', [{'X': 'CWUser', 'L': 'String'}])], |
1061 [self.ldap, self.system], None, {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []), |
1061 [self.ldap, self.system], None, {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, []), |
1062 ('OneFetchStep', [("Any X,L,S WHERE X in_state S, X login L, " |
1062 ('OneFetchStep', [("Any X,L,S WHERE X in_state S, X login L, " |
1063 'EXISTS(X in_group G, G name "bougloup", G is EGroup), S is State, X is EUser', |
1063 'EXISTS(X in_group G, G name "bougloup", G is CWGroup), S is State, X is CWUser', |
1064 [{'X': 'EUser', 'L': 'String', 'S': 'State', 'G': 'EGroup'}])], |
1064 [{'X': 'CWUser', 'L': 'String', 'S': 'State', 'G': 'CWGroup'}])], |
1065 None, None, [self.system], |
1065 None, None, [self.system], |
1066 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, [])]) |
1066 {'X': 'table0.C0', 'X.login': 'table0.C1', 'L': 'table0.C1'}, [])]) |
1067 |
1067 |
1068 def test_exists_complex(self): |
1068 def test_exists_complex(self): |
1069 self._test('Any G WHERE X in_group G, G name "managers", EXISTS(X copain T, T login in ("comme", "cochon"))', |
1069 self._test('Any G WHERE X in_group G, G name "managers", EXISTS(X copain T, T login in ("comme", "cochon"))', |
1070 [('FetchStep', [('Any T WHERE T login IN("comme", "cochon"), T is EUser', [{'T': 'EUser'}])], |
1070 [('FetchStep', [('Any T WHERE T login IN("comme", "cochon"), T is CWUser', [{'T': 'CWUser'}])], |
1071 [self.ldap, self.system], None, {'T': 'table0.C0'}, []), |
1071 [self.ldap, self.system], None, {'T': 'table0.C0'}, []), |
1072 ('OneFetchStep', |
1072 ('OneFetchStep', |
1073 [('Any G WHERE X in_group G, G name "managers", EXISTS(X copain T, T is EUser), G is EGroup, X is EUser', |
1073 [('Any G WHERE X in_group G, G name "managers", EXISTS(X copain T, T is CWUser), G is CWGroup, X is CWUser', |
1074 [{'X': 'EUser', 'T': 'EUser', 'G': 'EGroup'}])], |
1074 [{'X': 'CWUser', 'T': 'CWUser', 'G': 'CWGroup'}])], |
1075 None, None, [self.system], {'T': 'table0.C0'}, [])]) |
1075 None, None, [self.system], {'T': 'table0.C0'}, [])]) |
1076 |
1076 |
1077 def test_exists3(self): |
1077 def test_exists3(self): |
1078 self._test('Any G,L WHERE X in_group G, X login L, G name "managers", EXISTS(X copain T, T login in ("comme", "cochon"))', |
1078 self._test('Any G,L WHERE X in_group G, X login L, G name "managers", EXISTS(X copain T, T login in ("comme", "cochon"))', |
1079 [('FetchStep', |
1079 [('FetchStep', |
1080 [('Any T WHERE T login IN("comme", "cochon"), T is EUser', |
1080 [('Any T WHERE T login IN("comme", "cochon"), T is CWUser', |
1081 [{'T': 'EUser'}])], |
1081 [{'T': 'CWUser'}])], |
1082 [self.ldap, self.system], None, {'T': 'table0.C0'}, []), |
1082 [self.ldap, self.system], None, {'T': 'table0.C0'}, []), |
1083 ('FetchStep', |
1083 ('FetchStep', |
1084 [('Any L,X WHERE X login L, X is EUser', [{'X': 'EUser', 'L': 'String'}])], |
1084 [('Any L,X WHERE X login L, X is CWUser', [{'X': 'CWUser', 'L': 'String'}])], |
1085 [self.ldap, self.system], None, |
1085 [self.ldap, self.system], None, |
1086 {'X': 'table1.C1', 'X.login': 'table1.C0', 'L': 'table1.C0'}, []), |
1086 {'X': 'table1.C1', 'X.login': 'table1.C0', 'L': 'table1.C0'}, []), |
1087 ('OneFetchStep', |
1087 ('OneFetchStep', |
1088 [('Any G,L WHERE X in_group G, X login L, G name "managers", EXISTS(X copain T, T is EUser), G is EGroup, X is EUser', |
1088 [('Any G,L WHERE X in_group G, X login L, G name "managers", EXISTS(X copain T, T is CWUser), G is CWGroup, X is CWUser', |
1089 [{'G': 'EGroup', 'L': 'String', 'T': 'EUser', 'X': 'EUser'}])], |
1089 [{'G': 'CWGroup', 'L': 'String', 'T': 'CWUser', 'X': 'CWUser'}])], |
1090 None, None, |
1090 None, None, |
1091 [self.system], {'T': 'table0.C0', 'X': 'table1.C1', 'X.login': 'table1.C0', 'L': 'table1.C0'}, [])]) |
1091 [self.system], {'T': 'table0.C0', 'X': 'table1.C1', 'X.login': 'table1.C0', 'L': 'table1.C0'}, [])]) |
1092 |
1092 |
1093 def test_exists4(self): |
1093 def test_exists4(self): |
1094 self._test('Any G,L WHERE X in_group G, X login L, G name "managers", ' |
1094 self._test('Any G,L WHERE X in_group G, X login L, G name "managers", ' |
1095 'EXISTS(X copain T, T login L, T login in ("comme", "cochon")) OR ' |
1095 'EXISTS(X copain T, T login L, T login in ("comme", "cochon")) OR ' |
1096 'EXISTS(X in_state S, S name "pascontent", NOT X copain T2, T2 login "billy")', |
1096 'EXISTS(X in_state S, S name "pascontent", NOT X copain T2, T2 login "billy")', |
1097 [('FetchStep', |
1097 [('FetchStep', |
1098 [('Any T,L WHERE T login L, T login IN("comme", "cochon"), T is EUser', [{'T': 'EUser', 'L': 'String'}])], |
1098 [('Any T,L WHERE T login L, T login IN("comme", "cochon"), T is CWUser', [{'T': 'CWUser', 'L': 'String'}])], |
1099 [self.ldap, self.system], None, |
1099 [self.ldap, self.system], None, |
1100 {'T': 'table0.C0', 'T.login': 'table0.C1', 'L': 'table0.C1'}, []), |
1100 {'T': 'table0.C0', 'T.login': 'table0.C1', 'L': 'table0.C1'}, []), |
1101 ('FetchStep', |
1101 ('FetchStep', |
1102 [('Any T2 WHERE T2 login "billy", T2 is EUser', [{'T2': 'EUser'}])], |
1102 [('Any T2 WHERE T2 login "billy", T2 is CWUser', [{'T2': 'CWUser'}])], |
1103 [self.ldap, self.system], None, {'T2': 'table1.C0'}, []), |
1103 [self.ldap, self.system], None, {'T2': 'table1.C0'}, []), |
1104 ('FetchStep', |
1104 ('FetchStep', |
1105 [('Any L,X WHERE X login L, X is EUser', [{'X': 'EUser', 'L': 'String'}])], |
1105 [('Any L,X WHERE X login L, X is CWUser', [{'X': 'CWUser', 'L': 'String'}])], |
1106 [self.ldap, self.system], None, {'X': 'table2.C1', 'X.login': 'table2.C0', 'L': 'table2.C0'}, []), |
1106 [self.ldap, self.system], None, {'X': 'table2.C1', 'X.login': 'table2.C0', 'L': 'table2.C0'}, []), |
1107 ('OneFetchStep', |
1107 ('OneFetchStep', |
1108 [('Any G,L WHERE X in_group G, X login L, G name "managers", (EXISTS(X copain T, T login L, T is EUser)) OR (EXISTS(X in_state S, S name "pascontent", NOT X copain T2, S is State, T2 is EUser)), G is EGroup, X is EUser', |
1108 [('Any G,L WHERE X in_group G, X login L, G name "managers", (EXISTS(X copain T, T login L, T is CWUser)) OR (EXISTS(X in_state S, S name "pascontent", NOT X copain T2, S is State, T2 is CWUser)), G is CWGroup, X is CWUser', |
1109 [{'G': 'EGroup', 'L': 'String', 'S': 'State', 'T': 'EUser', 'T2': 'EUser', 'X': 'EUser'}])], |
1109 [{'G': 'CWGroup', 'L': 'String', 'S': 'State', 'T': 'CWUser', 'T2': 'CWUser', 'X': 'CWUser'}])], |
1110 None, None, [self.system], |
1110 None, None, [self.system], |
1111 {'T2': 'table1.C0', 'L': 'table2.C0', |
1111 {'T2': 'table1.C0', 'L': 'table2.C0', |
1112 'T': 'table0.C0', 'T.login': 'table0.C1', 'X': 'table2.C1', 'X.login': 'table2.C0'}, [])]) |
1112 'T': 'table0.C0', 'T.login': 'table0.C1', 'X': 'table2.C1', 'X.login': 'table2.C0'}, [])]) |
1113 |
1113 |
1114 def test_exists5(self): |
1114 def test_exists5(self): |
1115 self._test('Any GN,L WHERE X in_group G, X login L, G name GN, ' |
1115 self._test('Any GN,L WHERE X in_group G, X login L, G name GN, ' |
1116 'EXISTS(X copain T, T login in ("comme", "cochon")) AND ' |
1116 'EXISTS(X copain T, T login in ("comme", "cochon")) AND ' |
1117 'NOT EXISTS(X copain T2, T2 login "billy")', |
1117 'NOT EXISTS(X copain T2, T2 login "billy")', |
1118 [('FetchStep', [('Any T WHERE T login IN("comme", "cochon"), T is EUser', |
1118 [('FetchStep', [('Any T WHERE T login IN("comme", "cochon"), T is CWUser', |
1119 [{'T': 'EUser'}])], |
1119 [{'T': 'CWUser'}])], |
1120 [self.ldap, self.system], None, {'T': 'table0.C0'}, []), |
1120 [self.ldap, self.system], None, {'T': 'table0.C0'}, []), |
1121 ('FetchStep', [('Any T2 WHERE T2 login "billy", T2 is EUser', [{'T2': 'EUser'}])], |
1121 ('FetchStep', [('Any T2 WHERE T2 login "billy", T2 is CWUser', [{'T2': 'CWUser'}])], |
1122 [self.ldap, self.system], None, {'T2': 'table1.C0'}, []), |
1122 [self.ldap, self.system], None, {'T2': 'table1.C0'}, []), |
1123 ('FetchStep', [('Any L,X WHERE X login L, X is EUser', [{'X': 'EUser', 'L': 'String'}])], |
1123 ('FetchStep', [('Any L,X WHERE X login L, X is CWUser', [{'X': 'CWUser', 'L': 'String'}])], |
1124 [self.ldap, self.system], None, |
1124 [self.ldap, self.system], None, |
1125 {'X': 'table2.C1', 'X.login': 'table2.C0', 'L': 'table2.C0'}, []), |
1125 {'X': 'table2.C1', 'X.login': 'table2.C0', 'L': 'table2.C0'}, []), |
1126 ('OneFetchStep', [('Any GN,L WHERE X in_group G, X login L, G name GN, EXISTS(X copain T, T is EUser), NOT EXISTS(X copain T2, T2 is EUser), G is EGroup, X is EUser', |
1126 ('OneFetchStep', [('Any GN,L WHERE X in_group G, X login L, G name GN, EXISTS(X copain T, T is CWUser), NOT EXISTS(X copain T2, T2 is CWUser), G is CWGroup, X is CWUser', |
1127 [{'G': 'EGroup', 'GN': 'String', 'L': 'String', 'T': 'EUser', 'T2': 'EUser', 'X': 'EUser'}])], |
1127 [{'G': 'CWGroup', 'GN': 'String', 'L': 'String', 'T': 'CWUser', 'T2': 'CWUser', 'X': 'CWUser'}])], |
1128 None, None, [self.system], |
1128 None, None, [self.system], |
1129 {'T': 'table0.C0', 'T2': 'table1.C0', |
1129 {'T': 'table0.C0', 'T2': 'table1.C0', |
1130 'X': 'table2.C1', 'X.login': 'table2.C0', 'L': 'table2.C0'}, [])]) |
1130 'X': 'table2.C1', 'X.login': 'table2.C0', 'L': 'table2.C0'}, [])]) |
1131 |
1131 |
1132 def test_exists_security_no_invariant(self): |
1132 def test_exists_security_no_invariant(self): |
1133 ueid = self.session.user.eid |
1133 ueid = self.session.user.eid |
1134 self._test('Any X,AA,AB,AC,AD ORDERBY AA WHERE X is EUser, X login AA, X firstname AB, X surname AC, X modification_date AD, A eid %(B)s, \ |
1134 self._test('Any X,AA,AB,AC,AD ORDERBY AA WHERE X is CWUser, X login AA, X firstname AB, X surname AC, X modification_date AD, A eid %(B)s, \ |
1135 EXISTS(((X identity A) OR \ |
1135 EXISTS(((X identity A) OR \ |
1136 (EXISTS(X in_group C, C name IN("managers", "staff"), C is EGroup))) OR \ |
1136 (EXISTS(X in_group C, C name IN("managers", "staff"), C is CWGroup))) OR \ |
1137 (EXISTS(X in_group D, A in_group D, NOT D name "users", D is EGroup)))', |
1137 (EXISTS(X in_group D, A in_group D, NOT D name "users", D is CWGroup)))', |
1138 [('FetchStep', [('Any X,AA,AB,AC,AD WHERE X login AA, X firstname AB, X surname AC, X modification_date AD, X is EUser', |
1138 [('FetchStep', [('Any X,AA,AB,AC,AD WHERE X login AA, X firstname AB, X surname AC, X modification_date AD, X is CWUser', |
1139 [{'AA': 'String', 'AB': 'String', 'AC': 'String', 'AD': 'Datetime', |
1139 [{'AA': 'String', 'AB': 'String', 'AC': 'String', 'AD': 'Datetime', |
1140 'X': 'EUser'}])], |
1140 'X': 'CWUser'}])], |
1141 [self.ldap, self.system], None, {'AA': 'table0.C1', 'AB': 'table0.C2', |
1141 [self.ldap, self.system], None, {'AA': 'table0.C1', 'AB': 'table0.C2', |
1142 'AC': 'table0.C3', 'AD': 'table0.C4', |
1142 'AC': 'table0.C3', 'AD': 'table0.C4', |
1143 'X': 'table0.C0', |
1143 'X': 'table0.C0', |
1144 'X.firstname': 'table0.C2', |
1144 'X.firstname': 'table0.C2', |
1145 'X.login': 'table0.C1', |
1145 'X.login': 'table0.C1', |
1146 'X.modification_date': 'table0.C4', |
1146 'X.modification_date': 'table0.C4', |
1147 'X.surname': 'table0.C3'}, []), |
1147 'X.surname': 'table0.C3'}, []), |
1148 ('OneFetchStep', [('Any X,AA,AB,AC,AD ORDERBY AA WHERE X login AA, X firstname AB, X surname AC, X modification_date AD, EXISTS(((X identity 5) OR (EXISTS(X in_group C, C name IN("managers", "staff"), C is EGroup))) OR (EXISTS(X in_group D, 5 in_group D, NOT D name "users", D is EGroup))), X is EUser', |
1148 ('OneFetchStep', [('Any X,AA,AB,AC,AD ORDERBY AA WHERE X login AA, X firstname AB, X surname AC, X modification_date AD, EXISTS(((X identity 5) OR (EXISTS(X in_group C, C name IN("managers", "staff"), C is CWGroup))) OR (EXISTS(X in_group D, 5 in_group D, NOT D name "users", D is CWGroup))), X is CWUser', |
1149 [{'AA': 'String', 'AB': 'String', 'AC': 'String', 'AD': 'Datetime', |
1149 [{'AA': 'String', 'AB': 'String', 'AC': 'String', 'AD': 'Datetime', |
1150 'C': 'EGroup', 'D': 'EGroup', 'X': 'EUser'}])], |
1150 'C': 'CWGroup', 'D': 'CWGroup', 'X': 'CWUser'}])], |
1151 None, None, [self.system], |
1151 None, None, [self.system], |
1152 {'AA': 'table0.C1', 'AB': 'table0.C2', 'AC': 'table0.C3', 'AD': 'table0.C4', |
1152 {'AA': 'table0.C1', 'AB': 'table0.C2', 'AC': 'table0.C3', 'AD': 'table0.C4', |
1153 'X': 'table0.C0', |
1153 'X': 'table0.C0', |
1154 'X.firstname': 'table0.C2', 'X.login': 'table0.C1', 'X.modification_date': 'table0.C4', 'X.surname': 'table0.C3'}, |
1154 'X.firstname': 'table0.C2', 'X.login': 'table0.C1', 'X.modification_date': 'table0.C4', 'X.surname': 'table0.C3'}, |
1155 [])], |
1155 [])], |
1156 {'B': ueid}) |
1156 {'B': ueid}) |
1157 |
1157 |
1158 def test_relation_need_split(self): |
1158 def test_relation_need_split(self): |
1159 self._test('Any X, S WHERE X in_state S', |
1159 self._test('Any X, S WHERE X in_state S', |
1160 [('UnionStep', None, None, [ |
1160 [('UnionStep', None, None, [ |
1161 ('OneFetchStep', [('Any X,S WHERE X in_state S, S is State, X is IN(Affaire, EUser)', |
1161 ('OneFetchStep', [('Any X,S WHERE X in_state S, S is State, X is IN(Affaire, CWUser)', |
1162 [{'X': 'Affaire', 'S': 'State'}, {'X': 'EUser', 'S': 'State'}])], |
1162 [{'X': 'Affaire', 'S': 'State'}, {'X': 'CWUser', 'S': 'State'}])], |
1163 None, None, [self.system], {}, []), |
1163 None, None, [self.system], {}, []), |
1164 ('OneFetchStep', [('Any X,S WHERE X in_state S, S is State, X is Note', |
1164 ('OneFetchStep', [('Any X,S WHERE X in_state S, S is State, X is Note', |
1165 [{'X': 'Note', 'S': 'State'}])], |
1165 [{'X': 'Note', 'S': 'State'}])], |
1166 None, None, [self.rql, self.system], {}, []), |
1166 None, None, [self.rql, self.system], {}, []), |
1167 ])]) |
1167 ])]) |
1263 self._test('Any A,B,C,D WHERE A eid %(x)s,A creation_date B,A modification_date C, A todo_by D?', |
1263 self._test('Any A,B,C,D WHERE A eid %(x)s,A creation_date B,A modification_date C, A todo_by D?', |
1264 [('FetchStep', [('Any A,B,C WHERE A eid 999999, A creation_date B, A modification_date C, A is Note', |
1264 [('FetchStep', [('Any A,B,C WHERE A eid 999999, A creation_date B, A modification_date C, A is Note', |
1265 [{'A': 'Note', 'C': 'Datetime', 'B': 'Datetime'}])], |
1265 [{'A': 'Note', 'C': 'Datetime', 'B': 'Datetime'}])], |
1266 [self.rql], None, |
1266 [self.rql], None, |
1267 {'A': 'table0.C0', 'A.creation_date': 'table0.C1', 'A.modification_date': 'table0.C2', 'C': 'table0.C2', 'B': 'table0.C1'}, []), |
1267 {'A': 'table0.C0', 'A.creation_date': 'table0.C1', 'A.modification_date': 'table0.C2', 'C': 'table0.C2', 'B': 'table0.C1'}, []), |
1268 #('FetchStep', [('Any D WHERE D is EUser', [{'D': 'EUser'}])], |
1268 #('FetchStep', [('Any D WHERE D is CWUser', [{'D': 'CWUser'}])], |
1269 # [self.ldap, self.system], None, {'D': 'table1.C0'}, []), |
1269 # [self.ldap, self.system], None, {'D': 'table1.C0'}, []), |
1270 ('OneFetchStep', [('Any A,B,C,D WHERE A creation_date B, A modification_date C, A todo_by D?, A is Note, D is EUser', |
1270 ('OneFetchStep', [('Any A,B,C,D WHERE A creation_date B, A modification_date C, A todo_by D?, A is Note, D is CWUser', |
1271 [{'A': 'Note', 'C': 'Datetime', 'B': 'Datetime', 'D': 'EUser'}])], |
1271 [{'A': 'Note', 'C': 'Datetime', 'B': 'Datetime', 'D': 'CWUser'}])], |
1272 None, None, [self.system], |
1272 None, None, [self.system], |
1273 {'A': 'table0.C0', 'A.creation_date': 'table0.C1', 'A.modification_date': 'table0.C2', 'C': 'table0.C2', 'B': 'table0.C1'}, [])], |
1273 {'A': 'table0.C0', 'A.creation_date': 'table0.C1', 'A.modification_date': 'table0.C2', 'C': 'table0.C2', 'B': 'table0.C1'}, [])], |
1274 {'x': 999999}) |
1274 {'x': 999999}) |
1275 |
1275 |
1276 |
1276 |
1277 def test_simplified_var(self): |
1277 def test_simplified_var(self): |
1278 repo._type_source_cache[999999] = ('Note', 'cards', 999999) |
1278 repo._type_source_cache[999999] = ('Note', 'cards', 999999) |
1279 self._test('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
1279 self._test('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
1280 [('OneFetchStep', [('Any 5 WHERE 5 in_group G, (G name IN("managers", "logilab")) OR (X require_permission P?, P name "bla", P require_group G), X eid 999999', |
1280 [('OneFetchStep', [('Any 5 WHERE 5 in_group G, (G name IN("managers", "logilab")) OR (X require_permission P?, P name "bla", P require_group G), X eid 999999', |
1281 [{'X': 'Note', 'G': 'EGroup', 'P': 'EPermission'}])], |
1281 [{'X': 'Note', 'G': 'CWGroup', 'P': 'CWPermission'}])], |
1282 None, None, [self.system], {}, [])], |
1282 None, None, [self.system], {}, [])], |
1283 {'x': 999999, 'u': self.session.user.eid}) |
1283 {'x': 999999, 'u': self.session.user.eid}) |
1284 |
1284 |
1285 def test_has_text(self): |
1285 def test_has_text(self): |
1286 self._test('Card X WHERE X has_text "toto"', |
1286 self._test('Card X WHERE X has_text "toto"', |
1688 ], |
1688 ], |
1689 {'x': anoneid}) |
1689 {'x': anoneid}) |
1690 |
1690 |
1691 # def test_update4(self): |
1691 # def test_update4(self): |
1692 # # since we are adding a in_state relation with a state from the system |
1692 # # since we are adding a in_state relation with a state from the system |
1693 # # source, EUser should only be searched only in the system source as well |
1693 # # source, CWUser should only be searched only in the system source as well |
1694 # rset = self.execute('State X WHERE X name "activated"') |
1694 # rset = self.execute('State X WHERE X name "activated"') |
1695 # assert len(rset) == 1, rset |
1695 # assert len(rset) == 1, rset |
1696 # activatedeid = rset[0][0] |
1696 # activatedeid = rset[0][0] |
1697 # self._test('SET X in_state S WHERE X is EUser, S eid %s' % activatedeid, |
1697 # self._test('SET X in_state S WHERE X is CWUser, S eid %s' % activatedeid, |
1698 # [('UpdateStep', [ |
1698 # [('UpdateStep', [ |
1699 # ('OneFetchStep', [('DISTINCT Any X,%s WHERE X is EUser' % activatedeid, |
1699 # ('OneFetchStep', [('DISTINCT Any X,%s WHERE X is CWUser' % activatedeid, |
1700 # [{'X': 'EUser'}])], |
1700 # [{'X': 'CWUser'}])], |
1701 # None, None, [self.system], {}, []), |
1701 # None, None, [self.system], {}, []), |
1702 # ]), |
1702 # ]), |
1703 # ]) |
1703 # ]) |
1704 |
1704 |
1705 # non regression tests #################################################### |
1705 # non regression tests #################################################### |
1706 |
1706 |
1707 def test_nonregr1(self): |
1707 def test_nonregr1(self): |
1708 self._test('Any X, Y WHERE X copain Y, X login "syt", Y login "cochon"', |
1708 self._test('Any X, Y WHERE X copain Y, X login "syt", Y login "cochon"', |
1709 [('FetchStep', |
1709 [('FetchStep', |
1710 [('Any X WHERE X login "syt", X is EUser', [{'X': 'EUser'}])], |
1710 [('Any X WHERE X login "syt", X is CWUser', [{'X': 'CWUser'}])], |
1711 [self.ldap, self.system], None, {'X': 'table0.C0'}, []), |
1711 [self.ldap, self.system], None, {'X': 'table0.C0'}, []), |
1712 ('FetchStep', |
1712 ('FetchStep', |
1713 [('Any Y WHERE Y login "cochon", Y is EUser', [{'Y': 'EUser'}])], |
1713 [('Any Y WHERE Y login "cochon", Y is CWUser', [{'Y': 'CWUser'}])], |
1714 [self.ldap, self.system], None, {'Y': 'table1.C0'}, []), |
1714 [self.ldap, self.system], None, {'Y': 'table1.C0'}, []), |
1715 ('OneFetchStep', |
1715 ('OneFetchStep', |
1716 [('Any X,Y WHERE X copain Y, X is EUser, Y is EUser', |
1716 [('Any X,Y WHERE X copain Y, X is CWUser, Y is CWUser', |
1717 [{'X': 'EUser', 'Y': 'EUser'}])], |
1717 [{'X': 'CWUser', 'Y': 'CWUser'}])], |
1718 None, None, [self.system], {'X': 'table0.C0', 'Y': 'table1.C0'}, []) |
1718 None, None, [self.system], {'X': 'table0.C0', 'Y': 'table1.C0'}, []) |
1719 ]) |
1719 ]) |
1720 |
1720 |
1721 def test_nonregr2(self): |
1721 def test_nonregr2(self): |
1722 treid = self.session.user.latest_trinfo().eid |
1722 treid = self.session.user.latest_trinfo().eid |
1723 self._test('Any X ORDERBY D DESC WHERE E eid %(x)s, E wf_info_for X, X modification_date D', |
1723 self._test('Any X ORDERBY D DESC WHERE E eid %(x)s, E wf_info_for X, X modification_date D', |
1724 [('FetchStep', [('Any X,D WHERE X modification_date D, X is Note', |
1724 [('FetchStep', [('Any X,D WHERE X modification_date D, X is Note', |
1725 [{'X': 'Note', 'D': 'Datetime'}])], |
1725 [{'X': 'Note', 'D': 'Datetime'}])], |
1726 [self.rql, self.system], None, {'X': 'table0.C0', 'X.modification_date': 'table0.C1', 'D': 'table0.C1'}, []), |
1726 [self.rql, self.system], None, {'X': 'table0.C0', 'X.modification_date': 'table0.C1', 'D': 'table0.C1'}, []), |
1727 ('FetchStep', [('Any X,D WHERE X modification_date D, X is EUser', |
1727 ('FetchStep', [('Any X,D WHERE X modification_date D, X is CWUser', |
1728 [{'X': 'EUser', 'D': 'Datetime'}])], |
1728 [{'X': 'CWUser', 'D': 'Datetime'}])], |
1729 [self.ldap, self.system], None, {'X': 'table1.C0', 'X.modification_date': 'table1.C1', 'D': 'table1.C1'}, []), |
1729 [self.ldap, self.system], None, {'X': 'table1.C0', 'X.modification_date': 'table1.C1', 'D': 'table1.C1'}, []), |
1730 ('AggrStep', 'Any X ORDERBY D DESC', None, None, 'table2', None, [ |
1730 ('AggrStep', 'Any X ORDERBY D DESC', None, None, 'table2', None, [ |
1731 ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is Affaire'%treid, |
1731 ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is Affaire'%treid, |
1732 [{'X': 'Affaire', 'E': 'TrInfo', 'D': 'Datetime'}])], |
1732 [{'X': 'Affaire', 'E': 'TrInfo', 'D': 'Datetime'}])], |
1733 [self.system], |
1733 [self.system], |
1734 {}, |
1734 {}, |
1735 {'X': 'table2.C0', 'X.modification_date': 'table2.C1', 'D': 'table2.C1', 'E.wf_info_for': 'table2.C0'}, []), |
1735 {'X': 'table2.C0', 'X.modification_date': 'table2.C1', 'D': 'table2.C1', 'E.wf_info_for': 'table2.C0'}, []), |
1736 ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is EUser'%treid, |
1736 ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is CWUser'%treid, |
1737 [{'X': 'EUser', 'E': 'TrInfo', 'D': 'Datetime'}])], |
1737 [{'X': 'CWUser', 'E': 'TrInfo', 'D': 'Datetime'}])], |
1738 [self.system], |
1738 [self.system], |
1739 {'X': 'table1.C0', 'X.modification_date': 'table1.C1', 'D': 'table1.C1'}, |
1739 {'X': 'table1.C0', 'X.modification_date': 'table1.C1', 'D': 'table1.C1'}, |
1740 {'X': 'table2.C0', 'X.modification_date': 'table2.C1', 'D': 'table2.C1', 'E.wf_info_for': 'table2.C0'}, []), |
1740 {'X': 'table2.C0', 'X.modification_date': 'table2.C1', 'D': 'table2.C1', 'E.wf_info_for': 'table2.C0'}, []), |
1741 ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is Note'%treid, |
1741 ('FetchStep', [('Any X,D WHERE E eid %s, E wf_info_for X, X modification_date D, E is TrInfo, X is Note'%treid, |
1742 [{'X': 'Note', 'E': 'TrInfo', 'D': 'Datetime'}])], |
1742 [{'X': 'Note', 'E': 'TrInfo', 'D': 'Datetime'}])], |