Your IP : 216.73.216.213
��YfJ �
@ s� d Z d d l Z d d l Z d d l m Z y d d l Z Wn e k
rX d Z Yn Xd d l Z d d l m Z d d l m Z d d l m Z e j
e d k d � Gd d � d e j � � Z e
d
k r� e j � d S)zTests for asyncio/sslproto.py.� N)�mock)�log)�sslproto)�
test_utilsz
No ssl modulec s� e Z d Z � f d d � Z d d d � Z d d d � Z d d � Z d
d � Z d d
� Z d d � Z d d � Z
d d � Z � S)�SslProtoHandshakeTestsc s0 t � j � t j � | _ | j | j � d S)N)�super�setUp�asyncioZnew_event_loop�loopZset_event_loop)�self)� __class__� �D/opt/alt/python35/lib64/python3.5/test/test_asyncio/test_sslproto.pyr s
zSslProtoHandshakeTests.setUpNc C sc t j � } t j � } t j | j | | | � } | j | j j � | � | j
| j j � | S)N)r Zdummy_ssl_contextr ZProtocolr ZSSLProtocolr
�assertIs�_app_transportZget_protocolZ
addCleanup�close)r �waiterZ
sslcontextZ app_proto�protor
r
r �ssl_protocol s z#SslProtoHandshakeTests.ssl_protocolc C s t j � } t j � } d | j _ | r9 | | j _ n d d � } | | j _ t j d d | �� | j | � Wd QRX| S)N� c S s g S)Nr
)�callbackr
r
r �mock_handshake( s z>SslProtoHandshakeTests.connection_made.<locals>.mock_handshakezasyncio.sslproto._SSLPipe�return_value)r ZMockZshutdownr �do_handshakeZside_effectZpatch�connection_made)r � ssl_protor � transportZsslpiper r
r
r r ! s z&SslProtoHandshakeTests.connection_madec s� t j d | j � } | j | � } t j d | j � � � f d d � } | j � | j | | � t j � � | j j � � Wd QRXd S)Nr
c s$ t � } | | � � j d � g S)N)� ExceptionZ
set_result)r �exc)�
handshake_futr
r r 6 s
zBSslProtoHandshakeTests.test_cancel_handshake.<locals>.do_handshake) r �Futurer
r Zcancelr r Zdisable_loggerZrun_until_complete)r r r r r
)r r �test_cancel_handshake/ s
z,SslProtoHandshakeTests.test_cancel_handshakec C se t j d | j � } | j | � } | j | � | j � t j | j � | j | j � t
� d S)Nr
)r r r
r r Zeof_receivedr �run_briefly�assertIsInstance� exception�ConnectionResetError)r r r r
r
r �test_eof_received_waiterB s
z/SslProtoHandshakeTests.test_eof_received_waiterc C so t j d | j � } | j | � } t j j � } t j j t j � z | j
d � Wd t j j | � Xd S)Nr
)r r r
r r ZloggerZgetEffectiveLevelZsetLevel�loggingZFATALZ_fatal_error)r r r Z log_levelr
r
r �test_fatal_error_no_name_errorJ s z5SslProtoHandshakeTests.test_fatal_error_no_name_errorc C sh t j d | j � } | j | � } | j | � | j t � t j | j � | j | j
� t � d S)Nr
)r r r
r r �connection_lost�ConnectionAbortedErrorr r"