diff options
Diffstat (limited to 'oslo_middleware/tests/test_request_id.py')
-rw-r--r-- | oslo_middleware/tests/test_request_id.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/oslo_middleware/tests/test_request_id.py b/oslo_middleware/tests/test_request_id.py index 039b7af..5c79c21 100644 --- a/oslo_middleware/tests/test_request_id.py +++ b/oslo_middleware/tests/test_request_id.py @@ -22,6 +22,10 @@ import webob.dec from oslo_middleware import request_id +class AltHeader(request_id.RequestId): + compat_headers = ["x-compute-req-id", "x-silly-id"] + + class RequestIdTest(test_base.BaseTestCase): def test_generate_request_id(self): @webob.dec.wsgify @@ -37,3 +41,25 @@ class RequestIdTest(test_base.BaseTestCase): self.assertThat(res_req_id, matchers.StartsWith('req-')) # request-id in request environ is returned as response body self.assertEqual(res.body.decode('utf-8'), res_req_id) + + def test_compat_headers(self): + """Test that compat headers are set + + Compat headers might exist on a super class to support + previous API contracts. This ensures that you can set that to + a list of headers and those values are the same as the + request_id. + + """ + @webob.dec.wsgify + def application(req): + return req.environ[request_id.ENV_REQUEST_ID] + + app = AltHeader(application) + req = webob.Request.blank('/test') + res = req.get_response(app) + + res_req_id = res.headers.get(request_id.HTTP_RESP_HEADER_REQUEST_ID) + + self.assertEqual(res.headers.get("x-compute-req-id"), res_req_id) + self.assertEqual(res.headers.get("x-silly-id"), res_req_id) |