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

jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 010b507f29 Bugfix/41067 Fix `base_auth_manager` (#41105)
010b507f29 is described below

commit 010b507f290096375ef01d9baae458b2a461752e
Author: Vincent <97131062+vincb...@users.noreply.github.com>
AuthorDate: Mon Jul 29 17:51:27 2024 -0400

    Bugfix/41067 Fix `base_auth_manager` (#41105)
---
 tests/auth/managers/test_base_auth_manager.py | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/tests/auth/managers/test_base_auth_manager.py 
b/tests/auth/managers/test_base_auth_manager.py
index 7628924ad6..cd9652fb46 100644
--- a/tests/auth/managers/test_base_auth_manager.py
+++ b/tests/auth/managers/test_base_auth_manager.py
@@ -20,7 +20,6 @@ from typing import TYPE_CHECKING
 from unittest.mock import MagicMock, Mock, patch
 
 import pytest
-from flask import Flask
 from flask_appbuilder.menu import Menu
 
 from airflow.auth.managers.base_auth_manager import BaseAuthManager, 
ResourceMethod
@@ -31,8 +30,6 @@ from airflow.auth.managers.models.resource_details import (
     VariableDetails,
 )
 from airflow.exceptions import AirflowException
-from airflow.www.extensions.init_appbuilder import init_appbuilder
-from airflow.www.security_manager import AirflowSecurityManagerV2
 
 if TYPE_CHECKING:
     from airflow.auth.managers.models.base_user import BaseUser
@@ -114,13 +111,6 @@ def auth_manager():
     return EmptyAuthManager(None)
 
 
-@pytest.fixture
-def auth_manager_with_appbuilder():
-    flask_app = Flask(__name__)
-    appbuilder = init_appbuilder(flask_app)
-    return EmptyAuthManager(appbuilder)
-
-
 class TestBaseAuthManager:
     def test_get_cli_commands_return_empty_list(self, auth_manager):
         assert auth_manager.get_cli_commands() == []
@@ -238,9 +228,11 @@ class TestBaseAuthManager:
         )
         assert result == expected
 
-    @pytest.mark.db_test
-    def test_security_manager_return_default_security_manager(self, 
auth_manager_with_appbuilder):
-        assert isinstance(auth_manager_with_appbuilder.security_manager, 
AirflowSecurityManagerV2)
+    @patch("airflow.www.security_manager.AirflowSecurityManagerV2")
+    def test_security_manager_return_default_security_manager(
+        self, mock_airflow_security_manager, auth_manager
+    ):
+        assert auth_manager.security_manager == mock_airflow_security_manager()
 
     @pytest.mark.parametrize(
         "access_all, access_per_dag, dag_ids, expected",

Reply via email to