aboutsummaryrefslogtreecommitdiff
path: root/test/with_dummyserver/test_no_ssl.py
blob: f266d49cdad3d74c0cbf7b77e184b267640caf7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
Test connections without the builtin ssl module

Note: Import urllib3 inside the test functions to get the importblocker to work
"""
from ..test_no_ssl import TestWithoutSSL

from dummyserver.testcase import (
        HTTPDummyServerTestCase, HTTPSDummyServerTestCase)


class TestHTTPWithoutSSL(HTTPDummyServerTestCase, TestWithoutSSL):
    def test_simple(self):
        import urllib3

        pool = urllib3.HTTPConnectionPool(self.host, self.port)
        r = pool.request('GET', '/')
        self.assertEqual(r.status, 200, r.data)


class TestHTTPSWithoutSSL(HTTPSDummyServerTestCase, TestWithoutSSL):
    def test_simple(self):
        import urllib3

        pool = urllib3.HTTPSConnectionPool(self.host, self.port)
        try:
            pool.request('GET', '/')
        except urllib3.exceptions.SSLError as e:
            self.assertTrue('SSL module is not available' in str(e))