timkpaine commented on a change in pull request #6723: [AIRFLOW-6168] allows 
proxyfix to be configurable
URL: https://github.com/apache/airflow/pull/6723#discussion_r355538486
 
 

 ##########
 File path: tests/www/test_app.py
 ##########
 @@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, 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.
+
+import unittest
+
+from werkzeug.middleware.proxy_fix import ProxyFix
+
+from airflow.configuration import conf
+from airflow.settings import Session
+from airflow.www import app as application
+
+
+class TestApp(unittest.TestCase):
+    def test_constructor_no_proxyfix(self):
+        conf.set("webserver", "enable_proxy_fix", "False")
+        app, _ = application.create_app(session=Session, testing=True)
+        self.assertFalse(isinstance(app.wsgi_app, ProxyFix))
+
+    def test_constructor_proxyfix(self):
+        conf.set("webserver", "enable_proxy_fix", "True")
+        app, _ = application.create_app(session=Session, testing=True)
+        self.assertTrue(isinstance(app.wsgi_app, ProxyFix))
+        self.assertEqual(app.wsgi_app.x_for, '1')
+        self.assertEqual(app.wsgi_app.x_proto, '1')
+        self.assertEqual(app.wsgi_app.x_host, '1')
+        self.assertEqual(app.wsgi_app.x_port, '1')
+        self.assertEqual(app.wsgi_app.x_prefix, '1')
+
+    def test_constructor_proxyfix_args(self):
+        conf.set("webserver", "proxy_fix_x_for", '3')
 
 Review comment:
   apologies, i was working off `test_views.py` as an example, which does this 
extensively. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to