summaryrefslogtreecommitdiffstats
path: root/test/modules/http2/test_002_curl_basics.py
blob: bb03bd84f3dabc7bed809439e75650c06a371496 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import pytest

from .env import H2Conf


class TestCurlBasics:

    @pytest.fixture(autouse=True, scope='class')
    def _class_scope(self, env):
        conf = H2Conf(env)
        conf.add_vhost_test1()
        conf.add_vhost_test2()
        conf.install()
        assert env.apache_restart() == 0

    # check that we see the correct documents when using the test1 server name over http:
    def test_h2_002_01(self, env):
        url = env.mkurl("http", "test1", "/alive.json")
        r = env.curl_get(url, 5)
        assert r.response["status"] == 200
        assert "HTTP/1.1" == r.response["protocol"]
        assert r.response["json"]["alive"] is True
        assert r.response["json"]["host"] == "test1"

    # check that we see the correct documents when using the test1 server name over https:
    def test_h2_002_02(self, env):
        url = env.mkurl("https", "test1", "/alive.json")
        r = env.curl_get(url, 5)
        assert r.response["status"] == 200
        assert r.response["json"]["alive"] is True
        assert "test1" == r.response["json"]["host"]
        assert r.response["header"]["content-type"] == "application/json"

    # enforce HTTP/1.1
    def test_h2_002_03(self, env):
        url = env.mkurl("https", "test1", "/alive.json")
        r = env.curl_get(url, 5, options=["--http1.1"])
        assert r.response["status"] == 200
        assert r.response["protocol"] == "HTTP/1.1"

    # enforce HTTP/2
    def test_h2_002_04(self, env):
        url = env.mkurl("https", "test1", "/alive.json")
        r = env.curl_get(url, 5, options=["--http2"])
        assert r.response["status"] == 200
        assert r.response["protocol"] == "HTTP/2"

    # default is HTTP/2 on this host
    def test_h2_002_04b(self, env):
        url = env.mkurl("https", "test1", "/alive.json")
        r = env.curl_get(url, 5)
        assert r.response["status"] == 200
        assert r.response["protocol"] == "HTTP/2"
        assert r.response["json"]["host"] == "test1"

    # although, without ALPN, we cannot select it
    def test_h2_002_05(self, env):
        url = env.mkurl("https", "test1", "/alive.json")
        r = env.curl_get(url, 5, options=["--no-alpn"])
        assert r.response["status"] == 200
        assert r.response["protocol"] == "HTTP/1.1"
        assert r.response["json"]["host"] == "test1"

    # default is HTTP/1.1 on the other
    def test_h2_002_06(self, env):
        url = env.mkurl("https", "test2", "/alive.json")
        r = env.curl_get(url, 5)
        assert r.response["status"] == 200
        assert r.response["protocol"] == "HTTP/1.1"
        assert r.response["json"]["host"] == "test2"