From f628acd526e0de211dd82126f4bf65aaaf0f12fe Mon Sep 17 00:00:00 2001 From: Erik Olof Gunnar Andersson Date: Wed, 2 Oct 2019 18:59:16 -0700 Subject: [PATCH] Removed unused SSLMiddleware The SSL middlware has been replaced by http_proxy_to_wsgi since Mitaka. Change-Id: Ie36d184c3ed981193fb3ec77f586ed9870960b62 --- designate/api/middleware.py | 26 -------------- designate/tests/unit/api/test_middleware.py | 39 --------------------- 2 files changed, 65 deletions(-) diff --git a/designate/api/middleware.py b/designate/api/middleware.py index 5860594be..ce0b0bd22 100644 --- a/designate/api/middleware.py +++ b/designate/api/middleware.py @@ -13,7 +13,6 @@ # 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 import flask import webob.dec from oslo_config import cfg @@ -361,28 +360,3 @@ class APIv2ValidationErrorMiddleware(ValidationErrorMiddleware): def __init__(self, application): super(APIv2ValidationErrorMiddleware, self).__init__(application) self.api_version = 'API_v2' - - -class SSLMiddleware(base.Middleware): - """A middleware that replaces the request wsgi.url_scheme environment - variable with the value of HTTP header configured in - secure_proxy_ssl_header if exists in the incoming request. - This is useful if the server is behind a SSL termination proxy. - - Code nabbed from Heat. - """ - # Replaced by oslo.middleware's http_proxy_to_wsgi middleware - @removals.remove - def __init__(self, application): - super(SSLMiddleware, self).__init__(application) - LOG.info('Starting designate ssl middleware') - self.secure_proxy_ssl_header = 'HTTP_{0}'.format( - cfg.CONF['service:api'].secure_proxy_ssl_header.upper(). - replace('-', '_')) - self.override = cfg.CONF['service:api'].override_proto - - def process_request(self, request): - request.environ['wsgi.url_scheme'] = request.environ.get( - self.secure_proxy_ssl_header, request.environ['wsgi.url_scheme']) - if self.override: - request.environ['wsgi.url_scheme'] = self.override diff --git a/designate/tests/unit/api/test_middleware.py b/designate/tests/unit/api/test_middleware.py index e763b5eb4..2de766ac0 100644 --- a/designate/tests/unit/api/test_middleware.py +++ b/designate/tests/unit/api/test_middleware.py @@ -143,42 +143,3 @@ class KeystoneContextMiddlewareTest(oslotest.base.BaseTestCase): self.app(self.request) self.assertFalse(self.ctxt.edit_managed_records) - - -class SSLMiddlewareTest(oslotest.base.BaseTestCase): - def setUp(self): - super(SSLMiddlewareTest, self).setUp() - self.app = middleware.SSLMiddleware({}) - - self.request = FakeRequest() - - def test_bogus_header(self): - self.request.environ['wsgi.url_scheme'] = 'http' - # If someone sends something bogus, it will infect their self links - self.request.environ['HTTP_X_FORWARDED_PROTO'] = 'test' - self.app(self.request) - - self.assertEqual('test', self.request.environ['wsgi.url_scheme']) - - def test_http_header(self): - self.request.environ['wsgi.url_scheme'] = '' - self.request.environ['HTTP_X_FORWARDED_PROTO'] = 'http' - self.app(self.request) - - self.assertEqual('http', self.request.environ['wsgi.url_scheme']) - - def test_https_header(self): - self.request.environ['wsgi.url_scheme'] = 'http' - self.request.environ['HTTP_X_FORWARDED_PROTO'] = 'https' - self.app(self.request) - - self.assertEqual('https', self.request.environ['wsgi.url_scheme']) - - def test_override_proto(self): - self.request.environ['wsgi.url_scheme'] = 'http' - self.request.environ['HTTP_X_FORWARDED_PROTO'] = 'https' - self.app.override = 'test' - - self.app(self.request) - - self.assertEqual('test', self.request.environ['wsgi.url_scheme'])