def test_setProxies(self):
        """
        Read and Write proxies can be set en masse
        """
        directory = self.directory
        record = yield recordForPrincipalID(directory, "users:user01")

        readProxies, writeProxies = yield getProxies(record)
        self.assertEquals(readProxies, [])  # initially empty
        self.assertEquals(writeProxies, [])  # initially empty

        readProxies = [
            (yield recordForPrincipalID(directory, "users:user03")),
            (yield recordForPrincipalID(directory, "users:user04")),
        ]
        writeProxies = [(yield recordForPrincipalID(directory, "users:user05"))]
        yield setProxies(record, readProxies, writeProxies)

        readProxies, writeProxies = yield getProxies(record)
        self.assertEquals(set([r.uid for r in readProxies]), set(["user03", "user04"]))
        self.assertEquals(set([r.uid for r in writeProxies]), set(["user05"]))

        # Using None for a proxy list indicates a no-op
        yield setProxies(record, [], None)
        readProxies, writeProxies = yield getProxies(record)
        self.assertEquals(readProxies, [])  # now empty
        self.assertEquals(set([r.uid for r in writeProxies]), set(["user05"]))  # unchanged
    def test_setProxies(self):
        """
        Read and Write proxies can be set en masse
        """
        directory = self.directory
        record = yield recordForPrincipalID(directory, "users:user01")

        readProxies, writeProxies = yield getProxies(record)
        self.assertEquals(readProxies, [])  # initially empty
        self.assertEquals(writeProxies, [])  # initially empty

        readProxies = [
            (yield recordForPrincipalID(directory, "users:user03")),
            (yield recordForPrincipalID(directory, "users:user04")),
        ]
        writeProxies = [
            (yield recordForPrincipalID(directory, "users:user05")),
        ]
        yield setProxies(record, readProxies, writeProxies)

        readProxies, writeProxies = yield getProxies(record)
        self.assertEquals(set([r.uid for r in readProxies]),
                          set(["user03", "user04"]))
        self.assertEquals(set([r.uid for r in writeProxies]), set(["user05"]))

        # Using None for a proxy list indicates a no-op
        yield setProxies(record, [], None)
        readProxies, writeProxies = yield getProxies(record)
        self.assertEquals(readProxies, [])  # now empty
        self.assertEquals(set([r.uid for r in writeProxies]),
                          set(["user05"]))  # unchanged
    def test_setProxies(self):
        """
        Read and Write proxies can be set en masse
        """
        directory = directoryFromConfig(config)

        principal = principalForPrincipalID("users:user01", directory=directory)
        readProxies, writeProxies = (yield getProxies(principal, directory=directory))
        self.assertEquals(readProxies, []) # initially empty
        self.assertEquals(writeProxies, []) # initially empty

        (yield setProxies(None, principal, ["users:user03", "users:user04"], ["users:user05"], directory=directory))
        readProxies, writeProxies = (yield getProxies(principal, directory=directory))
        self.assertEquals(set(readProxies), set(["user03", "user04"]))
        self.assertEquals(set(writeProxies), set(["user05"]))

        # Using None for a proxy list indicates a no-op
        (yield setProxies(None, principal, [], None, directory=directory))
        readProxies, writeProxies = (yield getProxies(principal, directory=directory))
        self.assertEquals(readProxies, []) # now empty
        self.assertEquals(set(writeProxies), set(["user05"])) # unchanged
 def command_getLocationAttributes(self, command):
     guid = command['GeneratedUID']
     record = self.dir.recordWithGUID(guid)
     if record is None:
         self.respondWithError("Principal not found: %s" % (guid,))
         return
     recordDict = recordToDict(record)
     principal = principalForPrincipalID(guid, directory=self.dir)
     if principal is None:
         self.respondWithError("Principal not found: %s" % (guid,))
         return
     recordDict['AutoSchedule'] = principal.getAutoSchedule()
     recordDict['AutoAcceptGroup'] = principal.getAutoAcceptGroup()
     recordDict['ReadProxies'], recordDict['WriteProxies'] = (yield getProxies(principal,
         directory=self.dir))
     self.respond(command, recordDict)
Exemple #5
0
    def command_getLocationAttributes(self, command):
        uid = command['GeneratedUID']
        record = yield self.dir.recordWithUID(uid)
        if record is None:
            self.respondWithError("Principal not found: %s" % (uid,))
            return
        recordDict = recordToDict(record)
        # recordDict['AutoSchedule'] = principal.getAutoSchedule()
        try:
            recordDict['AutoAcceptGroup'] = record.autoAcceptGroup
        except AttributeError:
            pass

        readProxies, writeProxies = yield getProxies(record)
        recordDict['ReadProxies'] = [r.uid for r in readProxies]
        recordDict['WriteProxies'] = [r.uid for r in writeProxies]
        self.respond(command, recordDict)
Exemple #6
0
    def command_getLocationAttributes(self, command):
        uid = command['GeneratedUID']
        record = yield self.dir.recordWithUID(uid)
        if record is None:
            self.respondWithError("Principal not found: %s" % (uid, ))
            return
        recordDict = recordToDict(record)
        # recordDict['AutoSchedule'] = principal.getAutoSchedule()
        try:
            recordDict['AutoAcceptGroup'] = record.autoAcceptGroup
        except AttributeError:
            pass

        readProxies, writeProxies = yield getProxies(record)
        recordDict['ReadProxies'] = [r.uid for r in readProxies]
        recordDict['WriteProxies'] = [r.uid for r in writeProxies]
        self.respond(command, recordDict)