示例#1
0
    def test_unverified_ssl(self):
        """ Test that bare HTTPSConnection can connect, make requests """
        pool = HTTPSConnectionPool(self.host, self.port)
        pool.ConnectionCls = UnverifiedHTTPSConnection

        with mock.patch('warnings.warn') as warn:
            r = yield from pool.request('GET', '/')
            self.assertEqual(r.status, 200)
            self.assertTrue(warn.called)

            call, = warn.call_args_list
            category = call[0][1]
            self.assertEqual(category, InsecureRequestWarning)
示例#2
0
    def test_unverified_ssl(self):
        """ Test that bare HTTPSConnection can connect, make requests """
        pool = HTTPSConnectionPool(self.host, self.port)
        pool.ConnectionCls = UnverifiedHTTPSConnection

        with mock.patch('warnings.warn') as warn:
            r = yield from pool.request('GET', '/')
            self.assertEqual(r.status, 200)
            self.assertTrue(warn.called)

            call, = warn.call_args_list
            category = call[0][1]
            self.assertEqual(category, InsecureRequestWarning)
示例#3
0
 def test_no_ssl(self):
     pool = HTTPSConnectionPool(self.host, self.port)
     pool.ConnectionCls = None
     self.assertRaises(SSLError, pool._new_conn)
     yield from self.aioAssertRaises(SSLError, pool.request, 'GET', '/')
示例#4
0
 def test_no_ssl(self):
     pool = HTTPSConnectionPool(self.host, self.port)
     pool.ConnectionCls = None
     self.assertRaises(SSLError, pool._new_conn)
     yield from self.aioAssertRaises(SSLError, pool.request, 'GET', '/')