From a48488764a38961a66ad07c4bf629f220f80334c Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Garcia Date: Fri, 14 Jun 2013 13:47:10 +0200 Subject: wsgi.Middleware factory should use **kwargs Fixes bug 1190978 Change-Id: Ifb0673b7aab5292c13bf5c86c5cc2de8096f7e3e --- keystone/common/wsgi.py | 2 +- tests/test_wsgi.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/keystone/common/wsgi.py b/keystone/common/wsgi.py index d5368b2a..8f76b24f 100644 --- a/keystone/common/wsgi.py +++ b/keystone/common/wsgi.py @@ -288,7 +288,7 @@ class Middleware(Application): def _factory(app): conf = global_config.copy() conf.update(local_config) - return cls(app) + return cls(app, **local_config) return _factory def __init__(self, application): diff --git a/tests/test_wsgi.py b/tests/test_wsgi.py index 8e266749..c73212c8 100644 --- a/tests/test_wsgi.py +++ b/tests/test_wsgi.py @@ -176,3 +176,13 @@ class MiddlewareTest(BaseWSGITest): resp = FakeMiddleware(self.app)(req) self.assertEquals(resp.status_int, exception.UnexpectedError.code) self.assertIn("EXCEPTIONERROR", resp.body) + + def test_middleware_local_config(self): + class FakeMiddleware(wsgi.Middleware): + def __init__(self, *args, **kwargs): + self.kwargs = kwargs + + factory = FakeMiddleware.factory({}, testkey="test") + app = factory(self.app) + self.assertIn("testkey", app.kwargs) + self.assertEquals("test", app.kwargs["testkey"]) -- cgit