コード例 #1
0
    def testOneSenderManyRecipients(self):
        raddresses = [
            Q2QAddress("receiving-data.org", "receiver%d" % (x, ))
            for x in range(10)
        ]

        nexi = [
            sigma.Nexus(self.service, radr, sigma.BaseNexusUI(self.mktemp()),
                        self.service.callLater) for radr in raddresses
        ]

        self.stoppers.extend(nexi)

        self.senderNexus.push(self.sfile, 'TESTtoTEST', raddresses)
        self.service.flush()

        receivedIntroductions = 0

        for nexium in nexi:
            receivedIntroductions += nexium.ui.receivedIntroductions
        self.failUnless(receivedIntroductions > 1)

        for nexium in nexi:
            peerFiles = childrenOf(nexium.ui.basepath)
            self.assertEquals(len(peerFiles), 1)
            rfiles = childrenOf(peerFiles[0])
            self.assertEquals(len(rfiles), 1, rfiles)
            rfile = rfiles[0]
            self.assertEquals(rfile.open().read(), TEST_DATA,
                              "file value mismatch")
コード例 #2
0
ファイル: gtk2hack.py プロジェクト: chellygel/vertex
    def setCurrentID(self, idName):

        if idName is not None:
            currentID = Q2QAddress.fromString(idName)
            # Log in?
            # Self.animator.start()
            SL = self.xml.get_widget(
                "identifymenuitem").get_children()[0].set_label
            def loggedIn(result):
                SL(str(currentID))
                self.currentID = currentID
            def notLoggedIn(error):
                SL("Identify")
                # Self.animator.stop(0)
            # This following order is INSANE - you should definitely not have
            # to wait until the LISTEN succeeds to start the service; quite the
            # opposite, you should wait until the service has started, then
            # issue the LISTEN!! For some reason, the connection drops
            # immediately if you do that, and I have no idea why.  As soon as I
            # can fix that issue the startService should be moved up previous
            # to listenQ2Q.
            self.clientService.listenQ2Q(currentID,
                                         {'vertex': VertexFactory(self)},
                                         "desktop vertex UI").addCallbacks(
                loggedIn, notLoggedIn).addCallback(
                lambda ign: self.clientService.startService())
コード例 #3
0
ファイル: test_standalone.py プロジェクト: zhp1254/vertex
    def test_adds_user(self):
        """
        When L{UserAdder} is connected to L{IdentityAdmin}, the L{AddUser}
        command is called and L{IdentityAdmin} adds the user to its factory's
        store.
        """
        admin = IdentityAdmin()
        admin.factory = self.adminFactory

        serverTransport = makeFakeServer(admin)
        serverTransport.getQ2QHost = lambda: Q2QAddress('Q2Q Host')

        client = AMP()
        pump = connect(admin, serverTransport, client, makeFakeClient(client))

        d = client.callRemote(AddUser, name='q2q username',
                              password='******')
        pump.flush()

        # The username and password are added, along with the domain=q2q
        # host, to the IdentityAdmin's factory's store
        self.assertEqual([call('Q2Q Host', 'q2q username', 'q2q password')],
                         self.addUser.calls)

        # The server responds with {}
        self.assertEqual({}, self.successResultOf(d))
コード例 #4
0
ファイル: gtk2hack.py プロジェクト: varunshah1106/vertex
    def setCurrentID(self, idName):

        if idName is not None:
            currentID = Q2QAddress.fromString(idName)
            # log in?
            # self.animator.start()
            SL = self.xml.get_widget(
                "identifymenuitem").get_children()[0].set_label

            def loggedIn(result):
                SL(str(currentID))
                self.currentID = currentID

            def notLoggedIn(error):
                SL("Identify")
                # self.animator.stop(0)

            # This following order is INSANE - you should definitely not have
            # to wait until the LISTEN succeeds to start the service; quite the
            # opposite, you should wait until the service has started, then
            # issue the LISTEN!! For some reason, the connection drops
            # immediately if you do that, and I have no idea why.  As soon as I
            # can fix that issue the startService should be moved up previous
            # to listenQ2Q.
            self.clientService.listenQ2Q(currentID, {
                'vertex': VertexFactory(self)
            }, "desktop vertex UI").addCallbacks(
                loggedIn, notLoggedIn).addCallback(
                    lambda ign: self.clientService.startService())
コード例 #5
0
ファイル: gtk2hack.py プロジェクト: chellygel/vertex
    def identifyOK(self, event):
        idstr = self.addressEntry.get_text()
        D = self.clientService.authorize(
            Q2QAddress.fromString(idstr),
            self.passwordEntry.get_text())

        sensitiveWidgets = [self.addressEntry,
                            self.passwordEntry,
                            self.okButton,
                            self.cancelButton]
        for widget in sensitiveWidgets:
            widget.set_sensitive(False)
        self.progressLabel.set_text("Authenticating...")
        def itWorked(workedNone):
            self.identifyWindow.destroy()
            self.plug.setCurrentID(idstr)
        def itDidntWork(error):
            self.progressLabel.set_text(error.getErrorMessage())
            for widget in sensitiveWidgets:
                widget.set_sensitive(True)
        D.addCallbacks(itWorked, itDidntWork)
コード例 #6
0
ファイル: test_identity.py プロジェクト: zhp1254/vertex
    def test_identify(self):
        """
        A presence server responds to Identify messages with the cert
        stored for the requested domain.
        """
        target = "example.com"
        fakeCert = makeCert("fake certificate")

        class FakeStorage(object):
            def getPrivateCertificate(cs, subject):
                self.assertEqual(subject, target)
                return fakeCert
        class FakeService(object):
            certificateStorage = FakeStorage()

        q = Q2Q()
        q.service = FakeService()

        d = callResponder(q, Identify, subject=Q2QAddress(target))
        response = self.successResultOf(d)
        self.assertEqual(response, {'certificate': fakeCert})
        self.assertFalse(hasattr(response['certificate'], 'privateKey'))
コード例 #7
0
ファイル: gtk2hack.py プロジェクト: varunshah1106/vertex
    def identifyOK(self, event):
        idstr = self.addressEntry.get_text()
        D = self.clientService.authorize(Q2QAddress.fromString(idstr),
                                         self.passwordEntry.get_text())

        sensitiveWidgets = [
            self.addressEntry, self.passwordEntry, self.okButton,
            self.cancelButton
        ]
        for widget in sensitiveWidgets:
            widget.set_sensitive(False)
        self.progressLabel.set_text("Authenticating...")

        def itWorked(workedNone):
            self.identifyWindow.destroy()
            self.plug.setCurrentID(idstr)

        def itDidntWork(error):
            self.progressLabel.set_text(error.getErrorMessage())
            for widget in sensitiveWidgets:
                widget.set_sensitive(True)

        D.addCallbacks(itWorked, itDidntWork)
コード例 #8
0
            server = listener.buildProtocol(fromAddress)
            client = protocolFactory.buildProtocol(toAddress)

            servertpt = FakeQ2QTransport(sio, toAddress, fromAddress)
            clienttpt = FakeQ2QTransport(cio, fromAddress, toAddress)

            server.makeConnection(servertpt)
            client.makeConnection(clienttpt)
            pump = IOPump(client, server, cio, sio, False)
            self.pumps.append(pump)

            return defer.succeed(client)


sender = Q2QAddress("sending-data.net", "sender")
receiver = Q2QAddress("receiving-data.org", "receiver")


class TestBase(unittest.TestCase):
    def setUp(self):
        self.realChunkSize = sigma.CHUNK_SIZE
        sigma.CHUNK_SIZE = 100
        svc = self.service = FakeQ2QService()
        fname = self.mktemp()

        sf = self.sfile = FilePath(fname)
        if not sf.parent().isdir():
            sf.parent().makedirs()
        sf.open('w').write(TEST_DATA)
        self.senderNexus = sigma.Nexus(svc, sender,