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: //usr/lib/python3.6/site-packages/ndg/httpsclient/test/__pycache__/test_https.cpython-36.pyc
3

��Z��@s�dZdZdZdZdZdZdZddlZejej	d	�ej
e�Zddl
Z
ddlZdd
lmZddlmZddlmZdd
lmZGdd�de
j�Zedkr�e
j�dS)z�unit tests module for ndg.httpsclient.https.HTTPSconnection class

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)�level)�SSL)�	Constants)�HTTPSConnection)�ServerSSLCertVerificationc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�TestHTTPSConnectionz+Test ndg HTTPS client HTTPSConnection classcCsHttjtjd�}|j�|jdd�|j�}td|j��|j	�dS)N)�port�GET�/z
Response = %s)
rr�HOSTNAME�PORT�connect�request�getresponse�print�read�close)�self�conn�resp�r� /usr/lib/python3.6/test_https.py�test01_openszTestHTTPSConnection.test01_opencCs$ttjtjd�}|jtj|j�dS)N)r)rrrZPORT2�assertRaises�socket�errorr
)rrrrr�test02_open_fails$sz%TestHTTPSConnection.test02_open_failscCsltjtj�}dd�}|jtj|�|jd�|jdtj�t	tj
tj|d�}|j�|j
tj|jdd�dS)NcSstjd|j��|S)Nz/SSL peer certificate verification failed for %r)�log�debugZget_subject)r�x509�errnum�errdepth�preverify_okrrr�verify_callback+s
zRTestHTTPSConnection.test03_ssl_verification_of_peer_fails.<locals>.verify_callback�	)r�ssl_contextr	r
)r�Context�TLSv1_2_METHOD�
set_verify�VERIFY_PEER�set_verify_depth�load_verify_locationsrZUNITTEST_DIRrrrr
r�Errorr)r�ctxr#rrrr�%test03_ssl_verification_of_peer_fails(s

z9TestHTTPSConnection.test03_ssl_verification_of_peer_failscCs|tjtj�}dd�}|jtj|�|jd�|jdtj�t	tj
tj|d�}|j�|j
dd�|j�}td|j��dS)NcSs|S)Nr)rrr r!r"rrr�<lambda>>szNTestHTTPSConnection.test03_ssl_verification_of_peer_succeeds.<locals>.<lambda>r$)rr%r	r
z
Response = %s)rr&r'r(r)r*r+r�
CACERT_DIRrrrr
rrrr)rr-r#rrrrr�(test03_ssl_verification_of_peer_succeeds;s

z<TestHTTPSConnection.test03_ssl_verification_of_peer_succeedscCs�tjtj�}tdd�}|j�}|jtj|�|jd�|jdt	j
�tt	jt	j
|d�}|j�|jdd�|j�}td|j��dS)N�	localhost)�hostnamer$)rr%r	r
z
Response = %s)rr&r'r�get_verify_server_cert_funcr(r)r*r+rr0rrrr
rrrr)rr-�verificationr#rrrrr�*test04_ssl_verification_with_subj_alt_nameNs


z>TestHTTPSConnection.test04_ssl_verification_with_subj_alt_namecCs�tjtj�}tddd�}|j�}|jtj|�|jd�|jdt	j
�tt	jt	j
|d�}|j�|jdd�|j�}td|j��dS)	Nr2F)r3Zsubj_alt_name_matchr$)rr%r	r
z
Response = %s)rr&r'rr4r(r)r*r+rr0rrrr
rrrr)rr-r5r#rrrrr�-test04_ssl_verification_with_subj_common_nameas

zATestHTTPSConnection.test04_ssl_verification_with_subj_common_nameN)
�__name__�
__module__�__qualname__�__doc__rrr.r1r6r7rrrrrsr�__main__)r;�
__author__Z__date__Z
__copyright__Z__license__Z__contact__Z__revision__ZloggingZbasicConfig�DEBUGZ	getLoggerr8rZunittestrZOpenSSLrZndg.httpsclient.testrZndg.httpsclient.httpsrZ%ndg.httpsclient.ssl_peer_verificationrZTestCaser�mainrrrr�<module>s$
`