File: test_300_interim.py

package info (click to toggle)
apache2 2.4.65-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,128 kB
  • sloc: ansic: 211,971; python: 13,977; perl: 11,308; sh: 6,952; php: 1,315; javascript: 1,314; awk: 749; makefile: 712; lex: 374; yacc: 161; xml: 2
file content (40 lines) | stat: -rw-r--r-- 1,503 bytes parent folder | download | duplicates (6)
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
import pytest

from .env import H2Conf, H2TestEnv


@pytest.mark.skipif(condition=H2TestEnv.is_unsupported, reason="mod_http2 not supported here")
class TestInterimResponses:

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

    def setup_method(self, method):
        print("setup_method: %s" % method.__name__)

    def teardown_method(self, method):
        print("teardown_method: %s" % method.__name__)

    # check that we normally do not see an interim response
    def test_h2_300_01(self, env):
        url = env.mkurl("https", "test1", "/index.html")
        r = env.curl_post_data(url, 'XYZ')
        assert r.response["status"] == 200
        assert "previous" not in r.response

    # check that we see an interim response when we ask for it
    def test_h2_300_02(self, env):
        url = env.mkurl("https", "cgi", "/echo.py")
        r = env.curl_post_data(url, 'XYZ', options=["-H", "expect: 100-continue"])
        assert r.response["status"] == 200
        assert "previous" in r.response
        assert 100 == r.response["previous"]["status"] 

    # check proper answer on unexpected
    def test_h2_300_03(self, env):
        url = env.mkurl("https", "cgi", "/echo.py")
        r = env.curl_post_data(url, 'XYZ', options=["-H", "expect: the-unexpected"])
        assert 417 == r.response["status"]
        assert "previous" not in r.response