<s> """<STR_LIT>""" <EOL> import os <EOL> import ssl <EOL> import unittest <EOL> from nose . plugins . attrib import attr <EOL> import boto <EOL> from boto import exception , https_connection <EOL> from boto . gs . connection import GSConnection <EOL> from boto . s3 . connection import S3Connection <EOL> DEFAULT_CA_CERTS_FILE = os . path . join ( <EOL> os . path . dirname ( os . path . abspath ( __file__ ) ) , '<STR_LIT>' ) <EOL> PROXY_HOST = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> PROXY_PORT = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> INVALID_HOSTNAME_HOST = os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> @ attr ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> class CertValidationTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> for section in boto . config . sections ( ) : <EOL> boto . config . remove_section ( section ) <EOL> boto . config . add_section ( '<STR_LIT>' ) <EOL> boto . config . setbool ( '<STR_LIT>' , '<STR_LIT>' , True ) <EOL> boto . config . add_section ( '<STR_LIT>' ) <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def enableProxy ( self ) : <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , PROXY_HOST ) <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , PROXY_PORT ) <EOL> def assertConnectionThrows ( self , connection_class , error ) : <EOL> conn = connection_class ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertRaises ( error , conn . get_all_buckets ) <EOL> def do_test_valid_cert ( self ) : <EOL> self . assertConnectionThrows ( S3Connection , exception . S3ResponseError ) <EOL> self . assertConnectionThrows ( GSConnection , exception . GSResponseError ) <EOL> def test_valid_cert ( self ) : <EOL> self . do_test_valid_cert ( ) <EOL> def test_valid_cert_with_proxy ( self ) : <EOL> self . enableProxy ( ) <EOL> self . do_test_valid_cert ( ) <EOL> def do_test_invalid_signature ( self ) : <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , DEFAULT_CA_CERTS_FILE ) <EOL> self . assertConnectionThrows ( S3Connection , ssl . SSLError ) <EOL> self . assertConnectionThrows ( GSConnection , ssl . SSLError ) <EOL> def test_invalid_signature ( self ) : <EOL> self . do_test_invalid_signature ( ) <EOL> def test_invalid_signature_with_proxy ( self ) : <EOL> self . enableProxy ( ) <EOL> self . do_test_invalid_signature ( ) <EOL> def do_test_invalid_host ( self ) : <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , INVALID_HOSTNAME_HOST ) <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , INVALID_HOSTNAME_HOST ) <EOL> self . assertConnectionThrows ( S3Connection , ssl . SSLError ) <EOL> self . assertConnectionThrows ( GSConnection , ssl . SSLError ) <EOL> def do_test_invalid_host ( self ) : <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , INVALID_HOSTNAME_HOST ) <EOL> boto . config . set ( '<STR_LIT>' , '<STR_LIT>' , INVALID_HOSTNAME_HOST ) <EOL> self . assertConnectionThrows ( <EOL> S3Connection , https_connection . InvalidCertificateException ) <EOL> self . assertConnectionThrows ( <EOL> GSConnection , https_connection . InvalidCertificateException ) <EOL> def test_invalid_host ( self ) : <EOL> self . do_test_invalid_host ( ) <EOL> def test_invalid_host_with_proxy ( self ) : <EOL> self . enableProxy ( ) <EOL> self . do_test_invalid_host ( ) </s>
