equal
deleted
inserted
replaced
307 Here is a small test case that will check the basis of our security |
307 Here is a small test case that will check the basis of our security |
308 model, in :file:`test/test_sytweb.py`: |
308 model, in :file:`test/test_sytweb.py`: |
309 |
309 |
310 .. sourcecode:: python |
310 .. sourcecode:: python |
311 |
311 |
312 from cubicweb.devtools.testlib import CubicWebTC |
312 from cubicweb.devtools import testlib |
313 from cubicweb import Binary |
313 from cubicweb import Binary |
314 |
314 |
315 class SecurityTC(CubicWebTC): |
315 class SecurityTC(testlib.CubicWebTC): |
316 |
316 |
317 def test_visibility_propagation(self): |
317 def test_visibility_propagation(self): |
318 with self.admin_access.repo_cnx() as cnx: |
318 with self.admin_access.repo_cnx() as cnx: |
319 # create a user for later security checks |
319 # create a user for later security checks |
320 toto = self.create_user(cnx, 'toto') |
320 toto = self.create_user(cnx, 'toto') |
353 # test security with permissions |
353 # test security with permissions |
354 self.assertEquals(2, len(cnx.execute('File X'))) # now toto has access to photo2 |
354 self.assertEquals(2, len(cnx.execute('File X'))) # now toto has access to photo2 |
355 self.assertEquals(1, len(cnx.execute('Folder X'))) # and to restricted folder |
355 self.assertEquals(1, len(cnx.execute('Folder X'))) # and to restricted folder |
356 |
356 |
357 if __name__ == '__main__': |
357 if __name__ == '__main__': |
358 from logilab.common.testlib import unittest_main |
358 from unittest import main |
359 unittest_main() |
359 main() |
360 |
360 |
361 It's not complete, but shows most things you'll want to do in tests: adding some |
361 It's not complete, but shows most things you'll want to do in tests: adding some |
362 content, creating users and connecting as them in the test, etc... |
362 content, creating users and connecting as them in the test, etc... |
363 |
363 |
364 To run it type: |
364 To run it type: |