• File: test_https.pyo
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/test_https.pyo
  • Date Modified: 10/31/2014 10:04 AM
  • File size: 4.88 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

/Oc@sdZdZdZdZdZdZdZddlZejd	ej	ej
eZddl
Z
ddlZdd
lmZddlmZddlmZdd
lmZde
jfdYZedkre
jndS(sunit 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$iNtlevel(tSSL(t	Constants(tHTTPSConnection(tServerSSLCertVerificationtTestHTTPSConnectioncBsDeZdZdZdZdZdZdZdZRS(s+Test ndg HTTPS client HTTPSConnection classcCs[ttjdtj}|j|jdd|j}d|jGH|jdS(NtporttGETt/s
Response = %s(	RRtHOSTNAMEtPORTtconnecttrequesttgetresponsetreadtclose(tselftconntresp((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyttest01_opens
cCs2ttjdtj}|jtj|jdS(NR(RRR	tPORT2tfailUnlessRaisestsocketterrorR(RR((sC/usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyttest02_open_fails$scCstjtj}d}|jtj||jd|jdtj	t
tjdtjd|}|j
|jtj|jdddS(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	
	
cCstjtj}d}|jtj||jd|jdtj	t
tjdtjd|}|j
|jdd|j}d|jGHdS(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	
	
cCstjtj}tdd}|jtj||jd|jdt	j
tt	jdt	j
d|}|j|jdd|j}d|jGHdS(	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
	
cCstjtj}tdddt}|jtj||jd|jdt
jtt
j
dt
jd|}|j|jdd|j}d	|jGHdS(
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$]