HEX
Server: nginx/1.30.4
System: Linux d-twindigital-web-1.host-ed.eu 4.18.0-553.141.2.el8_10.x86_64 #1 SMP Wed Jul 8 10:28:18 EDT 2026 x86_64
User: u_twindigital_html (1009)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/ndg/httpsclient/test/__pycache__/test_urllib2.cpython-36.pyc
3

��Z
�@s�dZdZdZdZdZdZdZddlZejdd	kr@dd
l	m
Z
ndd
lm
Z
ddlZddl
mZddlmZdd
lmZddlmZGdd�dej�Zedkr�ej�dS)z�unit tests module for ndg.httpsclient.urllib2_build_opener module

PyOpenSSL utility to make a httplib-like interface suitable for use with 
urllib2
zP J Kershaw (STFC)z06/01/12z2(C) 2012 Science and Technology Facilities Councilz-BSD - see LICENSE file in top-level directoryzPhilip.Kershaw@stfc.ac.ukz$Id$�N�)�URLError)�SSL)�	Constants)�build_opener)�ServerSSLCertVerificationc@sJeZdZdZdd�Zdd�Zejej	dkd�dd	��Z
d
d�Zdd
�ZdS)�Urllib2TestCasez$Unit tests for urllib2 functionalitycCst�}|j|�dS)N)r�
assertTrue)�self�opener�r�"/usr/lib/python3.6/test_urllib2.py�test01_urllib2_build_openersz+Urllib2TestCase.test01_urllib2_build_openercCs0t�}|jtj�}|j|�td|j��dS)Nzres = %s)r�openr�TEST_URIr	�print�read)r
r�resrrr
�test02_open"s
zUrllib2TestCase.test02_openZ	localhostzSkip non-local hostcCst�}|jt|jtj�dS)N)r�assertRaisesrrrZ	TEST_URI2)r
rrrr
�test03_open_fails_unknown_loc)sz-Urllib2TestCase.test03_open_fails_unknown_loccCsPtjtj�}dd�}|jtj|�|jdd�t|d�}|jtj|j	t
j�dS)NcSs|S)Nr)ZconnZx509ZerrnumZerrdepthZpreverify_okrrr
�<lambda>1szJUrllib2TestCase.test04_open_peer_cert_verification_fails.<locals>.<lambda>z./)�ssl_context)r�Context�TLSv1_2_METHOD�
set_verify�VERIFY_PEER�load_verify_locationsrr�Errorrrr)r
�ctxZverify_callbackrrrr
�(test04_open_peer_cert_verification_fails.s
z8Urllib2TestCase.test04_open_peer_cert_verification_failscCs�tjtj�}tjjdd�}t|�dkr4d|d}ntj}t|d�}|j�}|j	tj
|�|jd�|jdtj
�t|d�}|jtj�}|j|�td|j��dS)	N�.�z*.)Zhostname�	)rzres = %s���)rrrr�HOSTNAME�split�lenrZget_verify_server_cert_funcrrZset_verify_depthrZ
CACERT_DIRrrrr	rr)r
rZsplit_hostnameZ	_hostnameZserver_ssl_verifyZverify_callback_rrrrr
�,test05_open_with_subj_alt_names_verification9s



z<Urllib2TestCase.test05_open_with_subj_alt_names_verificationN)
�__name__�
__module__�__qualname__�__doc__rr�unittestZskipIfrr%rr r(rrrr
rsr�__main__)r,�
__author__Z__date__Z
__copyright__Z__license__Z__contact__Z__revision__�sys�version_infoZurllib.errorrZurllib2r-ZOpenSSLrZndg.httpsclient.testrZ$ndg.httpsclient.urllib2_build_openerrZ%ndg.httpsclient.ssl_peer_verificationrZTestCaserr)�mainrrrr
�<module>s$=