Ticket #1879: test_pbsec.py

File test_pbsec.py, 803 bytes (added by pgstudy, 16 years ago)

Test without reactor.run()

Line 
1from twisted.trial import unittest
2from twisted.spread import pb, jelly
3
4class Receiver(pb.Root):
5  pass
6
7class PBWithSecurityOptionsTest(unittest.TestCase):
8    def testSecOptions(self):
9      import copy
10      gs=copy.copy(jelly.globalSecurity)
11      gs.isModuleAllowed=jelly.DummySecurityOptions().isModuleAllowed
12      gs.isClassAllowed=jelly.DummySecurityOptions().isClassAllowed
13      gs.isTypeAllowed=jelly.DummySecurityOptions().isTypeAllowed
14
15      factory = pb.PBClientFactory(gs)
16      factory.clientConnectionMade(pb.Broker(0))
17      serverFactory=pb.PBServerFactory(Receiver(),security=gs)
18      self.assertEquals(gs, factory.security)
19      self.assertEquals(gs, factory._broker.security)
20      proto = serverFactory.buildProtocol("127.0.0.1")
21      self.assertEquals(gs, proto.security)
22