tests/py3: Improve header casing
Previously, our unit tests with socket servers would let eventlet capitalize headers on the way out, which - isn't something we want to have eventlet do, because it - breaks unicode-in-header-names on py3, so it - is already disabled in swift.common.wsgi.run_server() for real servers. Include a test to make sure we don't forget about it in the future. Change-Id: I0156d0059092ed414b296c65fb70fc18533b074a
This commit is contained in:
parent
2545372055
commit
4d83b9b95e
@ -214,27 +214,38 @@ def setup_servers(the_object_server=object_server, extra_conf=None):
|
|||||||
logging_prosv = proxy_logging.ProxyLoggingMiddleware(
|
logging_prosv = proxy_logging.ProxyLoggingMiddleware(
|
||||||
listing_formats.ListingFilter(prosrv), conf, logger=prosrv.logger)
|
listing_formats.ListingFilter(prosrv), conf, logger=prosrv.logger)
|
||||||
prospa = spawn(wsgi.server, prolis, logging_prosv, nl,
|
prospa = spawn(wsgi.server, prolis, logging_prosv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
acc1spa = spawn(wsgi.server, acc1lis, acc1srv, nl,
|
acc1spa = spawn(wsgi.server, acc1lis, acc1srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
acc2spa = spawn(wsgi.server, acc2lis, acc2srv, nl,
|
acc2spa = spawn(wsgi.server, acc2lis, acc2srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
con1spa = spawn(wsgi.server, con1lis, con1srv, nl,
|
con1spa = spawn(wsgi.server, con1lis, con1srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
con2spa = spawn(wsgi.server, con2lis, con2srv, nl,
|
con2spa = spawn(wsgi.server, con2lis, con2srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
obj1spa = spawn(wsgi.server, obj1lis, obj1srv, nl,
|
obj1spa = spawn(wsgi.server, obj1lis, obj1srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
obj2spa = spawn(wsgi.server, obj2lis, obj2srv, nl,
|
obj2spa = spawn(wsgi.server, obj2lis, obj2srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
obj3spa = spawn(wsgi.server, obj3lis, obj3srv, nl,
|
obj3spa = spawn(wsgi.server, obj3lis, obj3srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
obj4spa = spawn(wsgi.server, obj4lis, obj4srv, nl,
|
obj4spa = spawn(wsgi.server, obj4lis, obj4srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
obj5spa = spawn(wsgi.server, obj5lis, obj5srv, nl,
|
obj5spa = spawn(wsgi.server, obj5lis, obj5srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
obj6spa = spawn(wsgi.server, obj6lis, obj6srv, nl,
|
obj6spa = spawn(wsgi.server, obj6lis, obj6srv, nl,
|
||||||
protocol=SwiftHttpProtocol)
|
protocol=SwiftHttpProtocol,
|
||||||
|
capitalize_response_headers=False)
|
||||||
context["test_coros"] = \
|
context["test_coros"] = \
|
||||||
(prospa, acc1spa, acc2spa, con1spa, con2spa, obj1spa, obj2spa, obj3spa,
|
(prospa, acc1spa, acc2spa, con1spa, con2spa, obj1spa, obj2spa, obj3spa,
|
||||||
obj4spa, obj5spa, obj6spa)
|
obj4spa, obj5spa, obj6spa)
|
||||||
|
@ -2432,6 +2432,41 @@ class TestReplicatedObjectController(
|
|||||||
self.assertEqual(res.status_int, 200)
|
self.assertEqual(res.status_int, 200)
|
||||||
self.assertEqual(res.body, b'')
|
self.assertEqual(res.body, b'')
|
||||||
|
|
||||||
|
@unpatch_policies
|
||||||
|
def test_PUT_GET_unicode_metadata(self):
|
||||||
|
prolis = _test_sockets[0]
|
||||||
|
sock = connect_tcp(('localhost', prolis.getsockname()[1]))
|
||||||
|
fd = sock.makefile('rwb')
|
||||||
|
|
||||||
|
path = b'/v1/a/c/o.zerobyte'
|
||||||
|
fd.write(b'PUT %s HTTP/1.1\r\n'
|
||||||
|
b'Host: localhost\r\n'
|
||||||
|
b'X-Storage-Token: t\r\n'
|
||||||
|
b'Expect: 100-continue\r\n'
|
||||||
|
b'Transfer-Encoding: chunked\r\n'
|
||||||
|
b'Content-Type: application/octet-stream\r\n'
|
||||||
|
b'X-Object-Meta-\xf0\x9f\x8c\xb4: \xf0\x9f\x91\x8d\r\n'
|
||||||
|
b'\r\n0\r\n\r\n' % (path,))
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = b'HTTP/1.1 100'
|
||||||
|
self.assertEqual(headers[:len(exp)], exp)
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = b'HTTP/1.1 201'
|
||||||
|
self.assertEqual(headers[:len(exp)], exp)
|
||||||
|
|
||||||
|
fd.write(b'GET %s HTTP/1.1\r\n'
|
||||||
|
b'Host: localhost\r\n'
|
||||||
|
b'Connection: close\r\n'
|
||||||
|
b'X-Storage-Token: t\r\n'
|
||||||
|
b'\r\n' % (path,))
|
||||||
|
fd.flush()
|
||||||
|
headers = readuntil2crlfs(fd)
|
||||||
|
exp = b'HTTP/1.1 200'
|
||||||
|
self.assertEqual(headers[:len(exp)], exp)
|
||||||
|
self.assertIn(b'X-Object-Meta-\xf0\x9f\x8c\xb4: \xf0\x9f\x91\x8d',
|
||||||
|
headers.split(b'\r\n'))
|
||||||
|
|
||||||
@unpatch_policies
|
@unpatch_policies
|
||||||
def test_GET_short_read(self):
|
def test_GET_short_read(self):
|
||||||
prolis = _test_sockets[0]
|
prolis = _test_sockets[0]
|
||||||
@ -5332,7 +5367,7 @@ class TestReplicatedObjectController(
|
|||||||
exp = b'HTTP/1.1 200'
|
exp = b'HTTP/1.1 200'
|
||||||
self.assertEqual(headers[:len(exp)], exp)
|
self.assertEqual(headers[:len(exp)], exp)
|
||||||
self.assertIn(b'\r\nX-Object-Meta-%s: %s\r\n' %
|
self.assertIn(b'\r\nX-Object-Meta-%s: %s\r\n' %
|
||||||
(quote(ustr_short).lower().encode('ascii'),
|
(quote(ustr_short).title().encode('ascii'),
|
||||||
quote(ustr).encode('ascii')), headers)
|
quote(ustr).encode('ascii')), headers)
|
||||||
|
|
||||||
@unpatch_policies
|
@unpatch_policies
|
||||||
|
Loading…
Reference in New Issue
Block a user