def test_normalDB(self):

        # Get the DB
        yield self.db.clean()

        calendaruserproxy.ProxyDBService = self.db
        loader = XMLCalendarUserProxyLoader(
            "/Volumes/Data/Users/cyrusdaboo/Documents/Development/Apple/eclipse/CalendarServer-3/conf/auth/proxies-test.xml"
        )
        yield loader.updateProxyDB()

        yield self.db.setGroupMembers("A", (
            "B",
            "C",
            "D",
        ))

        membersA = yield self.db.getMembers("A")
        membershipsB = yield self.db.getMemberships("B")

        self.assertEqual(membersA, set((
            "B",
            "C",
            "D",
        )))
        self.assertEqual(membershipsB, set(("A", )))
Exemplo n.º 2
0
    def startService(self):
        """
        Start the service.
        """

        directory = directoryFromConfig(self.config)

        # Load proxy assignments from XML if specified
        if self.config.ProxyLoadFromFile:
            proxydbClass = namedClass(self.config.ProxyDBService.type)
            calendaruserproxy.ProxyDBService = proxydbClass(
                **self.config.ProxyDBService.params)
            loader = XMLCalendarUserProxyLoader(self.config.ProxyLoadFromFile)
            yield loader.updateProxyDB()

        # Populate the group membership cache
        if (self.config.GroupCaching.Enabled and
            self.config.GroupCaching.EnableUpdater):
            proxydb = calendaruserproxy.ProxyDBService
            if proxydb is None:
                proxydbClass = namedClass(self.config.ProxyDBService.type)
                proxydb = proxydbClass(**self.config.ProxyDBService.params)

            updater = GroupMembershipCacheUpdater(proxydb,
                directory,
                self.config.GroupCaching.UpdateSeconds,
                self.config.GroupCaching.ExpireSeconds,
                self.config.GroupCaching.LockSeconds,
                namespace=self.config.GroupCaching.MemcachedPool,
                useExternalProxies=self.config.GroupCaching.UseExternalProxies)
            yield updater.updateCache(fast=True)
            # Set in motion the work queue based updates:
            yield scheduleNextGroupCachingUpdate(self.store, 0)

            uid, gid = getCalendarServerIDs(self.config)
            dbPath = os.path.join(self.config.DataRoot, "proxies.sqlite")
            if os.path.exists(dbPath):
                os.chown(dbPath, uid, gid)

        # Process old inbox items
        self.store.setMigrating(True)
        yield self.processInboxItems()
        self.store.setMigrating(False)

        # Migrate mail tokens from sqlite to store
        yield migrateTokensToStore(self.config.DataRoot, self.store)
        # Set mail polling in motion
        if self.config.Scheduling.iMIP.Enabled:
            yield scheduleNextMailPoll(self.store, 0)
    def test_normalDB(self):
    
        # Get the DB
        yield self.db.clean()
        
        calendaruserproxy.ProxyDBService = self.db
        loader = XMLCalendarUserProxyLoader("/Volumes/Data/Users/cyrusdaboo/Documents/Development/Apple/eclipse/CalendarServer-3/conf/auth/proxies-test.xml")
        yield loader.updateProxyDB()

        yield self.db.setGroupMembers("A", ("B", "C", "D",))
        
        membersA = yield self.db.getMembers("A")
        membershipsB = yield self.db.getMemberships("B")
        
        self.assertEqual(membersA, set(("B", "C", "D",)))
        self.assertEqual(membershipsB, set(("A",)))
Exemplo n.º 4
0
    def stepWithResult(self, result):
        if self.doPostImport:

            directory = directoryFromConfig(self.config)

            # Load proxy assignments from XML if specified
            if self.config.ProxyLoadFromFile:
                proxydbClass = namedClass(self.config.ProxyDBService.type)
                calendaruserproxy.ProxyDBService = proxydbClass(
                    **self.config.ProxyDBService.params)
                loader = XMLCalendarUserProxyLoader(self.config.ProxyLoadFromFile)
                yield loader.updateProxyDB()

            # Populate the group membership cache
            if (self.config.GroupCaching.Enabled and
                self.config.GroupCaching.EnableUpdater):
                proxydb = calendaruserproxy.ProxyDBService
                if proxydb is None:
                    proxydbClass = namedClass(self.config.ProxyDBService.type)
                    proxydb = proxydbClass(**self.config.ProxyDBService.params)

                updater = GroupMembershipCacheUpdater(proxydb,
                    directory,
                    self.config.GroupCaching.UpdateSeconds,
                    self.config.GroupCaching.ExpireSeconds,
                    self.config.GroupCaching.LockSeconds,
                    namespace=self.config.GroupCaching.MemcachedPool,
                    useExternalProxies=self.config.GroupCaching.UseExternalProxies)
                yield updater.updateCache(fast=True)

                uid, gid = getCalendarServerIDs(self.config)
                dbPath = os.path.join(self.config.DataRoot, "proxies.sqlite")
                if os.path.exists(dbPath):
                    os.chown(dbPath, uid, gid)

            # Process old inbox items
            self.store.setMigrating(True)
            yield self.processInboxItems()
            self.store.setMigrating(False)

            # Migrate mail tokens from sqlite to store
            yield migrateTokensToStore(self.config.DataRoot, self.store)
Exemplo n.º 5
0
 def _doProxyUpdate():
     proxydbClass = namedClass(config.ProxyDBService.type)
     calendaruserproxy.ProxyDBService = proxydbClass(**config.ProxyDBService.params)
     loader = XMLCalendarUserProxyLoader(config.ProxyLoadFromFile)
     return loader.updateProxyDB()
Exemplo n.º 6
0
def loadDelegatesFromXMLintoStore(xmlFile, store):
    loader = XMLCalendarUserProxyLoader(xmlFile)
    return loader.updateProxyStore(store)
Exemplo n.º 7
0
def loadDelegatesFromXMLintoProxyDB(xmlFile, service):
    loader = XMLCalendarUserProxyLoader(xmlFile)
    return loader.updateProxyDB(service)
Exemplo n.º 8
0
def loadDelegatesFromXML(xmlFile, service):
    loader = XMLCalendarUserProxyLoader(xmlFile, service)
    return loader.updateProxyDB()