Exemplo n.º 1
0
    def test_verified(self):
        https_pool = HTTPSConnectionPool(self.host, self.port,
                                         cert_reqs='CERT_REQUIRED',
                                         ca_certs=DEFAULT_CA)

        conn = https_pool._new_conn()
        self.assertEqual(conn.__class__, VerifiedHTTPSConnection)

        with mock.patch('warnings.warn') as warn:
            r = yield from https_pool.request('GET', '/')
            self.assertEqual(r.status, 200)
            self.assertTrue(len(warn.call_args_list)==0, warn.call_args_list)
Exemplo n.º 2
0
    def test_verified(self):
        https_pool = HTTPSConnectionPool(self.host,
                                         self.port,
                                         cert_reqs='CERT_REQUIRED',
                                         ca_certs=DEFAULT_CA)

        conn = https_pool._new_conn()
        self.assertEqual(conn.__class__, VerifiedHTTPSConnection)

        with mock.patch('warnings.warn') as warn:
            r = yield from https_pool.request('GET', '/')
            self.assertEqual(r.status, 200)
            self.assertTrue(len(warn.call_args_list) == 0, warn.call_args_list)
Exemplo n.º 3
0
 def test_tunnel(self):
     """ test the _tunnel behavior """
     timeout = Timeout(total=None)
     https_pool = HTTPSConnectionPool(self.host, self.port, timeout=timeout,
                                      cert_reqs='CERT_NONE')
     conn = https_pool._new_conn()
     try:
         conn.set_tunnel(self.host, self.port)
     except AttributeError: # python 2.6
         conn._set_tunnel(self.host, self.port)
     conn._tunnel = mock.Mock(return_value=iter([None, None, None]))
     yield from https_pool._make_request(conn, 'GET', '/')
     conn._tunnel.assert_called_once_with()
Exemplo n.º 4
0
 def test_tunnel(self):
     """ test the _tunnel behavior """
     timeout = Timeout(total=None)
     https_pool = HTTPSConnectionPool(self.host,
                                      self.port,
                                      timeout=timeout,
                                      cert_reqs='CERT_NONE')
     conn = https_pool._new_conn()
     try:
         conn.set_tunnel(self.host, self.port)
     except AttributeError:  # python 2.6
         conn._set_tunnel(self.host, self.port)
     conn._tunnel = mock.Mock(return_value=iter([None, None, None]))
     yield from https_pool._make_request(conn, 'GET', '/')
     conn._tunnel.assert_called_once_with()