コード例 #1
0
    def testBatchCheck(self):
        if sqlite3.sqlite_version_info() < (3,7,0):
            raise testhelp.SkipTestException("buggy sqlite; use embedded sqlite")
        self.openRepository()
        db = self._setupDB()
        na = netauth.NetworkAuthorization(db, "localhost")

        db.transaction()

        self._addUserRole(na, "ro", "ro")
        na.addAcl("ro", "foo:.*", label=None, write=False)
        ro = ("ro", "ro", [ (None, None) ], None )

        self._addUserRole(na, "rw", "rw")
        na.addAcl("rw", "foo:.*", label=None, write=True)
        rw = ("rw", "rw", [ (None, None) ], None )
        
        self._addUserRole(na, "mixed", "mixed")
        na.addAcl("mixed", "foo:.*", label=None, write=False)
        na.addAcl("mixed", "foo:runtime", label=None, write=True)
        mixed = ("mixed", "mixed", [ (None, None) ], None )

        db.commit()
        
        fr = self.addComponent("foo:runtime")
        fd = self.addComponent("foo:devel")
        troveList = [ (fr.getName(), fr.getVersion().asString(), fr.getFlavor().freeze()),
                      (fd.getName(), fd.getVersion().asString(), fd.getFlavor().freeze())]
        self.assertEqual(na.batchCheck(ro, troveList), [True,True])
        self.assertEqual(na.batchCheck(ro, troveList, write=True), [False,False])
        self.assertEqual(na.batchCheck(rw, troveList), [True,True])
        self.assertEqual(na.batchCheck(rw, troveList, write=True), [True,True])
        self.assertEqual(na.batchCheck(mixed, troveList), [True,True])
        self.assertEqual(na.batchCheck(mixed, troveList, write=True), [True,False])
コード例 #2
0
ファイル: testsuite.py プロジェクト: tensor5/conary
 def setupPaths(self):
     # turn off rpm locking via a DSO override. We have to
     # keep a reference to the handle or else dlclose() will be
     # called on it. Yes, this is ugly, but for some reason RPM
     # has a global variable for the location of the lock file
     # that only gets filled in the first time you ask for the rpm
     # database lock. Thus you can't use more than one root directory
     # during any single execution of rpmlib code.
     assert 'rpm._rpm' not in sys.modules
     from conary_test import norpmlock
     norpmlock.open(resources.get_path('conary_test', '_norpmlock.so'))
     if sqlite3.sqlite_version_info() < (3, 7, 0):
         warnings.warn("conary.sqlite3 is linked against a too-old system "
                       "sqlite that is known to have bugs affecting the "
                       "repository.")
     # Some transport tests are affected by proxy environment settings
     for transport in ('http', 'https', 'ftp', 'all', 'no'):
         name = '%s_proxy' % transport
         os.environ.pop(name, None)
         os.environ.pop(name.upper(), None)
コード例 #3
0
ファイル: testsuite.py プロジェクト: pombr/conary
 def setupPaths(self):
     # turn off rpm locking via a DSO override. We have to
     # keep a reference to the handle or else dlclose() will be
     # called on it. Yes, this is ugly, but for some reason RPM
     # has a global variable for the location of the lock file
     # that only gets filled in the first time you ask for the rpm
     # database lock. Thus you can't use more than one root directory
     # during any single execution of rpmlib code.
     assert 'rpm._rpm' not in sys.modules
     from conary_test import norpmlock
     norpmlock.open(resources.get_path('conary_test', '_norpmlock.so'))
     if sqlite3.sqlite_version_info() < (3,7,0):
         warnings.warn("conary.sqlite3 is linked against a too-old system "
                 "sqlite that is known to have bugs affecting the "
                 "repository.")
     # Some transport tests are affected by proxy environment settings
     for transport in ('http', 'https', 'ftp', 'all', 'no'):
         name = '%s_proxy' % transport
         os.environ.pop(name, None)
         os.environ.pop(name.upper(), None)