1import pytest
2
3from .env import H2Conf
4
5
6class TestProxyServerHeader:
7
8    @pytest.fixture(autouse=True, scope='class')
9    def _class_scope(self, env):
10        conf = H2Conf(env, extras={
11            f'cgi.{env.http_tld}': [
12                "Header unset Server",
13                "Header always set Server cgi",
14            ]
15        })
16        conf.add_vhost_cgi(proxy_self=True, h2proxy_self=False)
17        conf.install()
18        assert env.apache_restart() == 0
19
20    def setup_method(self, method):
21        print("setup_method: %s" % method.__name__)
22
23    def teardown_method(self, method):
24        print("teardown_method: %s" % method.__name__)
25
26    def test_h2_501_01(self, env):
27        url = env.mkurl("https", "cgi", "/proxy/hello.py")
28        r = env.curl_get(url, 5)
29        assert r.response["status"] == 200
30        assert "HTTP/1.1" == r.response["json"]["protocol"]
31        assert "" == r.response["json"]["https"]
32        assert "" == r.response["json"]["ssl_protocol"]
33        assert "" == r.response["json"]["h2"]
34        assert "" == r.response["json"]["h2push"]
35        assert "cgi" == r.response["header"]["server"]
36