xref: /unit/test/test_php_application.py (revision 2073:bc6ad31ce286)
12054Szelenkov@nginx.comimport getpass
21367Szelenkov@nginx.comimport os
31529Szelenkov@nginx.comimport re
41367Szelenkov@nginx.comimport shutil
51850Smax.romanov@nginx.comimport signal
61529Szelenkov@nginx.comimport time
71477Szelenkov@nginx.com
81635Szelenkov@nginx.comimport pytest
91019Szelenkov@nginx.comfrom unit.applications.lang.php import TestApplicationPHP
101730Szelenkov@nginx.comfrom unit.option import option
11675Szelenkov@nginx.com
121848Szelenkov@nginx.com
131019Szelenkov@nginx.comclass TestPHPApplication(TestApplicationPHP):
141467Szelenkov@nginx.com    prerequisites = {'modules': {'php': 'all'}}
15675Szelenkov@nginx.com
16982Szelenkov@nginx.com    def before_disable_functions(self):
17982Szelenkov@nginx.com        body = self.get()['body']
18982Szelenkov@nginx.com
191596Szelenkov@nginx.com        assert re.search(r'time: \d+', body), 'disable_functions before time'
201596Szelenkov@nginx.com        assert re.search(r'exec: \/\w+', body), 'disable_functions before exec'
21865Szelenkov@nginx.com
222054Szelenkov@nginx.com    def check_opcache(self):
232054Szelenkov@nginx.com        resp = self.get()
242054Szelenkov@nginx.com        assert resp['status'] == 200, 'status'
252054Szelenkov@nginx.com
262054Szelenkov@nginx.com        headers = resp['headers']
272054Szelenkov@nginx.com        if 'X-OPcache' in headers and headers['X-OPcache'] == '-1':
282054Szelenkov@nginx.com            pytest.skip('opcache is not supported')
292054Szelenkov@nginx.com
302054Szelenkov@nginx.com        return resp
312054Szelenkov@nginx.com
321381St.nateldemoura@f5.com    def set_opcache(self, app, val):
331596Szelenkov@nginx.com        assert 'success' in self.conf(
341770Szelenkov@nginx.com            {"admin": {"opcache.enable": val, "opcache.enable_cli": val}},
351596Szelenkov@nginx.com            'applications/' + app + '/options',
361381St.nateldemoura@f5.com        )
371381St.nateldemoura@f5.com
382054Szelenkov@nginx.com        r = self.check_opcache()
392054Szelenkov@nginx.com        assert r['headers']['X-OPcache'] == val, 'opcache value'
401381St.nateldemoura@f5.com
412054Szelenkov@nginx.com    def set_preload(self, preload):
422054Szelenkov@nginx.com        with open(option.temp_dir + '/php.ini', 'w') as f:
432054Szelenkov@nginx.com            f.write(
442054Szelenkov@nginx.com                """opcache.preload = %(test_dir)s/php/opcache/preload\
452054Szelenkov@nginx.com/%(preload)s
462054Szelenkov@nginx.comopcache.preload_user = %(user)s
472054Szelenkov@nginx.com"""
482054Szelenkov@nginx.com                % {
492054Szelenkov@nginx.com                    'test_dir': option.test_dir,
502054Szelenkov@nginx.com                    'preload': preload,
512054Szelenkov@nginx.com                    'user': option.user or getpass.getuser(),
522054Szelenkov@nginx.com                }
532054Szelenkov@nginx.com            )
541381St.nateldemoura@f5.com
552054Szelenkov@nginx.com        assert 'success' in self.conf(
562054Szelenkov@nginx.com            {"file": option.temp_dir + "/php.ini"},
572054Szelenkov@nginx.com            'applications/opcache/options',
582054Szelenkov@nginx.com        )
591381St.nateldemoura@f5.com
60675Szelenkov@nginx.com    def test_php_application_variables(self):
61675Szelenkov@nginx.com        self.load('variables')
62675Szelenkov@nginx.com
63675Szelenkov@nginx.com        body = 'Test body string.'
64675Szelenkov@nginx.com
651017Szelenkov@nginx.com        resp = self.post(
661017Szelenkov@nginx.com            headers={
671017Szelenkov@nginx.com                'Host': 'localhost',
681017Szelenkov@nginx.com                'Content-Type': 'text/html',
691017Szelenkov@nginx.com                'Custom-Header': 'blah',
701017Szelenkov@nginx.com                'Connection': 'close',
711017Szelenkov@nginx.com            },
721017Szelenkov@nginx.com            body=body,
731596Szelenkov@nginx.com            url='/index.php/blah?var=val',
741017Szelenkov@nginx.com        )
75675Szelenkov@nginx.com
761596Szelenkov@nginx.com        assert resp['status'] == 200, 'status'
77675Szelenkov@nginx.com        headers = resp['headers']
78675Szelenkov@nginx.com        header_server = headers.pop('Server')
791596Szelenkov@nginx.com        assert re.search(r'Unit/[\d\.]+', header_server), 'server header'
801596Szelenkov@nginx.com        assert (
811596Szelenkov@nginx.com            headers.pop('Server-Software') == header_server
821596Szelenkov@nginx.com        ), 'server software header'
83675Szelenkov@nginx.com
84675Szelenkov@nginx.com        date = headers.pop('Date')
851596Szelenkov@nginx.com        assert date[-4:] == ' GMT', 'date header timezone'
861596Szelenkov@nginx.com        assert (
871596Szelenkov@nginx.com            abs(self.date_to_sec_epoch(date) - self.sec_epoch()) < 5
881596Szelenkov@nginx.com        ), 'date header'
89675Szelenkov@nginx.com
90675Szelenkov@nginx.com        if 'X-Powered-By' in headers:
91675Szelenkov@nginx.com            headers.pop('X-Powered-By')
92675Szelenkov@nginx.com
93675Szelenkov@nginx.com        headers.pop('Content-type')
941596Szelenkov@nginx.com        assert headers == {
951596Szelenkov@nginx.com            'Connection': 'close',
961596Szelenkov@nginx.com            'Content-Length': str(len(body)),
971596Szelenkov@nginx.com            'Request-Method': 'POST',
981596Szelenkov@nginx.com            'Path-Info': '/blah',
991596Szelenkov@nginx.com            'Request-Uri': '/index.php/blah?var=val',
1001596Szelenkov@nginx.com            'Http-Host': 'localhost',
1011596Szelenkov@nginx.com            'Server-Protocol': 'HTTP/1.1',
1021596Szelenkov@nginx.com            'Custom-Header': 'blah',
1031596Szelenkov@nginx.com        }, 'headers'
1041596Szelenkov@nginx.com        assert resp['body'] == body, 'body'
105675Szelenkov@nginx.com
106894Szelenkov@nginx.com    def test_php_application_query_string(self):
107894Szelenkov@nginx.com        self.load('query_string')
108894Szelenkov@nginx.com
109894Szelenkov@nginx.com        resp = self.get(url='/?var1=val1&var2=val2')
110894Szelenkov@nginx.com
1111596Szelenkov@nginx.com        assert (
1121596Szelenkov@nginx.com            resp['headers']['Query-String'] == 'var1=val1&var2=val2'
1131596Szelenkov@nginx.com        ), 'query string'
114894Szelenkov@nginx.com
115894Szelenkov@nginx.com    def test_php_application_query_string_empty(self):
116894Szelenkov@nginx.com        self.load('query_string')
117894Szelenkov@nginx.com
118894Szelenkov@nginx.com        resp = self.get(url='/?')
119894Szelenkov@nginx.com
1201596Szelenkov@nginx.com        assert resp['status'] == 200, 'query string empty status'
1211596Szelenkov@nginx.com        assert resp['headers']['Query-String'] == '', 'query string empty'
122894Szelenkov@nginx.com
1231850Smax.romanov@nginx.com    def test_php_application_fastcgi_finish_request(self, unit_pid):
1241701Szelenkov@nginx.com        self.load('fastcgi_finish_request')
1251701Szelenkov@nginx.com
1261862Szelenkov@nginx.com        assert 'success' in self.conf(
1271862Szelenkov@nginx.com            {"admin": {"auto_globals_jit": "1"}},
1281862Szelenkov@nginx.com            'applications/fastcgi_finish_request/options',
1291862Szelenkov@nginx.com        )
1301862Szelenkov@nginx.com
1311701Szelenkov@nginx.com        assert self.get()['body'] == '0123'
1321701Szelenkov@nginx.com
1331862Szelenkov@nginx.com        os.kill(unit_pid, signal.SIGUSR1)
1341770Szelenkov@nginx.com
1351850Smax.romanov@nginx.com        errs = self.findall(r'Error in fastcgi_finish_request')
1361701Szelenkov@nginx.com
1371850Smax.romanov@nginx.com        assert len(errs) == 0, 'no error'
1381701Szelenkov@nginx.com
1391850Smax.romanov@nginx.com    def test_php_application_fastcgi_finish_request_2(self, unit_pid):
1401701Szelenkov@nginx.com        self.load('fastcgi_finish_request')
1411701Szelenkov@nginx.com
1421862Szelenkov@nginx.com        assert 'success' in self.conf(
1431862Szelenkov@nginx.com            {"admin": {"auto_globals_jit": "1"}},
1441862Szelenkov@nginx.com            'applications/fastcgi_finish_request/options',
1451862Szelenkov@nginx.com        )
1461862Szelenkov@nginx.com
1471701Szelenkov@nginx.com        resp = self.get(url='/?skip')
1481701Szelenkov@nginx.com        assert resp['status'] == 200
1491701Szelenkov@nginx.com        assert resp['body'] == ''
1501701Szelenkov@nginx.com
1511862Szelenkov@nginx.com        os.kill(unit_pid, signal.SIGUSR1)
1521701Szelenkov@nginx.com
1531850Smax.romanov@nginx.com        errs = self.findall(r'Error in fastcgi_finish_request')
1541701Szelenkov@nginx.com
1551850Smax.romanov@nginx.com        assert len(errs) == 0, 'no error'
1561701Szelenkov@nginx.com
157894Szelenkov@nginx.com    def test_php_application_query_string_absent(self):
158894Szelenkov@nginx.com        self.load('query_string')
159894Szelenkov@nginx.com
160894Szelenkov@nginx.com        resp = self.get()
161894Szelenkov@nginx.com
1621596Szelenkov@nginx.com        assert resp['status'] == 200, 'query string absent status'
1631596Szelenkov@nginx.com        assert resp['headers']['Query-String'] == '', 'query string absent'
164894Szelenkov@nginx.com
165675Szelenkov@nginx.com    def test_php_application_phpinfo(self):
166675Szelenkov@nginx.com        self.load('phpinfo')
167675Szelenkov@nginx.com
168675Szelenkov@nginx.com        resp = self.get()
169675Szelenkov@nginx.com
1701596Szelenkov@nginx.com        assert resp['status'] == 200, 'status'
1711596Szelenkov@nginx.com        assert resp['body'] != '', 'body not empty'
172675Szelenkov@nginx.com
1731090Svbart@nginx.com    def test_php_application_header_status(self):
1741090Svbart@nginx.com        self.load('header')
1751090Svbart@nginx.com
1761596Szelenkov@nginx.com        assert (
1771090Svbart@nginx.com            self.get(
1781090Svbart@nginx.com                headers={
1791090Svbart@nginx.com                    'Host': 'localhost',
1801090Svbart@nginx.com                    'Connection': 'close',
1811090Svbart@nginx.com                    'X-Header': 'HTTP/1.1 404 Not Found',
1821090Svbart@nginx.com                }
1831596Szelenkov@nginx.com            )['status']
1841596Szelenkov@nginx.com            == 404
1851596Szelenkov@nginx.com        ), 'status'
1861090Svbart@nginx.com
1871596Szelenkov@nginx.com        assert (
1881090Svbart@nginx.com            self.get(
1891090Svbart@nginx.com                headers={
1901090Svbart@nginx.com                    'Host': 'localhost',
1911090Svbart@nginx.com                    'Connection': 'close',
1921090Svbart@nginx.com                    'X-Header': 'http/1.1 404 Not Found',
1931090Svbart@nginx.com                }
1941596Szelenkov@nginx.com            )['status']
1951596Szelenkov@nginx.com            == 404
1961596Szelenkov@nginx.com        ), 'status case insensitive'
1971090Svbart@nginx.com
1981596Szelenkov@nginx.com        assert (
1991090Svbart@nginx.com            self.get(
2001090Svbart@nginx.com                headers={
2011090Svbart@nginx.com                    'Host': 'localhost',
2021090Svbart@nginx.com                    'Connection': 'close',
2031090Svbart@nginx.com                    'X-Header': 'HTTP/ 404 Not Found',
2041090Svbart@nginx.com                }
2051596Szelenkov@nginx.com            )['status']
2061596Szelenkov@nginx.com            == 404
2071596Szelenkov@nginx.com        ), 'status version empty'
2081090Svbart@nginx.com
209675Szelenkov@nginx.com    def test_php_application_404(self):
210675Szelenkov@nginx.com        self.load('404')
211675Szelenkov@nginx.com
212675Szelenkov@nginx.com        resp = self.get()
213675Szelenkov@nginx.com
2141596Szelenkov@nginx.com        assert resp['status'] == 404, '404 status'
2151596Szelenkov@nginx.com        assert re.search(
2161596Szelenkov@nginx.com            r'<title>404 Not Found</title>', resp['body']
2171596Szelenkov@nginx.com        ), '404 body'
218675Szelenkov@nginx.com
219675Szelenkov@nginx.com    def test_php_application_keepalive_body(self):
220675Szelenkov@nginx.com        self.load('mirror')
221675Szelenkov@nginx.com
2221596Szelenkov@nginx.com        assert self.get()['status'] == 200, 'init'
2231029Szelenkov@nginx.com
2241453Szelenkov@nginx.com        body = '0123456789' * 500
2251017Szelenkov@nginx.com        (resp, sock) = self.post(
2261017Szelenkov@nginx.com            headers={
2271017Szelenkov@nginx.com                'Host': 'localhost',
2281017Szelenkov@nginx.com                'Connection': 'keep-alive',
2291017Szelenkov@nginx.com                'Content-Type': 'text/html',
2301017Szelenkov@nginx.com            },
2311017Szelenkov@nginx.com            start=True,
2321453Szelenkov@nginx.com            body=body,
2331029Szelenkov@nginx.com            read_timeout=1,
2341017Szelenkov@nginx.com        )
235675Szelenkov@nginx.com
2361596Szelenkov@nginx.com        assert resp['body'] == body, 'keep-alive 1'
237675Szelenkov@nginx.com
2381453Szelenkov@nginx.com        body = '0123456789'
2391017Szelenkov@nginx.com        resp = self.post(
2401017Szelenkov@nginx.com            headers={
2411017Szelenkov@nginx.com                'Host': 'localhost',
2421017Szelenkov@nginx.com                'Connection': 'close',
2431017Szelenkov@nginx.com                'Content-Type': 'text/html',
2441017Szelenkov@nginx.com            },
2451017Szelenkov@nginx.com            sock=sock,
2461453Szelenkov@nginx.com            body=body,
2471017Szelenkov@nginx.com        )
248675Szelenkov@nginx.com
2491596Szelenkov@nginx.com        assert resp['body'] == body, 'keep-alive 2'
250675Szelenkov@nginx.com
251675Szelenkov@nginx.com    def test_php_application_conditional(self):
252675Szelenkov@nginx.com        self.load('conditional')
253675Szelenkov@nginx.com
2541596Szelenkov@nginx.com        assert re.search(r'True', self.get()['body']), 'conditional true'
2551596Szelenkov@nginx.com        assert re.search(r'False', self.post()['body']), 'conditional false'
256675Szelenkov@nginx.com
257675Szelenkov@nginx.com    def test_php_application_get_variables(self):
258675Szelenkov@nginx.com        self.load('get_variables')
259675Szelenkov@nginx.com
260675Szelenkov@nginx.com        resp = self.get(url='/?var1=val1&var2=&var3')
2611596Szelenkov@nginx.com        assert resp['headers']['X-Var-1'] == 'val1', 'GET variables'
2621636Svbart@nginx.com        assert resp['headers']['X-Var-2'] == '', 'GET variables 2'
2631636Svbart@nginx.com        assert resp['headers']['X-Var-3'] == '', 'GET variables 3'
2641636Svbart@nginx.com        assert resp['headers']['X-Var-4'] == 'not set', 'GET variables 4'
265675Szelenkov@nginx.com
266675Szelenkov@nginx.com    def test_php_application_post_variables(self):
267675Szelenkov@nginx.com        self.load('post_variables')
268675Szelenkov@nginx.com
2691017Szelenkov@nginx.com        resp = self.post(
2701017Szelenkov@nginx.com            headers={
2711017Szelenkov@nginx.com                'Content-Type': 'application/x-www-form-urlencoded',
2721017Szelenkov@nginx.com                'Host': 'localhost',
2731017Szelenkov@nginx.com                'Connection': 'close',
2741017Szelenkov@nginx.com            },
2751017Szelenkov@nginx.com            body='var1=val1&var2=',
2761017Szelenkov@nginx.com        )
2771596Szelenkov@nginx.com        assert resp['headers']['X-Var-1'] == 'val1', 'POST variables'
2781636Svbart@nginx.com        assert resp['headers']['X-Var-2'] == '', 'POST variables 2'
2791636Svbart@nginx.com        assert resp['headers']['X-Var-3'] == 'not set', 'POST variables 3'
280675Szelenkov@nginx.com
281675Szelenkov@nginx.com    def test_php_application_cookies(self):
282675Szelenkov@nginx.com        self.load('cookies')
283675Szelenkov@nginx.com
2841017Szelenkov@nginx.com        resp = self.get(
2851017Szelenkov@nginx.com            headers={
2861017Szelenkov@nginx.com                'Cookie': 'var=val; var2=val2',
2871017Szelenkov@nginx.com                'Host': 'localhost',
2881017Szelenkov@nginx.com                'Connection': 'close',
2891017Szelenkov@nginx.com            }
2901017Szelenkov@nginx.com        )
291675Szelenkov@nginx.com
2921596Szelenkov@nginx.com        assert resp['headers']['X-Cookie-1'] == 'val', 'cookie'
2931596Szelenkov@nginx.com        assert resp['headers']['X-Cookie-2'] == 'val2', 'cookie'
294675Szelenkov@nginx.com
295692Szelenkov@nginx.com    def test_php_application_ini_precision(self):
296692Szelenkov@nginx.com        self.load('ini_precision')
297692Szelenkov@nginx.com
2981596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] != '4', 'ini value default'
2991017Szelenkov@nginx.com
3001775Szelenkov@nginx.com        assert 'success' in self.conf(
3011017Szelenkov@nginx.com            {"file": "ini/php.ini"}, 'applications/ini_precision/options'
3021017Szelenkov@nginx.com        )
303692Szelenkov@nginx.com
3041596Szelenkov@nginx.com        assert (
3051596Szelenkov@nginx.com            self.get()['headers']['X-File']
3061596Szelenkov@nginx.com            == option.test_dir + '/php/ini_precision/ini/php.ini'
3071596Szelenkov@nginx.com        ), 'ini file'
3081596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] == '4', 'ini value'
309692Szelenkov@nginx.com
3101596Szelenkov@nginx.com    @pytest.mark.skip('not yet')
311721Szelenkov@nginx.com    def test_php_application_ini_admin_user(self):
312721Szelenkov@nginx.com        self.load('ini_precision')
313721Szelenkov@nginx.com
3141596Szelenkov@nginx.com        assert 'error' in self.conf(
3151596Szelenkov@nginx.com            {"user": {"precision": "4"}, "admin": {"precision": "5"}},
3161596Szelenkov@nginx.com            'applications/ini_precision/options',
3171596Szelenkov@nginx.com        ), 'ini admin user'
318721Szelenkov@nginx.com
319721Szelenkov@nginx.com    def test_php_application_ini_admin(self):
320721Szelenkov@nginx.com        self.load('ini_precision')
321721Szelenkov@nginx.com
3221775Szelenkov@nginx.com        assert 'success' in self.conf(
3232053Szelenkov@nginx.com            {"file": "ini/php.ini", "admin": {"precision": "5"}},
3241017Szelenkov@nginx.com            'applications/ini_precision/options',
3251017Szelenkov@nginx.com        )
326721Szelenkov@nginx.com
3272053Szelenkov@nginx.com        assert (
3282053Szelenkov@nginx.com            self.get()['headers']['X-File']
3292053Szelenkov@nginx.com            == option.test_dir + '/php/ini_precision/ini/php.ini'
3302053Szelenkov@nginx.com        ), 'ini file'
3311596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] == '5', 'ini value admin'
332721Szelenkov@nginx.com
333721Szelenkov@nginx.com    def test_php_application_ini_user(self):
334721Szelenkov@nginx.com        self.load('ini_precision')
335721Szelenkov@nginx.com
3361775Szelenkov@nginx.com        assert 'success' in self.conf(
3372053Szelenkov@nginx.com            {"file": "ini/php.ini", "user": {"precision": "5"}},
3381017Szelenkov@nginx.com            'applications/ini_precision/options',
3391017Szelenkov@nginx.com        )
340721Szelenkov@nginx.com
3412053Szelenkov@nginx.com        assert (
3422053Szelenkov@nginx.com            self.get()['headers']['X-File']
3432053Szelenkov@nginx.com            == option.test_dir + '/php/ini_precision/ini/php.ini'
3442053Szelenkov@nginx.com        ), 'ini file'
3451596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] == '5', 'ini value user'
346721Szelenkov@nginx.com
347721Szelenkov@nginx.com    def test_php_application_ini_user_2(self):
348721Szelenkov@nginx.com        self.load('ini_precision')
349721Szelenkov@nginx.com
3501775Szelenkov@nginx.com        assert 'success' in self.conf(
3511017Szelenkov@nginx.com            {"file": "ini/php.ini"}, 'applications/ini_precision/options'
3521017Szelenkov@nginx.com        )
353721Szelenkov@nginx.com
3541596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] == '4', 'ini user file'
355721Szelenkov@nginx.com
3561775Szelenkov@nginx.com        assert 'success' in self.conf(
3571017Szelenkov@nginx.com            {"precision": "5"}, 'applications/ini_precision/options/user'
3581017Szelenkov@nginx.com        )
359721Szelenkov@nginx.com
3601596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] == '5', 'ini value user'
361721Szelenkov@nginx.com
362721Szelenkov@nginx.com    def test_php_application_ini_set_admin(self):
363721Szelenkov@nginx.com        self.load('ini_precision')
364721Szelenkov@nginx.com
3651775Szelenkov@nginx.com        assert 'success' in self.conf(
3661017Szelenkov@nginx.com            {"admin": {"precision": "5"}}, 'applications/ini_precision/options'
3671017Szelenkov@nginx.com        )
368721Szelenkov@nginx.com
3691596Szelenkov@nginx.com        assert (
3701596Szelenkov@nginx.com            self.get(url='/?precision=6')['headers']['X-Precision'] == '5'
3711596Szelenkov@nginx.com        ), 'ini set admin'
372721Szelenkov@nginx.com
373721Szelenkov@nginx.com    def test_php_application_ini_set_user(self):
374721Szelenkov@nginx.com        self.load('ini_precision')
375721Szelenkov@nginx.com
3761775Szelenkov@nginx.com        assert 'success' in self.conf(
3771017Szelenkov@nginx.com            {"user": {"precision": "5"}}, 'applications/ini_precision/options'
3781017Szelenkov@nginx.com        )
379721Szelenkov@nginx.com
3801596Szelenkov@nginx.com        assert (
3811596Szelenkov@nginx.com            self.get(url='/?precision=6')['headers']['X-Precision'] == '6'
3821596Szelenkov@nginx.com        ), 'ini set user'
383721Szelenkov@nginx.com
384721Szelenkov@nginx.com    def test_php_application_ini_repeat(self):
385721Szelenkov@nginx.com        self.load('ini_precision')
386721Szelenkov@nginx.com
3871775Szelenkov@nginx.com        assert 'success' in self.conf(
3881017Szelenkov@nginx.com            {"user": {"precision": "5"}}, 'applications/ini_precision/options'
3891017Szelenkov@nginx.com        )
390721Szelenkov@nginx.com
3911596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] == '5', 'ini value'
392721Szelenkov@nginx.com
3931596Szelenkov@nginx.com        assert self.get()['headers']['X-Precision'] == '5', 'ini value repeat'
394721Szelenkov@nginx.com
395865Szelenkov@nginx.com    def test_php_application_disable_functions_exec(self):
396982Szelenkov@nginx.com        self.load('time_exec')
397982Szelenkov@nginx.com
398982Szelenkov@nginx.com        self.before_disable_functions()
399865Szelenkov@nginx.com
4001775Szelenkov@nginx.com        assert 'success' in self.conf(
4011017Szelenkov@nginx.com            {"admin": {"disable_functions": "exec"}},
4021017Szelenkov@nginx.com            'applications/time_exec/options',
4031017Szelenkov@nginx.com        )
404865Szelenkov@nginx.com
405982Szelenkov@nginx.com        body = self.get()['body']
406865Szelenkov@nginx.com
4071596Szelenkov@nginx.com        assert re.search(r'time: \d+', body), 'disable_functions time'
4081596Szelenkov@nginx.com        assert not re.search(r'exec: \/\w+', body), 'disable_functions exec'
409865Szelenkov@nginx.com
410865Szelenkov@nginx.com    def test_php_application_disable_functions_comma(self):
411982Szelenkov@nginx.com        self.load('time_exec')
412865Szelenkov@nginx.com
413982Szelenkov@nginx.com        self.before_disable_functions()
414865Szelenkov@nginx.com
4151775Szelenkov@nginx.com        assert 'success' in self.conf(
4161017Szelenkov@nginx.com            {"admin": {"disable_functions": "exec,time"}},
4171017Szelenkov@nginx.com            'applications/time_exec/options',
4181017Szelenkov@nginx.com        )
419865Szelenkov@nginx.com
420982Szelenkov@nginx.com        body = self.get()['body']
421982Szelenkov@nginx.com
422*2073Szelenkov@nginx.com        assert not re.search(r'time: \d+', body), 'disable_functions comma time'
4231596Szelenkov@nginx.com        assert not re.search(
4241596Szelenkov@nginx.com            r'exec: \/\w+', body
4251596Szelenkov@nginx.com        ), 'disable_functions comma exec'
426865Szelenkov@nginx.com
4271742Szelenkov@nginx.com    def test_php_application_auth(self):
4281742Szelenkov@nginx.com        self.load('auth')
4291742Szelenkov@nginx.com
4301742Szelenkov@nginx.com        resp = self.get()
4311742Szelenkov@nginx.com        assert resp['status'] == 200, 'status'
4321742Szelenkov@nginx.com        assert resp['headers']['X-Digest'] == 'not set', 'digest'
4331742Szelenkov@nginx.com        assert resp['headers']['X-User'] == 'not set', 'user'
4341742Szelenkov@nginx.com        assert resp['headers']['X-Password'] == 'not set', 'password'
4351742Szelenkov@nginx.com
4361742Szelenkov@nginx.com        resp = self.get(
4371742Szelenkov@nginx.com            headers={
4381742Szelenkov@nginx.com                'Host': 'localhost',
4391742Szelenkov@nginx.com                'Authorization': 'Basic dXNlcjpwYXNzd29yZA==',
4401742Szelenkov@nginx.com                'Connection': 'close',
4411742Szelenkov@nginx.com            }
4421742Szelenkov@nginx.com        )
4431742Szelenkov@nginx.com        assert resp['status'] == 200, 'basic status'
4441742Szelenkov@nginx.com        assert resp['headers']['X-Digest'] == 'not set', 'basic digest'
4451742Szelenkov@nginx.com        assert resp['headers']['X-User'] == 'user', 'basic user'
4461742Szelenkov@nginx.com        assert resp['headers']['X-Password'] == 'password', 'basic password'
4471742Szelenkov@nginx.com
4481742Szelenkov@nginx.com        resp = self.get(
4491742Szelenkov@nginx.com            headers={
4501742Szelenkov@nginx.com                'Host': 'localhost',
4511742Szelenkov@nginx.com                'Authorization': 'Digest username="blah", realm="", uri="/"',
4521742Szelenkov@nginx.com                'Connection': 'close',
4531742Szelenkov@nginx.com            }
4541742Szelenkov@nginx.com        )
4551742Szelenkov@nginx.com        assert resp['status'] == 200, 'digest status'
4561742Szelenkov@nginx.com        assert (
4571742Szelenkov@nginx.com            resp['headers']['X-Digest'] == 'username="blah", realm="", uri="/"'
4581742Szelenkov@nginx.com        ), 'digest digest'
4591742Szelenkov@nginx.com        assert resp['headers']['X-User'] == 'not set', 'digest user'
4601742Szelenkov@nginx.com        assert resp['headers']['X-Password'] == 'not set', 'digest password'
4611742Szelenkov@nginx.com
4621742Szelenkov@nginx.com    def test_php_application_auth_invalid(self):
4631742Szelenkov@nginx.com        self.load('auth')
4641742Szelenkov@nginx.com
4651742Szelenkov@nginx.com        def check_auth(auth):
4661848Szelenkov@nginx.com            resp = self.get(
4671848Szelenkov@nginx.com                headers={
4681848Szelenkov@nginx.com                    'Host': 'localhost',
4691848Szelenkov@nginx.com                    'Authorization': auth,
4701848Szelenkov@nginx.com                    'Connection': 'close',
4711848Szelenkov@nginx.com                }
4721848Szelenkov@nginx.com            )
4731742Szelenkov@nginx.com
4741742Szelenkov@nginx.com            assert resp['status'] == 200, 'status'
4751742Szelenkov@nginx.com            assert resp['headers']['X-Digest'] == 'not set', 'Digest'
4761742Szelenkov@nginx.com            assert resp['headers']['X-User'] == 'not set', 'User'
4771742Szelenkov@nginx.com            assert resp['headers']['X-Password'] == 'not set', 'Password'
4781742Szelenkov@nginx.com
4791742Szelenkov@nginx.com        check_auth('Basic dXN%cjpwYXNzd29yZA==')
4801742Szelenkov@nginx.com        check_auth('Basic XNlcjpwYXNzd29yZA==')
4811742Szelenkov@nginx.com        check_auth('Basic DdXNlcjpwYXNzd29yZA==')
4821742Szelenkov@nginx.com        check_auth('Basic blah')
4831742Szelenkov@nginx.com        check_auth('Basic')
4841742Szelenkov@nginx.com        check_auth('Digest')
4851742Szelenkov@nginx.com        check_auth('blah')
4861742Szelenkov@nginx.com
487865Szelenkov@nginx.com    def test_php_application_disable_functions_space(self):
488982Szelenkov@nginx.com        self.load('time_exec')
489865Szelenkov@nginx.com
490982Szelenkov@nginx.com        self.before_disable_functions()
491865Szelenkov@nginx.com
4921775Szelenkov@nginx.com        assert 'success' in self.conf(
4931017Szelenkov@nginx.com            {"admin": {"disable_functions": "exec time"}},
4941017Szelenkov@nginx.com            'applications/time_exec/options',
4951017Szelenkov@nginx.com        )
496865Szelenkov@nginx.com
497982Szelenkov@nginx.com        body = self.get()['body']
498982Szelenkov@nginx.com
499*2073Szelenkov@nginx.com        assert not re.search(r'time: \d+', body), 'disable_functions space time'
5001596Szelenkov@nginx.com        assert not re.search(
5011596Szelenkov@nginx.com            r'exec: \/\w+', body
5021596Szelenkov@nginx.com        ), 'disable_functions space exec'
503865Szelenkov@nginx.com
504865Szelenkov@nginx.com    def test_php_application_disable_functions_user(self):
505982Szelenkov@nginx.com        self.load('time_exec')
506982Szelenkov@nginx.com
507982Szelenkov@nginx.com        self.before_disable_functions()
508865Szelenkov@nginx.com
5091775Szelenkov@nginx.com        assert 'success' in self.conf(
5101017Szelenkov@nginx.com            {"user": {"disable_functions": "exec"}},
5111017Szelenkov@nginx.com            'applications/time_exec/options',
5121017Szelenkov@nginx.com        )
513865Szelenkov@nginx.com
514982Szelenkov@nginx.com        body = self.get()['body']
515982Szelenkov@nginx.com
5161596Szelenkov@nginx.com        assert re.search(r'time: \d+', body), 'disable_functions user time'
5171596Szelenkov@nginx.com        assert not re.search(
5181596Szelenkov@nginx.com            r'exec: \/\w+', body
5191596Szelenkov@nginx.com        ), 'disable_functions user exec'
520865Szelenkov@nginx.com
521865Szelenkov@nginx.com    def test_php_application_disable_functions_nonexistent(self):
522982Szelenkov@nginx.com        self.load('time_exec')
523982Szelenkov@nginx.com
524982Szelenkov@nginx.com        self.before_disable_functions()
525865Szelenkov@nginx.com
5261775Szelenkov@nginx.com        assert 'success' in self.conf(
5271017Szelenkov@nginx.com            {"admin": {"disable_functions": "blah"}},
5281017Szelenkov@nginx.com            'applications/time_exec/options',
5291017Szelenkov@nginx.com        )
530865Szelenkov@nginx.com
531982Szelenkov@nginx.com        body = self.get()['body']
532865Szelenkov@nginx.com
5331596Szelenkov@nginx.com        assert re.search(
5341596Szelenkov@nginx.com            r'time: \d+', body
5351596Szelenkov@nginx.com        ), 'disable_functions nonexistent time'
5361596Szelenkov@nginx.com        assert re.search(
5371596Szelenkov@nginx.com            r'exec: \/\w+', body
5381596Szelenkov@nginx.com        ), 'disable_functions nonexistent exec'
539865Szelenkov@nginx.com
540865Szelenkov@nginx.com    def test_php_application_disable_classes(self):
541865Szelenkov@nginx.com        self.load('date_time')
542865Szelenkov@nginx.com
5431596Szelenkov@nginx.com        assert re.search(
5441596Szelenkov@nginx.com            r'012345', self.get()['body']
5451596Szelenkov@nginx.com        ), 'disable_classes before'
546865Szelenkov@nginx.com
5471775Szelenkov@nginx.com        assert 'success' in self.conf(
5481017Szelenkov@nginx.com            {"admin": {"disable_classes": "DateTime"}},
5491017Szelenkov@nginx.com            'applications/date_time/options',
5501017Szelenkov@nginx.com        )
551865Szelenkov@nginx.com
5521596Szelenkov@nginx.com        assert not re.search(
5531596Szelenkov@nginx.com            r'012345', self.get()['body']
5541596Szelenkov@nginx.com        ), 'disable_classes before'
555865Szelenkov@nginx.com
556865Szelenkov@nginx.com    def test_php_application_disable_classes_user(self):
557865Szelenkov@nginx.com        self.load('date_time')
558865Szelenkov@nginx.com
5591596Szelenkov@nginx.com        assert re.search(
5601596Szelenkov@nginx.com            r'012345', self.get()['body']
5611596Szelenkov@nginx.com        ), 'disable_classes before'
562982Szelenkov@nginx.com
5631775Szelenkov@nginx.com        assert 'success' in self.conf(
5641017Szelenkov@nginx.com            {"user": {"disable_classes": "DateTime"}},
5651017Szelenkov@nginx.com            'applications/date_time/options',
5661017Szelenkov@nginx.com        )
567865Szelenkov@nginx.com
5681596Szelenkov@nginx.com        assert not re.search(
5691596Szelenkov@nginx.com            r'012345', self.get()['body']
5701596Szelenkov@nginx.com        ), 'disable_classes before'
5711017Szelenkov@nginx.com
5721850Smax.romanov@nginx.com    def test_php_application_error_log(self):
5731529Szelenkov@nginx.com        self.load('error_log')
5741529Szelenkov@nginx.com
5751596Szelenkov@nginx.com        assert self.get()['status'] == 200, 'status'
5761529Szelenkov@nginx.com
5771529Szelenkov@nginx.com        time.sleep(1)
5781529Szelenkov@nginx.com
5791596Szelenkov@nginx.com        assert self.get()['status'] == 200, 'status 2'
5801529Szelenkov@nginx.com
5811529Szelenkov@nginx.com        pattern = r'\d{4}\/\d\d\/\d\d\s\d\d:.+\[notice\].+Error in application'
5821529Szelenkov@nginx.com
5831596Szelenkov@nginx.com        assert self.wait_for_record(pattern) is not None, 'errors print'
5841529Szelenkov@nginx.com
5851850Smax.romanov@nginx.com        errs = self.findall(pattern)
5861850Smax.romanov@nginx.com
5871850Smax.romanov@nginx.com        assert len(errs) == 2, 'error_log count'
5881529Szelenkov@nginx.com
5891850Smax.romanov@nginx.com        date = errs[0].split('[')[0]
5901850Smax.romanov@nginx.com        date2 = errs[1].split('[')[0]
5911850Smax.romanov@nginx.com        assert date != date2, 'date diff'
5921529Szelenkov@nginx.com
5931105Szelenkov@nginx.com    def test_php_application_script(self):
5941596Szelenkov@nginx.com        assert 'success' in self.conf(
5951596Szelenkov@nginx.com            {
5961596Szelenkov@nginx.com                "listeners": {"*:7080": {"pass": "applications/script"}},
5971596Szelenkov@nginx.com                "applications": {
5981596Szelenkov@nginx.com                    "script": {
5992055Szelenkov@nginx.com                        "type": self.get_application_type(),
6001596Szelenkov@nginx.com                        "processes": {"spare": 0},
6011596Szelenkov@nginx.com                        "root": option.test_dir + "/php/script",
6021596Szelenkov@nginx.com                        "script": "phpinfo.php",
6031596Szelenkov@nginx.com                    }
6041596Szelenkov@nginx.com                },
6051596Szelenkov@nginx.com            }
6061596Szelenkov@nginx.com        ), 'configure script'
6071105Szelenkov@nginx.com
6081105Szelenkov@nginx.com        resp = self.get()
6091105Szelenkov@nginx.com
6101596Szelenkov@nginx.com        assert resp['status'] == 200, 'status'
6111596Szelenkov@nginx.com        assert resp['body'] != '', 'body not empty'
6121105Szelenkov@nginx.com
6131105Szelenkov@nginx.com    def test_php_application_index_default(self):
6141596Szelenkov@nginx.com        assert 'success' in self.conf(
6151596Szelenkov@nginx.com            {
6161596Szelenkov@nginx.com                "listeners": {"*:7080": {"pass": "applications/phpinfo"}},
6171596Szelenkov@nginx.com                "applications": {
6181596Szelenkov@nginx.com                    "phpinfo": {
6192055Szelenkov@nginx.com                        "type": self.get_application_type(),
6201596Szelenkov@nginx.com                        "processes": {"spare": 0},
6211596Szelenkov@nginx.com                        "root": option.test_dir + "/php/phpinfo",
6221596Szelenkov@nginx.com                    }
6231596Szelenkov@nginx.com                },
6241596Szelenkov@nginx.com            }
6251596Szelenkov@nginx.com        ), 'configure index default'
6261105Szelenkov@nginx.com
6271346St.nateldemoura@f5.com        resp = self.get()
6281346St.nateldemoura@f5.com
6291596Szelenkov@nginx.com        assert resp['status'] == 200, 'status'
6301596Szelenkov@nginx.com        assert resp['body'] != '', 'body not empty'
6311346St.nateldemoura@f5.com
6321654Szelenkov@nginx.com    def test_php_application_extension_check(self, temp_dir):
6331346St.nateldemoura@f5.com        self.load('phpinfo')
6341346St.nateldemoura@f5.com
6351596Szelenkov@nginx.com        assert self.get(url='/index.wrong')['status'] != 200, 'status'
6361596Szelenkov@nginx.com
6371654Szelenkov@nginx.com        new_root = temp_dir + "/php"
6381596Szelenkov@nginx.com        os.mkdir(new_root)
6391596Szelenkov@nginx.com        shutil.copy(option.test_dir + '/php/phpinfo/index.wrong', new_root)
6401596Szelenkov@nginx.com
6411596Szelenkov@nginx.com        assert 'success' in self.conf(
6421596Szelenkov@nginx.com            {
6431596Szelenkov@nginx.com                "listeners": {"*:7080": {"pass": "applications/phpinfo"}},
6441596Szelenkov@nginx.com                "applications": {
6451596Szelenkov@nginx.com                    "phpinfo": {
6462055Szelenkov@nginx.com                        "type": self.get_application_type(),
6471596Szelenkov@nginx.com                        "processes": {"spare": 0},
6481596Szelenkov@nginx.com                        "root": new_root,
6491596Szelenkov@nginx.com                        "working_directory": new_root,
6501596Szelenkov@nginx.com                    }
6511596Szelenkov@nginx.com                },
6521596Szelenkov@nginx.com            }
6531596Szelenkov@nginx.com        ), 'configure new root'
6541596Szelenkov@nginx.com
6551596Szelenkov@nginx.com        resp = self.get()
6561596Szelenkov@nginx.com        assert str(resp['status']) + resp['body'] != '200', 'status new root'
6571596Szelenkov@nginx.com
6581596Szelenkov@nginx.com    def run_php_application_cwd_root_tests(self):
6591596Szelenkov@nginx.com        assert 'success' in self.conf_delete(
6601596Szelenkov@nginx.com            'applications/cwd/working_directory'
6611346St.nateldemoura@f5.com        )
662865Szelenkov@nginx.com
6631596Szelenkov@nginx.com        script_cwd = option.test_dir + '/php/cwd'
6641367Szelenkov@nginx.com
6651596Szelenkov@nginx.com        resp = self.get()
6661596Szelenkov@nginx.com        assert resp['status'] == 200, 'status ok'
6671596Szelenkov@nginx.com        assert resp['body'] == script_cwd, 'default cwd'
6681596Szelenkov@nginx.com
6691596Szelenkov@nginx.com        assert 'success' in self.conf(
670*2073Szelenkov@nginx.com            '"' + option.test_dir + '"',
671*2073Szelenkov@nginx.com            'applications/cwd/working_directory',
6721367Szelenkov@nginx.com        )
6731367Szelenkov@nginx.com
6741367Szelenkov@nginx.com        resp = self.get()
6751596Szelenkov@nginx.com        assert resp['status'] == 200, 'status ok'
6761596Szelenkov@nginx.com        assert resp['body'] == script_cwd, 'wdir cwd'
6771381St.nateldemoura@f5.com
6781381St.nateldemoura@f5.com        resp = self.get(url='/?chdir=/')
6791596Szelenkov@nginx.com        assert resp['status'] == 200, 'status ok'
6801596Szelenkov@nginx.com        assert resp['body'] == '/', 'cwd after chdir'
6811381St.nateldemoura@f5.com
6821381St.nateldemoura@f5.com        # cwd must be restored
6831381St.nateldemoura@f5.com
6841381St.nateldemoura@f5.com        resp = self.get()
6851596Szelenkov@nginx.com        assert resp['status'] == 200, 'status ok'
6861596Szelenkov@nginx.com        assert resp['body'] == script_cwd, 'cwd restored'
6871381St.nateldemoura@f5.com
6881381St.nateldemoura@f5.com        resp = self.get(url='/subdir/')
6891596Szelenkov@nginx.com        assert resp['body'] == script_cwd + '/subdir', 'cwd subdir'
6901381St.nateldemoura@f5.com
6911381St.nateldemoura@f5.com    def test_php_application_cwd_root(self):
6921381St.nateldemoura@f5.com        self.load('cwd')
6931381St.nateldemoura@f5.com        self.run_php_application_cwd_root_tests()
6941381St.nateldemoura@f5.com
6951381St.nateldemoura@f5.com    def test_php_application_cwd_opcache_disabled(self):
6961381St.nateldemoura@f5.com        self.load('cwd')
6971381St.nateldemoura@f5.com        self.set_opcache('cwd', '0')
6981381St.nateldemoura@f5.com        self.run_php_application_cwd_root_tests()
6991381St.nateldemoura@f5.com
7001381St.nateldemoura@f5.com    def test_php_application_cwd_opcache_enabled(self):
7011381St.nateldemoura@f5.com        self.load('cwd')
7021381St.nateldemoura@f5.com        self.set_opcache('cwd', '1')
7031381St.nateldemoura@f5.com        self.run_php_application_cwd_root_tests()
7041381St.nateldemoura@f5.com
7051381St.nateldemoura@f5.com    def run_php_application_cwd_script_tests(self):
7061381St.nateldemoura@f5.com        self.load('cwd')
7071381St.nateldemoura@f5.com
7081596Szelenkov@nginx.com        script_cwd = option.test_dir + '/php/cwd'
7091381St.nateldemoura@f5.com
7101596Szelenkov@nginx.com        assert 'success' in self.conf_delete(
7111596Szelenkov@nginx.com            'applications/cwd/working_directory'
7121381St.nateldemoura@f5.com        )
7131381St.nateldemoura@f5.com
7141596Szelenkov@nginx.com        assert 'success' in self.conf('"index.php"', 'applications/cwd/script')
7151381St.nateldemoura@f5.com
7161596Szelenkov@nginx.com        assert self.get()['body'] == script_cwd, 'default cwd'
7171596Szelenkov@nginx.com
7181596Szelenkov@nginx.com        assert self.get(url='/?chdir=/')['body'] == '/', 'cwd after chdir'
7191381St.nateldemoura@f5.com
7201381St.nateldemoura@f5.com        # cwd must be restored
7211596Szelenkov@nginx.com        assert self.get()['body'] == script_cwd, 'cwd restored'
7221381St.nateldemoura@f5.com
7231381St.nateldemoura@f5.com    def test_php_application_cwd_script(self):
7241381St.nateldemoura@f5.com        self.load('cwd')
7251381St.nateldemoura@f5.com        self.run_php_application_cwd_script_tests()
7261381St.nateldemoura@f5.com
7271381St.nateldemoura@f5.com    def test_php_application_cwd_script_opcache_disabled(self):
7281381St.nateldemoura@f5.com        self.load('cwd')
7291381St.nateldemoura@f5.com        self.set_opcache('cwd', '0')
7301381St.nateldemoura@f5.com        self.run_php_application_cwd_script_tests()
7311381St.nateldemoura@f5.com
7321381St.nateldemoura@f5.com    def test_php_application_cwd_script_opcache_enabled(self):
7331381St.nateldemoura@f5.com        self.load('cwd')
7341381St.nateldemoura@f5.com        self.set_opcache('cwd', '1')
7351381St.nateldemoura@f5.com        self.run_php_application_cwd_script_tests()
7361381St.nateldemoura@f5.com
7371381St.nateldemoura@f5.com    def test_php_application_path_relative(self):
7381381St.nateldemoura@f5.com        self.load('open')
7391381St.nateldemoura@f5.com
7401596Szelenkov@nginx.com        assert self.get()['body'] == 'test', 'relative path'
7411381St.nateldemoura@f5.com
7421596Szelenkov@nginx.com        assert (
7431596Szelenkov@nginx.com            self.get(url='/?chdir=/')['body'] != 'test'
7441596Szelenkov@nginx.com        ), 'relative path w/ chdir'
7451367Szelenkov@nginx.com
7461596Szelenkov@nginx.com        assert self.get()['body'] == 'test', 'relative path 2'
7472000Smax.romanov@nginx.com
7482000Smax.romanov@nginx.com    def test_php_application_shared_opcache(self):
7492000Smax.romanov@nginx.com        self.load('opcache', limits={'requests': 1})
7502000Smax.romanov@nginx.com
7512054Szelenkov@nginx.com        r = self.check_opcache()
7522000Smax.romanov@nginx.com        pid = r['headers']['X-Pid']
7532054Szelenkov@nginx.com        assert r['headers']['X-Cached'] == '0', 'not cached'
7542000Smax.romanov@nginx.com
7552000Smax.romanov@nginx.com        r = self.get()
7562000Smax.romanov@nginx.com
7572000Smax.romanov@nginx.com        assert r['headers']['X-Pid'] != pid, 'new instance'
7582000Smax.romanov@nginx.com        assert r['headers']['X-Cached'] == '1', 'cached'
7592054Szelenkov@nginx.com
7602054Szelenkov@nginx.com    def test_php_application_opcache_preload_chdir(self, temp_dir):
7612054Szelenkov@nginx.com        self.load('opcache')
7622054Szelenkov@nginx.com
7632054Szelenkov@nginx.com        self.check_opcache()
7642054Szelenkov@nginx.com
7652054Szelenkov@nginx.com        self.set_preload('chdir.php')
7662054Szelenkov@nginx.com
7672054Szelenkov@nginx.com        assert self.get()['headers']['X-Cached'] == '0', 'not cached'
7682054Szelenkov@nginx.com        assert self.get()['headers']['X-Cached'] == '1', 'cached'
7692054Szelenkov@nginx.com
7702054Szelenkov@nginx.com    def test_php_application_opcache_preload_ffr(self, temp_dir):
7712054Szelenkov@nginx.com        self.load('opcache')
7722054Szelenkov@nginx.com
7732054Szelenkov@nginx.com        self.check_opcache()
7742054Szelenkov@nginx.com
7752054Szelenkov@nginx.com        self.set_preload('fastcgi_finish_request.php')
7762054Szelenkov@nginx.com
7772054Szelenkov@nginx.com        assert self.get()['headers']['X-Cached'] == '0', 'not cached'
7782054Szelenkov@nginx.com        assert self.get()['headers']['X-Cached'] == '1', 'cached'
779