You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2021/06/10 17:50:11 UTC

[airflow] branch v1-10-stable updated: Fix too specific parsing of `False` in LegacyUIDeprecated (#14967)

This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch v1-10-stable
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v1-10-stable by this push:
     new 4a27689  Fix too specific parsing of `False` in LegacyUIDeprecated (#14967)
4a27689 is described below

commit 4a276897169bd977f136983f929b59baac82c628
Author: Marian Cepok <ma...@gmail.com>
AuthorDate: Thu Jun 10 19:49:45 2021 +0200

    Fix too specific parsing of `False` in LegacyUIDeprecated (#14967)
---
 airflow/upgrade/rules/legacy_ui_deprecated.py    |  4 ++--
 tests/upgrade/rules/test_legacy_ui_deprecated.py | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/airflow/upgrade/rules/legacy_ui_deprecated.py b/airflow/upgrade/rules/legacy_ui_deprecated.py
index 9570af7..07617a8 100644
--- a/airflow/upgrade/rules/legacy_ui_deprecated.py
+++ b/airflow/upgrade/rules/legacy_ui_deprecated.py
@@ -28,8 +28,8 @@ class LegacyUIDeprecated(BaseRule):
 
     def check(self):
         if conf.has_option("webserver", "rbac"):
-            rbac = conf.get("webserver", "rbac")
-            if rbac == "false":
+            rbac = conf.get("webserver", "rbac").strip().lower()
+            if rbac in ("f", "false", "0"):
                 return (
                     "rbac in airflow.cfg must be explicitly set empty as"
                     " RBAC mechanism is enabled by default."
diff --git a/tests/upgrade/rules/test_legacy_ui_deprecated.py b/tests/upgrade/rules/test_legacy_ui_deprecated.py
index adbbe8f..1aea7ef 100644
--- a/tests/upgrade/rules/test_legacy_ui_deprecated.py
+++ b/tests/upgrade/rules/test_legacy_ui_deprecated.py
@@ -15,14 +15,15 @@
 # specific language governing permissions and limitations
 # under the License.
 from unittest import TestCase
+from unittest.mock import patch
 
 from airflow.upgrade.rules.legacy_ui_deprecated import LegacyUIDeprecated
 from tests.test_utils.config import conf_vars
 
 
 class TestLegacyUIDeprecated(TestCase):
-    @conf_vars({("webserver", "rbac"): "false"})
-    def test_invalid_check(self):
+    @patch('airflow.configuration.conf.get')
+    def test_invalid_check(self, conf_get):
         rule = LegacyUIDeprecated()
 
         assert isinstance(rule.description, str)
@@ -32,8 +33,10 @@ class TestLegacyUIDeprecated(TestCase):
             "rbac in airflow.cfg must be explicitly set empty as"
             " RBAC mechanism is enabled by default."
         )
-        response = rule.check()
-        assert response == msg
+        for false_value in ("False", "false", "f", "0"):
+            conf_get.return_value = false_value
+            response = rule.check()
+            assert response == msg
 
     @conf_vars({("webserver", "rbac"): ""})
     def test_valid_check(self):