
                            S SK Jr  S SKrS SKJr  S SKr S SKJr  S SKJ	r	J
r
  S SKJrJr  SS jrSS jrS	S
KJr  S	SKJr  S	SKJrJrJrJrJrJr  S	SKJrJrJr  S	S
KJr    " S S5      r!g! \ a     NIf = f)    )annotationsN)mock)x509)FILETYPE_PEMload_certificate)_dnsname_to_stdlibget_subj_alt_namec                      SSK Jn   U " 5         g ! [         a$  n[        R                  " SU< 35         S nAg S nAff = f)Nr   )inject_into_urllib3zCould not import PyOpenSSL: )urllib3.contrib.pyopensslr   ImportErrorpytestskip)r   es     Bplatform/gsutil/third_party/urllib3/test/contrib/test_pyopenssl.pysetup_moduler      s7    :A :21%899:s    
>9>c                 @     SSK Jn   U " 5         g ! [         a     g f = f)Nr   extract_from_urllib3)r   r   r   r   s    r   teardown_moduler      s"    B s    
   )TestSSL)TestUtilSSL)TestHTTPS_IPV4SANTestHTTPS_IPV6SANTestHTTPS_TLSv1TestHTTPS_TLSv1_1TestHTTPS_TLSv1_2TestHTTPS_TLSv1_3)TestClientCertsTestSNITestSocketClosingc                  j    \ rS rSrSrS
S jrS
S jrS
S jr\R                  " S5      SS j5       r
Srg	)TestPyOpenSSLHelpers:   z'
Tests for PyOpenSSL helper functions.
c                .    SnSn[        U5      U:X  d   eg)zH
We can convert a dnsname to a native string when the domain is simple.
u   उदाहरण.परीकzxn--p1b6ci4b4b3a.xn--11b5bs8dNr   selfnameexpected_results      r   test_dnsname_to_stdlib_simple2TestPyOpenSSLHelpers.test_dnsname_to_stdlib_simple?   s!     19!$'?:::    c                .    SnSn[        U5      U:X  d   eg)zE
If there is a . in front of the domain name we correctly encode it.
u    .उदाहरण.परीकz.xn--p1b6ci4b4b3a.xn--11b5bs8dNr'   r(   s      r   %test_dnsname_to_stdlib_leading_period:TestPyOpenSSLHelpers.test_dnsname_to_stdlib_leading_periodH   s!     2:!$'?:::r.   c                .    SnSn[        U5      U:X  d   eg)zX
If there's a wildcard character in the front of the string we handle it
appropriately.
u!   *.उदाहरण.परीकz*.xn--p1b6ci4b4b3a.xn--11b5bs8dNr'   r(   s      r   $test_dnsname_to_stdlib_leading_splat9TestPyOpenSSLHelpers.test_dnsname_to_stdlib_leading_splatQ   s!    
 3;!$'?:::r.   z%urllib3.contrib.pyopenssl.log.warningc                   [         R                  R                  [         R                  R                  [        5      S5      n[        U5       n[        [        UR                  5       5      nSSS5        [        W5      / :X  d   eUR                  S:X  d   e[        UR                  S   S   [        R                  5      (       d   eg! , (       d  f       Nc= f)zo
If a certificate has two subject alternative names, cryptography raises
an x509.DuplicateExtension exception.
zduplicate_san.pemN   r   )ospathjoindirname__file__openr   r   readr	   
call_count
isinstance	call_argsr   DuplicateExtension)r)   mock_warningr8   fpcerts        r   test_get_subj_alt_name+TestPyOpenSSLHelpers.test_get_subj_alt_name[   s     ww||BGGOOH57JK$Z2#L"'')<D  !&",,,&&!+++,003A68O8OPPPP Zs   C		
C NreturnNone)rB   zmock.MagicMockrI   rJ   )__name__
__module____qualname____firstlineno____doc__r,   r0   r3   r   patchrE   __static_attributes__rG   r.   r   r$   r$   :   s6    ;;; 
ZZ78Q 9Qr.   r$   rH   )"
__future__r   r7   unittestr   r   cryptographyr   OpenSSL.cryptor   r   r   r   r	   r   r   r   test_sslr   	test_utilr   with_dummyserver.test_httpsr   r   r   r   r   r   !with_dummyserver.test_socketlevelr    r!   r"   TestSocketSSLr$   rG   r.   r   <module>r[      sp    " 	  		!
 P
:  #  

.Q .QU  		s   A- -A65A6