/Oc @ s d Z d Z d Z d Z d Z d Z d Z d d l Z e j d e j e j
e Z d d l
Z
d d l Z d d
l m Z d d l m Z d d l m Z d d
l m Z d e
j f d YZ e d k r e
j n d S( s unit tests module for ndg.httpsclient.https.HTTPSconnection class
PyOpenSSL utility to make a httplib-like interface suitable for use with
urllib2
s P J Kershaw (STFC)s 06/01/12s2 (C) 2012 Science and Technology Facilities Councils- BSD - see LICENSE file in top-level directorys Philip.Kershaw@stfc.ac.uks $Id$iNt level( t SSL( t Constants( t HTTPSConnection( t ServerSSLCertVerificationt TestHTTPSConnectionc B sD e Z d Z d Z d Z d Z d Z d Z d Z RS( s+ Test ndg HTTPS client HTTPSConnection classc C s[ t t j d t j } | j | j d d | j } d | j GH| j d S( Nt portt GETt /s
Response = %s( R R t HOSTNAMEt PORTt connectt requestt getresponset readt close( t selft connt resp( ( sC /usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt test01_open s
c C s2 t t j d t j } | j t j | j d S( NR ( R R R t PORT2t failUnlessRaisest sockett errorR ( R R ( ( sC /usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt test02_open_fails$ s c C s t j t j } d } | j t j | | j d | j d t j t
t j d t j d | } | j
| j t j | j d d d S( Nc S s t j d | j | S( Ns/ SSL peer certificate verification failed for %r( t logt debugt get_subject( R t x509t errnumt errdeptht preverify_ok( ( sC /usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt verify_callback+ s
i R t ssl_contextR R ( R t Contextt SSLv3_METHODt
set_verifyt VERIFY_PEERt set_verify_deptht load_verify_locationst NoneR t UNITTEST_DIRR R R
R R t ErrorR ( R t ctxR R ( ( sC /usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt% test03_ssl_verification_of_peer_fails( s
c C s t j t j } d } | j t j | | j d | j d t j t
t j d t j d | } | j
| j d d | j } d | j GHd S( Nc S s | S( N( ( R R R R R ( ( sC /usr/lib/python2.7/site-packages/ndg/httpsclient/test/test_https.pyt <lambda>>