Spade

Mini Shell

Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/ndg/httpsclient/test/
Upload File

[Home] [System Details] [Kill Me]
Current File:~$ //proc/self/root/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyc

�
�/Oc@s�dZdZdZdZdZdZdZddlZejd	ej	�ej
e�Zddl
Z
ddlZdd
lmZddlmZddlmZdd
lmZde
jfd��YZedkr�e
j�ndS(s�unit
tests module for ndg.httpsclient.https.HTTPSconnection class

PyOpenSSL utility to make a httplib-like interface suitable for use with 
urllib2
sP J Kershaw (STFC)s06/01/12s2(C) 2012 Science and Technology Facilities
Councils-BSD - see LICENSE file in top-level
directorysPhilip.Kershaw@stfc.ac.uks$Id$i����Ntlevel(tSSL(t	Constants(tHTTPSConnection(tServerSSLCertVerificationtTestHTTPSConnectioncBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s+Test
ndg HTTPS client HTTPSConnection
classcCs[ttjdtj�}|j�|jdd�|j�}d|j�GH|j�dS(NtporttGETt/s
Response
=
%s(	RRtHOSTNAMEtPORTtconnecttrequesttgetresponsetreadtclose(tselftconntresp((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyttest01_opens
cCs2ttjdtj�}|jtj|j�dS(NR(RRR	tPORT2tfailUnlessRaisestsocketterrorR(RR((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyttest02_open_fails$scCs�tjtj�}d�}|jtj|�|jd�|jdtj	�t
tjdtjd|�}|j
�|jtj|jdd�dS(NcSstjd|j��|S(Ns/SSL
peer certificate verification failed for
%r(tlogtdebugtget_subject(Rtx509terrnumterrdepthtpreverify_ok((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pytverify_callback+s	
i	Rtssl_contextRR(RtContexttSSLv3_METHODt
set_verifytVERIFY_PEERtset_verify_depthtload_verify_locationstNoneRtUNITTEST_DIRRR	R
RRtErrorR(RtctxR
R((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt%test03_ssl_verification_of_peer_fails(s	
	
cCs�tjtj�}d�}|jtj|�|jd�|jdtj	�t
tjdtjd|�}|j
�|jdd�|j�}d|j�GHdS(NcSs|S(N((RRRRR((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt<lambda>>si	RR!RRs
Response
= %s(RR"R#R$R%R&R'R(Rt
CACERT_DIRRR	R
RRR
R(RR+R
RR((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt(test03_ssl_verification_of_peer_succeeds;s	
	
cCs�tjtj�}tdd�}|jtj|�|jd�|jdt	j
�tt	jdt	j
d|�}|j�|jdd�|j�}d|j�GHdS(	Nthostnamet	localhosti	RR!RRs
Response
= %s(RR"R#RR$R%R&R'R(RR.RR	R
RRR
R(RR+R
RR((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt*test04_ssl_verification_with_subj_alt_nameNs
	
cCs�tjtj�}tdddt�}|jtj|�|jd�|jdt
j�tt
j
dt
jd|�}|j�|jdd�|j�}d	|j�GHdS(
NR0R1tsubj_alt_name_matchi	RR!RRs
Response =
%s(RR"R#RtFalseR$R%R&R'R(RR.RR	R
RRR
R(RR+R
RR((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt-test04_ssl_verification_with_subj_common_name`s	
	
(	t__name__t
__module__t__doc__RRR,R/R2R5(((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyRs					t__main__(R8t
__author__t__date__t
__copyright__t__license__t__contact__t__revision__tloggingtbasicConfigtDEBUGt	getLoggerR6RtunittestRtOpenSSLRtndg.httpsclient.testRtndg.httpsclient.httpsRt%ndg.httpsclient.ssl_peer_verificationRtTestCaseRtmain(((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt<module>s$]