From 9c39c87689a7a0e34083d14b76fee60eb74b68be Mon Sep 17 00:00:00 2001 From: nibrag Date: Sat, 14 May 2016 14:12:15 +0300 Subject: [PATCH] Added test case to create ssl transport --- tests/test_protocols.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_protocols.py b/tests/test_protocols.py index 467c773..036385d 100644 --- a/tests/test_protocols.py +++ b/tests/test_protocols.py @@ -2,6 +2,7 @@ import asyncio import aiosocks import unittest import socket +import ssl as ssllib from unittest import mock from asyncio import coroutine as coro import aiosocks.constants as c @@ -256,6 +257,21 @@ class TestBaseSocksProtocol(unittest.TestCase): proto._negotiate_done = True proto.eof_received() + def test_make_ssl_proto(self): + loop_mock = mock.Mock() + app_proto = mock.Mock() + + ssl_context = ssllib.create_default_context() + proto = make_base(loop_mock, + ap_factory=lambda: app_proto, ssl=ssl_context) + proto.socks_request = fake_coroutine((None, None)) + proto._transport = mock.Mock() + self.loop.run_until_complete(proto.negotiate(None, None)) + + self.assertTrue(loop_mock._make_ssl_transport.called) + self.assertIs(loop_mock._make_ssl_transport.call_args[1]['sslcontext'], + ssl_context) + @mock.patch('aiosocks.protocols.asyncio.Task') def test_func_negotiate_cb_call(self, task_mock): loop_mock = mock.Mock()