xref: /unit/test/test_routing_tls.py (revision 2592:e079c44a8340)
1from unit.applications.tls import ApplicationTLS
2
3prerequisites = {'modules': {'openssl': 'any'}}
4
5client = ApplicationTLS()
6
7
8def test_routes_match_scheme_tls():
9    client.certificate()
10
11    assert 'success' in client.conf(
12        {
13            "listeners": {
14                "*:8080": {"pass": "routes"},
15                "*:8081": {
16                    "pass": "routes",
17                    "tls": {"certificate": 'default'},
18                },
19            },
20            "routes": [
21                {"match": {"scheme": "http"}, "action": {"return": 200}},
22                {"match": {"scheme": "https"}, "action": {"return": 201}},
23            ],
24            "applications": {},
25        }
26    ), 'scheme configure'
27
28    assert client.get()['status'] == 200, 'http'
29    assert client.get_ssl(port=8081)['status'] == 201, 'https'
30