diff options
author | gordon chung <gord@live.ca> | 2015-11-09 11:35:34 -0500 |
---|---|---|
committer | gordon chung <gord@live.ca> | 2015-11-09 13:31:59 -0500 |
commit | e11c08eef8587518010ce2dbbeb8b450886b09bf (patch) | |
tree | e32ea98ac4cf2d527aa2e961b50c92caa84d99f3 | |
parent | b4ad4f9073136298294ee9ba10c23ebb2f77a705 (diff) | |
download | oslo-middleware-e11c08eef8587518010ce2dbbeb8b450886b09bf.tar.gz |
add missing shortcut for HTTPProxyToWSGI middleware
we should've added a shortcut to oslo_middleware/__init__ to hide path.
additionally we shouldn't have added Middleware to class name as it's
redundant
Change-Id: Id581180c24006aa142eb8bf086eb7fc42835cff5
Closes-Bug: #1514507
-rw-r--r-- | oslo_middleware/__init__.py | 2 | ||||
-rw-r--r-- | oslo_middleware/http_proxy_to_wsgi.py | 9 | ||||
-rw-r--r-- | oslo_middleware/tests/test_http_proxy_to_wsgi.py | 11 |
3 files changed, 19 insertions, 3 deletions
diff --git a/oslo_middleware/__init__.py b/oslo_middleware/__init__.py index b2ea8c0..ea1c12d 100644 --- a/oslo_middleware/__init__.py +++ b/oslo_middleware/__init__.py @@ -15,6 +15,7 @@ __all__ = ['CatchErrors', 'CORS', 'Debug', 'Healthcheck', + 'HTTPProxyToWSGI', 'RequestId', 'RequestBodySizeLimiter', 'SSLMiddleware'] @@ -24,6 +25,7 @@ from oslo_middleware.correlation_id import CorrelationId from oslo_middleware.cors import CORS from oslo_middleware.debug import Debug from oslo_middleware.healthcheck import Healthcheck +from oslo_middleware.http_proxy_to_wsgi import HTTPProxyToWSGI from oslo_middleware.request_id import RequestId from oslo_middleware.sizelimit import RequestBodySizeLimiter from oslo_middleware.ssl import SSLMiddleware diff --git a/oslo_middleware/http_proxy_to_wsgi.py b/oslo_middleware/http_proxy_to_wsgi.py index 425f414..a2da6ab 100644 --- a/oslo_middleware/http_proxy_to_wsgi.py +++ b/oslo_middleware/http_proxy_to_wsgi.py @@ -11,11 +11,11 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing permissions and # limitations under the License. - +from debtcollector import removals from oslo_middleware import base -class HTTPProxyToWSGIMiddleware(base.ConfigurableMiddleware): +class HTTPProxyToWSGI(base.ConfigurableMiddleware): """HTTP proxy to WSGI termination middleware. This middleware overloads WSGI environment variables with the one provided @@ -68,3 +68,8 @@ class HTTPProxyToWSGIMiddleware(base.ConfigurableMiddleware): v = req.environ.get("HTTP_X_FORWARDED_PREFIX") if v: req.environ['SCRIPT_NAME'] = v + req.environ['SCRIPT_NAME'] + + +@removals.remove +class HTTPProxyToWSGIMiddleware(HTTPProxyToWSGI): + """Placeholder for backward compatibility""" diff --git a/oslo_middleware/tests/test_http_proxy_to_wsgi.py b/oslo_middleware/tests/test_http_proxy_to_wsgi.py index bbd3601..8db1190 100644 --- a/oslo_middleware/tests/test_http_proxy_to_wsgi.py +++ b/oslo_middleware/tests/test_http_proxy_to_wsgi.py @@ -28,9 +28,18 @@ class TestHTTPProxyToWSGI(test_base.BaseTestCase): def fake_app(req): return util.application_uri(req.environ) + self.middleware = http_proxy_to_wsgi.HTTPProxyToWSGI(fake_app) + self.request = webob.Request.blank('/foo/bar', method='POST') + + def test_backward_compat(self): + @webob.dec.wsgify() + def fake_app(req): + return util.application_uri(req.environ) + self.middleware = http_proxy_to_wsgi.HTTPProxyToWSGIMiddleware( fake_app) - self.request = webob.Request.blank('/foo/bar', method='POST') + response = self.request.get_response(self.middleware) + self.assertEqual(b"http://localhost:80/", response.body) def test_no_headers(self): response = self.request.get_response(self.middleware) |