Exemple #1
0
    def testCollectionAccessSuperUser(self):
        # super user accessing (non-)shared res from nu

        parentColl = '/SOGo/dav/%s/Calendar/' % subscriber_username
        self.createdRsrc = '%stest-dav-acl/' % parentColl
        for rsrc in [ 'personal', 'test-dav-acl' ]:
            resource = '%s%s/' % (parentColl, rsrc)
            mkcol = webdavlib.WebDAVMKCOL(resource)
            self.superuser_client.execute(mkcol)
            acl_utility = utilities.TestCalendarACLUtility(self,
                                                           self.subscriber_client,
                                                           resource)
            acl_utility.setupRights(username, {})

        propfind = webdavlib.WebDAVPROPFIND(parentColl, [ "displayname" ], 1)
        self.subscriber_client.execute(propfind)
        hrefs = [x.text \
                 for x in propfind.response["document"] \
                 .findall("{DAV:}response/{DAV:}href")]
        self.assertTrue(len(hrefs) > 2,
                        "expected at least 3 hrefs in response")
        self.assertEquals(hrefs[0], parentColl,
                          "the href must be the 'Calendar' parent coll.")
        for rsrc in [ 'personal', 'test-dav-acl' ]:
            resource = '%s%s/' % (parentColl, rsrc)
            self.assertTrue(hrefs.index(resource) > -1,
                            "resource '%s' not returned" % resource)

if __name__ == "__main__":
    sogotests.runTests()
Exemple #2
0
class sogoToolTest(unittest.TestCase):

    def setUp(self):
      self.backupdir = tempfile.mkdtemp()

    def tearDown(self):
      os.chdir("/")
      shutil.rmtree(self.backupdir)

    def testBackupAll(self):
      """ sogo-tool backup ALL """

      (uid, gid) = pwd.getpwnam(sogo_user)[2:4]

      # We need to run as root since there's no way
      # of using another user's GNUstepDefaults
      self.assertEqual(os.getuid(), 0, "this test must run as root...")

      os.chown(self.backupdir, uid, gid)
      cmd = "sudo -u %s bash -c \"(cd %s && %s backup . ALL >/dev/null 2>&1)\"" % (sogo_user, self.backupdir, sogo_tool_path)
      print "sogo-tool cmd to execute %s" % cmd
      status = os.system(cmd)
      print "Exit status of os.system(): %d" % status
      rc = os.WEXITSTATUS(status)
      self.assertEqual(rc, 0, "sogo-tool failed RC=%d" % rc)


if __name__ == "__main__":
    sogotests.runTests()