tempesta-tech / tempesta-test

Test suite for Tempesta FW
10 stars 4 forks source link

disable request parsing for deproxy and h2 deproxy clients #322

Closed RomanBelozerov closed 1 year ago

RomanBelozerov commented 1 year ago

Added new parsing variable for deproxy/deproxy-h2 clients. Parsing is enabled by default. And also removed H2Request class because we use h2 library with integrated request parsing.

Usage example:

deproxy

# for client {'id': 'deproxy', 'type': 'deproxy', 'addr': "${tempesta_ip}", 'port': '80'}
>>> client = self.get_client('deproxy')
>>> client.start()
>>> client.make_request('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-Length: invalid\r\n\r\n')
>>> client.wait_for_response()

We will receive - ValueError: invalid literal for int() with base 10: 'invalid'. But if we disable request parsing:

# for client {'id': 'deproxy', 'type': 'deproxy', 'addr': "${tempesta_ip}", 'port': '80'}
>>> client = self.get_client('deproxy')
>>> client.start()
>>> client.parsing = False
>>> client.make_request('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-Length: invalid\r\n\r\n')
>>> client.wait_for_response()

We will send request and receive response:

HTTP/1.1 400 Bad Request
date: Tue, 18 Oct 2022 10:34:02 GMT
content-length: 0
server: Tempesta FW/pre-0.7.0
connection: close

deproxy h2

# for client {'id': 'deproxy', 'type': 'deproxy_h2', 'addr': '${tempesta_ip}', 'port': '443', 'ssl': True, 'ssl_hostname': 'localhost'}
>>> client = self.get_client('deproxy')
>>> client.make_request(
    (':path', '/'),
    (':scheme', 'https'),
    (':method', 'GET')
)
>>> client.wait_for_response()

Traceback output - h2.exceptions.ProtocolError: Request header block does not have an :authority or Host header.

# for client {'id': 'deproxy', 'type': 'deproxy_h2', 'addr': '${tempesta_ip}', 'port': '443', 'ssl': True, 'ssl_hostname': 'localhost'}
>>> client = self.get_client('deproxy')
>>> client.parsing = False
>>> client.make_request(
    (':path', '/'),
    (':scheme', 'https'),
    (':method', 'GET')
)
>>> client.wait_for_response()

We will send request and receive dmesg warning - Cant convert h2 request to http/1.1: no authority found and response

:status: 500
date: Tue, 18 Oct 2022 11:06:08 GMT
content-length: 0
server: Tempesta FW/pre-0.7.0
b3b commented 1 year ago

Tests are failing becase of the wrong Deproxy address:

======================================================================
FAIL: test_parsing_make_request (selftests.test_deproxy.DeproxyTestH2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/b3bf/git/tempesta-pr/selftests/test_deproxy.py", line 163, in test_parsing_make_request
    self.start_all()
  File "/home/b3bf/git/tempesta-pr/selftests/test_deproxy.py", line 143, in start_all
    self.assertTrue(self.wait_all_connections())
AssertionError: False is not true

======================================================================
FAIL: test_with_body (selftests.test_deproxy.DeproxyTestH2)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/b3bf/git/tempesta-pr/selftests/test_deproxy.py", line 232, in test_with_body
    self.start_all()
  File "/home/b3bf/git/tempesta-pr/selftests/test_deproxy.py", line 143, in start_all
    self.assertTrue(self.wait_all_connections())
AssertionError: False is not true

----------------------------------------------------------------------