Browse Source

Added test case to create ssl transport

main
nibrag 8 years ago
parent
commit
9c39c87689
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      tests/test_protocols.py

+ 16
- 0
tests/test_protocols.py View File

@@ -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()


Loading…
Cancel
Save