Python twisted.internet.endpoints.SSL4ServerEndpoint() Examples
The following are 9
code examples of twisted.internet.endpoints.SSL4ServerEndpoint().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
twisted.internet.endpoints
, or try the search function
.
Example #1
Source File: test_endpoints.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def createServerEndpoint(self, reactor, factory, **listenArgs): """ Create an L{SSL4ServerEndpoint} and return the tools to verify its behaviour. @param factory: The thing that we expect to be passed to our L{IStreamServerEndpoint.listen} implementation. @param reactor: A fake L{IReactorSSL} that L{SSL4ServerEndpoint} can call L{IReactorSSL.listenSSL} on. @param listenArgs: Optional dictionary of arguments to L{IReactorSSL.listenSSL}. """ address = IPv4Address("TCP", "0.0.0.0", 0) return (endpoints.SSL4ServerEndpoint(reactor, address.port, self.serverSSLContext, **listenArgs), (address.port, factory, self.serverSSLContext, listenArgs.get('backlog', 50), listenArgs.get('interface', '')), address)
Example #2
Source File: test_endpoints.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_ssl(self): """ When passed an SSL strports description, L{endpoints.serverFromString} returns a L{SSL4ServerEndpoint} instance initialized with the values from the string. """ reactor = object() server = endpoints.serverFromString( reactor, "ssl:1234:backlog=12:privateKey=%s:" "certKey=%s:sslmethod=TLSv1_METHOD:interface=10.0.0.1" % (escapedPEMPathName, escapedPEMPathName)) self.assertIsInstance(server, endpoints.SSL4ServerEndpoint) self.assertIs(server._reactor, reactor) self.assertEqual(server._port, 1234) self.assertEqual(server._backlog, 12) self.assertEqual(server._interface, "10.0.0.1") self.assertEqual(server._sslContextFactory.method, TLSv1_METHOD) ctx = server._sslContextFactory.getContext() self.assertIsInstance(ctx, ContextType)
Example #3
Source File: test_endpoints.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def test_sslWithDefaults(self): """ An SSL string endpoint description with minimal arguments returns a properly initialized L{SSL4ServerEndpoint} instance. """ reactor = object() server = endpoints.serverFromString( reactor, "ssl:4321:privateKey=%s" % (escapedPEMPathName,)) self.assertIsInstance(server, endpoints.SSL4ServerEndpoint) self.assertIs(server._reactor, reactor) self.assertEqual(server._port, 4321) self.assertEqual(server._backlog, 50) self.assertEqual(server._interface, "") self.assertEqual(server._sslContextFactory.method, SSLv23_METHOD) self.assertTrue( server._sslContextFactory._options & OP_NO_SSLv3, ) ctx = server._sslContextFactory.getContext() self.assertIsInstance(ctx, ContextType) # Use a class variable to ensure we use the exactly same endpoint string # except for the chain file itself.
Example #4
Source File: test_endpoints.py From learn_python3_spider with MIT License | 6 votes |
def createServerEndpoint(self, reactor, factory, **listenArgs): """ Create an L{SSL4ServerEndpoint} and return the tools to verify its behaviour. @param factory: The thing that we expect to be passed to our L{IStreamServerEndpoint.listen} implementation. @param reactor: A fake L{IReactorSSL} that L{SSL4ServerEndpoint} can call L{IReactorSSL.listenSSL} on. @param listenArgs: Optional dictionary of arguments to L{IReactorSSL.listenSSL}. """ address = IPv4Address("TCP", "0.0.0.0", 0) return (endpoints.SSL4ServerEndpoint(reactor, address.port, self.serverSSLContext, **listenArgs), (address.port, factory, self.serverSSLContext, listenArgs.get('backlog', 50), listenArgs.get('interface', '')), address)
Example #5
Source File: test_endpoints.py From learn_python3_spider with MIT License | 6 votes |
def test_ssl(self): """ When passed an SSL strports description, L{endpoints.serverFromString} returns a L{SSL4ServerEndpoint} instance initialized with the values from the string. """ reactor = object() server = endpoints.serverFromString( reactor, "ssl:1234:backlog=12:privateKey=%s:" "certKey=%s:sslmethod=TLSv1_METHOD:interface=10.0.0.1" % (escapedPEMPathName, escapedPEMPathName)) self.assertIsInstance(server, endpoints.SSL4ServerEndpoint) self.assertIs(server._reactor, reactor) self.assertEqual(server._port, 1234) self.assertEqual(server._backlog, 12) self.assertEqual(server._interface, "10.0.0.1") self.assertEqual(server._sslContextFactory.method, TLSv1_METHOD) ctx = server._sslContextFactory.getContext() self.assertIsInstance(ctx, ContextType)
Example #6
Source File: test_endpoints.py From learn_python3_spider with MIT License | 6 votes |
def test_sslWithDefaults(self): """ An SSL string endpoint description with minimal arguments returns a properly initialized L{SSL4ServerEndpoint} instance. """ reactor = object() server = endpoints.serverFromString( reactor, "ssl:4321:privateKey=%s" % (escapedPEMPathName,)) self.assertIsInstance(server, endpoints.SSL4ServerEndpoint) self.assertIs(server._reactor, reactor) self.assertEqual(server._port, 4321) self.assertEqual(server._backlog, 50) self.assertEqual(server._interface, "") self.assertEqual(server._sslContextFactory.method, SSLv23_METHOD) self.assertTrue( server._sslContextFactory._options & OP_NO_SSLv3, ) ctx = server._sslContextFactory.getContext() self.assertIsInstance(ctx, ContextType) # Use a class variable to ensure we use the exactly same endpoint string # except for the chain file itself.
Example #7
Source File: test_endpoints.py From learn_python3_spider with MIT License | 6 votes |
def test_sslNoTrailingNewlinePem(self): """ Lack of a trailing newline in key and cert .pem files should not generate an exception. """ reactor = object() server = endpoints.serverFromString( reactor, "ssl:1234:backlog=12:privateKey=%s:" "certKey=%s:sslmethod=TLSv1_METHOD:interface=10.0.0.1" % ( escapedNoTrailingNewlineKeyPEMPathName, escapedNoTrailingNewlineCertPEMPathName, ) ) self.assertIsInstance(server, endpoints.SSL4ServerEndpoint) self.assertIs(server._reactor, reactor) self.assertEqual(server._port, 1234) self.assertEqual(server._backlog, 12) self.assertEqual(server._interface, "10.0.0.1") self.assertEqual(server._sslContextFactory.method, TLSv1_METHOD) ctx = server._sslContextFactory.getContext() self.assertIsInstance(ctx, ContextType)
Example #8
Source File: test_endpoints.py From python-for-android with Apache License 2.0 | 6 votes |
def createServerEndpoint(self, reactor, factory, **listenArgs): """ Create an L{SSL4ServerEndpoint} and return the tools to verify its behaviour. @param factory: The thing that we expect to be passed to our L{IStreamServerEndpoint.listen} implementation. @param reactor: A fake L{IReactorSSL} that L{SSL4ServerEndpoint} can call L{IReactorSSL.listenSSL} on. @param listenArgs: Optional dictionary of arguments to L{IReactorSSL.listenSSL}. """ address = IPv4Address("TCP", "0.0.0.0", 0) return (endpoints.SSL4ServerEndpoint(reactor, address.port, self.serverSSLContext, **listenArgs), (address.port, factory, self.serverSSLContext, listenArgs.get('backlog', 50), listenArgs.get('interface', '')), address)
Example #9
Source File: test_endpoints.py From python-for-android with Apache License 2.0 | 6 votes |
def test_ssl(self): """ When passed an SSL strports description, L{endpoints.serverFromString} returns a L{SSL4ServerEndpoint} instance initialized with the values from the string. """ reactor = object() server = endpoints.serverFromString( reactor, "ssl:1234:backlog=12:privateKey=%s:" "certKey=%s:interface=10.0.0.1" % (escapedPEMPathName, escapedPEMPathName)) self.assertIsInstance(server, endpoints.SSL4ServerEndpoint) self.assertIdentical(server._reactor, reactor) self.assertEquals(server._port, 1234) self.assertEquals(server._backlog, 12) self.assertEquals(server._interface, "10.0.0.1") ctx = server._sslContextFactory.getContext() self.assertIsInstance(ctx, ContextType)