Tests: minor fixes.

This commit is contained in:
Andrei Zeliankou
2022-09-07 01:11:04 +01:00
parent 9d3b9dba40
commit c65e04682e
11 changed files with 19 additions and 171 deletions

View File

@@ -15,7 +15,6 @@ class application:
self.start( self.start(
'200', '200',
[ [
('Content-Type', self.environ.get('CONTENT_TYPE')),
('Content-Length', str(len(body))), ('Content-Length', str(len(body))),
], ],
) )

View File

@@ -36,7 +36,6 @@ class TestAccessLog(TestApplicationPython):
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body='01234', body='01234',
@@ -47,15 +46,7 @@ class TestAccessLog(TestApplicationPython):
self.wait_for_record(r'"POST / HTTP/1.1" 200 5') is not None self.wait_for_record(r'"POST / HTTP/1.1" 200 5') is not None
), 'keepalive 1' ), 'keepalive 1'
resp = self.post( resp = self.post(sock=sock, body='0123456789')
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=sock,
body='0123456789',
)
assert ( assert (
self.wait_for_record(r'"POST / HTTP/1.1" 200 10') is not None self.wait_for_record(r'"POST / HTTP/1.1" 200 10') is not None
@@ -315,16 +306,7 @@ Connection: close
self.set_format('$uri $body_bytes_sent') self.set_format('$uri $body_bytes_sent')
body = '0123456789' * 50 body = '0123456789' * 50
self.post( self.post(url='/bbs', body=body, read_timeout=1)
url='/bbs',
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
body=body,
read_timeout=1,
)
assert ( assert (
self.wait_for_record(r'^\/bbs ' + str(len(body)) + r'$') is not None self.wait_for_record(r'^\/bbs ' + str(len(body)) + r'$') is not None
), '$body_bytes_sent' ), '$body_bytes_sent'

View File

@@ -160,15 +160,7 @@ custom-header: BLAH
assert self.get()['status'] == 200, 'init' assert self.get()['status'] == 200, 'init'
body = '0123456789AB' * 1024 * 1024 # 12 Mb body = '0123456789AB' * 1024 * 1024 # 12 Mb
resp = self.post( resp = self.post(body=body, read_buffer_size=1024 * 1024)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
body=body,
read_buffer_size=1024 * 1024,
)
assert resp['body'] == body, 'keep-alive 1' assert resp['body'] == body, 'keep-alive 1'
@@ -182,7 +174,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -192,15 +183,7 @@ custom-header: BLAH
assert resp['body'] == body, 'keep-alive 1' assert resp['body'] == body, 'keep-alive 1'
body = '0123456789' body = '0123456789'
resp = self.post( resp = self.post(sock=sock, body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=sock,
body=body,
)
assert resp['body'] == body, 'keep-alive 2' assert resp['body'] == body, 'keep-alive 2'
@@ -218,7 +201,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -236,7 +218,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
sock=socks[i], sock=socks[i],
@@ -249,15 +230,7 @@ custom-header: BLAH
self.load('mirror', processes=i + 1) self.load('mirror', processes=i + 1)
for i in range(conns): for i in range(conns):
resp = self.post( resp = self.post(sock=socks[i], body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=socks[i],
body=body,
)
assert resp['body'] == body, 'keep-alive close' assert resp['body'] == body, 'keep-alive close'
@@ -274,7 +247,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -287,16 +259,7 @@ custom-header: BLAH
assert self.get()['status'] == 200, 'init' assert self.get()['status'] == 200, 'init'
(resp, sock) = self.post( (resp, sock) = self.post(start=True, sock=sock, body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
start=True,
sock=sock,
body=body,
)
assert resp['status'] == 200, 'reconfigure 2 keep-alive 2' assert resp['status'] == 200, 'reconfigure 2 keep-alive 2'
assert resp['body'] == '', 'reconfigure 2 keep-alive 2 body' assert resp['body'] == '', 'reconfigure 2 keep-alive 2 body'

View File

@@ -229,18 +229,12 @@ class TestConfiguration(TestControl):
def test_listeners_unix_abstract(self): def test_listeners_unix_abstract(self):
if option.system != 'Linux': if option.system != 'Linux':
assert 'error' in self.conf( assert 'error' in self.try_addr("unix:@sock"), 'abstract at'
{"unix:@sock": {"pass": "routes"}}, 'listeners'
), 'unix abstract at'
pytest.skip('not yet') pytest.skip('not yet')
assert 'error' in self.conf( assert 'error' in self.try_addr("unix:\0soc"), 'abstract \0'
{"unix:\0sock": {"pass": "routes"}}, 'listeners' assert 'error' in self.try_addr("unix:\u0000soc"), 'abstract \0 unicode'
), 'unix abstract zero'
assert 'error' in self.conf(
{"unix:\u0000sock": {"pass": "routes"}}, 'listeners'
), 'unix abstract zero unicode'
def test_listeners_addr(self): def test_listeners_addr(self):
assert 'success' in self.try_addr("*:7080"), 'wildcard' assert 'success' in self.try_addr("*:7080"), 'wildcard'

View File

@@ -95,7 +95,6 @@ class TestGoApplication(TestApplicationGo):
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -105,16 +104,7 @@ class TestGoApplication(TestApplicationGo):
assert resp['body'] == body, 'keep-alive 1' assert resp['body'] == body, 'keep-alive 1'
body = '0123456789' body = '0123456789'
resp = self.post( resp = self.post(sock=sock, body=body)
headers={
'Host': 'localhost',
'Content-Type': 'text/html',
'Connection': 'close',
},
sock=sock,
body=body,
)
assert resp['body'] == body, 'keep-alive 2' assert resp['body'] == body, 'keep-alive 2'
def test_go_application_cookies(self): def test_go_application_cookies(self):

View File

@@ -124,7 +124,6 @@ class TestNodeApplication(TestApplicationNode):
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -134,15 +133,7 @@ class TestNodeApplication(TestApplicationNode):
assert resp['body'] == '0123456789' * 500, 'keep-alive 1' assert resp['body'] == '0123456789' * 500, 'keep-alive 1'
body = '0123456789' body = '0123456789'
resp = self.post( resp = self.post(sock=sock, body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=sock,
body=body,
)
assert resp['body'] == body, 'keep-alive 2' assert resp['body'] == body, 'keep-alive 2'

View File

@@ -226,7 +226,6 @@ opcache.preload_user = %(user)s
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -236,15 +235,7 @@ opcache.preload_user = %(user)s
assert resp['body'] == body, 'keep-alive 1' assert resp['body'] == body, 'keep-alive 1'
body = '0123456789' body = '0123456789'
resp = self.post( resp = self.post(sock=sock, body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=sock,
body=body,
)
assert resp['body'] == body, 'keep-alive 2' assert resp['body'] == body, 'keep-alive 2'

View File

@@ -370,7 +370,6 @@ Content-Length: 10
resp = self.post_http10( resp = self.post_http10(
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Content-Type': 'text/html',
'Content-Length': str(len(body)), 'Content-Length': str(len(body)),
'X-Parts': '2', 'X-Parts': '2',
'X-Delay': '1', 'X-Delay': '1',
@@ -384,7 +383,6 @@ Content-Length: 10
resp = self.post_http10( resp = self.post_http10(
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Content-Type': 'text/html',
'Content-Length': str(len(body)), 'Content-Length': str(len(body)),
'X-Parts': '2', 'X-Parts': '2',
'X-Delay': '1', 'X-Delay': '1',
@@ -403,7 +401,6 @@ Content-Length: 10
_, sock = self.post_http10( _, sock = self.post_http10(
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Content-Type': 'text/html',
'Content-Length': '10000', 'Content-Length': '10000',
'X-Parts': '3', 'X-Parts': '3',
'X-Delay': '1', 'X-Delay': '1',
@@ -419,7 +416,6 @@ Content-Length: 10
_, sock = self.post_http10( _, sock = self.post_http10(
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Content-Type': 'text/html',
'Content-Length': '10000', 'Content-Length': '10000',
'X-Parts': '3', 'X-Parts': '3',
'X-Delay': '1', 'X-Delay': '1',

View File

@@ -138,14 +138,7 @@ custom-header: BLAH
def test_python_application_ctx_iter_atexit(self): def test_python_application_ctx_iter_atexit(self):
self.load('ctx_iter_atexit') self.load('ctx_iter_atexit')
resp = self.post( resp = self.post(body='0123456789')
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
body='0123456789',
)
assert resp['status'] == 200, 'ctx iter status' assert resp['status'] == 200, 'ctx iter status'
assert resp['body'] == '0123456789', 'ctx iter body' assert resp['body'] == '0123456789', 'ctx iter body'
@@ -166,7 +159,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -176,15 +168,7 @@ custom-header: BLAH
assert resp['body'] == body, 'keep-alive 1' assert resp['body'] == body, 'keep-alive 1'
body = '0123456789' body = '0123456789'
resp = self.post( resp = self.post(sock=sock, body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=sock,
body=body,
)
assert resp['body'] == body, 'keep-alive 2' assert resp['body'] == body, 'keep-alive 2'
@@ -202,7 +186,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -220,7 +203,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
sock=socks[i], sock=socks[i],
@@ -233,15 +215,7 @@ custom-header: BLAH
self.load('mirror', processes=i + 1) self.load('mirror', processes=i + 1)
for i in range(conns): for i in range(conns):
resp = self.post( resp = self.post(sock=socks[i], body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=socks[i],
body=body,
)
assert resp['body'] == body, 'keep-alive close' assert resp['body'] == body, 'keep-alive close'
@@ -258,7 +232,6 @@ custom-header: BLAH
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -271,16 +244,7 @@ custom-header: BLAH
assert self.get()['status'] == 200, 'init' assert self.get()['status'] == 200, 'init'
(resp, sock) = self.post( (resp, sock) = self.post(start=True, sock=sock, body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
start=True,
sock=sock,
body=body,
)
assert resp['status'] == 200, 'reconfigure 2 keep-alive 2' assert resp['status'] == 200, 'reconfigure 2 keep-alive 2'
assert resp['body'] == '', 'reconfigure 2 keep-alive 2 body' assert resp['body'] == '', 'reconfigure 2 keep-alive 2 body'

View File

@@ -347,7 +347,6 @@ class TestRubyApplication(TestApplicationRuby):
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body=body, body=body,
@@ -357,15 +356,7 @@ class TestRubyApplication(TestApplicationRuby):
assert resp['body'] == body, 'keep-alive 1' assert resp['body'] == body, 'keep-alive 1'
body = '0123456789' body = '0123456789'
resp = self.post( resp = self.post(sock=sock, body=body)
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=sock,
body=body,
)
assert resp['body'] == body, 'keep-alive 2' assert resp['body'] == body, 'keep-alive 2'

View File

@@ -505,7 +505,6 @@ basicConstraints = critical,CA:TRUE"""
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body='0123456789', body='0123456789',
@@ -518,7 +517,6 @@ basicConstraints = critical,CA:TRUE"""
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'close', 'Connection': 'close',
'Content-Type': 'text/html',
}, },
sock=sock, sock=sock,
body='0123456789', body='0123456789',
@@ -570,9 +568,7 @@ basicConstraints = critical,CA:TRUE"""
assert 'success' in self.conf_delete('/certificates/default') assert 'success' in self.conf_delete('/certificates/default')
try: try:
resp = self.get_ssl( resp = self.get_ssl(sock=sock)
headers={'Host': 'localhost', 'Connection': 'close'}, sock=sock
)
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
@@ -605,7 +601,6 @@ basicConstraints = critical,CA:TRUE"""
headers={ headers={
'Host': 'localhost', 'Host': 'localhost',
'Connection': 'keep-alive', 'Connection': 'keep-alive',
'Content-Type': 'text/html',
}, },
start=True, start=True,
body='0123456789', body='0123456789',
@@ -622,15 +617,7 @@ basicConstraints = critical,CA:TRUE"""
r' (?!' + app_id + r'#)(\d+)#\d+ "mirror" application started' r' (?!' + app_id + r'#)(\d+)#\d+ "mirror" application started'
) )
resp = self.post_ssl( resp = self.post_ssl(sock=sock, body='0123456789')
headers={
'Host': 'localhost',
'Connection': 'close',
'Content-Type': 'text/html',
},
sock=sock,
body='0123456789',
)
assert resp['status'] == 200, 'application respawn status' assert resp['status'] == 200, 'application respawn status'
assert resp['body'] == '0123456789', 'application respawn body' assert resp['body'] == '0123456789', 'application respawn body'