diff --git a/devel-common/src/tests_common/test_utils/mock_security_manager.py b/devel-common/src/tests_common/test_utils/mock_security_manager.py deleted file mode 100644 index ee0f49372afa9..0000000000000 --- a/devel-common/src/tests_common/test_utils/mock_security_manager.py +++ /dev/null @@ -1,30 +0,0 @@ -# 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. -from __future__ import annotations - -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0", __file__): - from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride - - -class MockSecurityManager(FabAirflowSecurityManagerOverride): - """Mock Security Manager for testing purposes.""" - - VIEWER_VMS = { - "Airflow", - } diff --git a/providers/common/io/tests/unit/common/io/operators/test_file_transfer.py b/providers/common/io/tests/unit/common/io/operators/test_file_transfer.py index 65751bb3ef7da..7168fa1932665 100644 --- a/providers/common/io/tests/unit/common/io/operators/test_file_transfer.py +++ b/providers/common/io/tests/unit/common/io/operators/test_file_transfer.py @@ -20,11 +20,7 @@ from unittest import mock from airflow.providers.common.compat.openlineage.facet import Dataset - -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.8.0", __file__): - from airflow.providers.common.io.operators.file_transfer import FileTransferOperator +from airflow.providers.common.io.operators.file_transfer import FileTransferOperator def test_file_transfer_copy(): diff --git a/providers/fab/docs/cli-ref.rst b/providers/fab/docs/cli-ref.rst index bd980f8a1ee00..e5e42b8425b0b 100644 --- a/providers/fab/docs/cli-ref.rst +++ b/providers/fab/docs/cli-ref.rst @@ -18,11 +18,6 @@ FAB CLI Commands ================ -.. note:: - The CLI commands below are sourced from the FAB provider by Airflow 2.9.0+. - Previously, they were part of core Airflow, so if you are using Airflow below 2.9.0 please see - the core Airflow documentation for the list of CLI commands and parameters available. - .. argparse:: :module: airflow.providers.fab.auth_manager.fab_auth_manager :func: get_parser diff --git a/providers/fab/tests/unit/fab/auth_manager/api/auth/backend/test_kerberos_auth.py b/providers/fab/tests/unit/fab/auth_manager/api/auth/backend/test_kerberos_auth.py index e57f34ce4b033..83708c6a0d74b 100644 --- a/providers/fab/tests/unit/fab/auth_manager/api/auth/backend/test_kerberos_auth.py +++ b/providers/fab/tests/unit/fab/auth_manager/api/auth/backend/test_kerberos_auth.py @@ -16,10 +16,7 @@ # under the License. from __future__ import annotations -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth import init_app +from airflow.providers.fab.auth_manager.api.auth.backend.kerberos_auth import init_app class TestKerberosAuth: diff --git a/providers/fab/tests/unit/fab/auth_manager/api_endpoints/api_connexion_utils.py b/providers/fab/tests/unit/fab/auth_manager/api_endpoints/api_connexion_utils.py index 674549b432f89..1cd9c628cf572 100644 --- a/providers/fab/tests/unit/fab/auth_manager/api_endpoints/api_connexion_utils.py +++ b/providers/fab/tests/unit/fab/auth_manager/api_endpoints/api_connexion_utils.py @@ -18,13 +18,9 @@ from contextlib import contextmanager +from airflow.providers.fab.auth_manager.security_manager.override import EXISTING_ROLES from airflow.providers.fab.www.api_connexion.exceptions import EXCEPTIONS_LINK_MAP -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.security_manager.override import EXISTING_ROLES - @contextmanager def create_test_client(app, user_name, role_name, permissions): diff --git a/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_role_and_permission_endpoint.py b/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_role_and_permission_endpoint.py index 76dd19237791d..a107d0988abe9 100644 --- a/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_role_and_permission_endpoint.py +++ b/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_role_and_permission_endpoint.py @@ -19,10 +19,11 @@ import pytest from sqlalchemy import select +from airflow.providers.fab.auth_manager.models import Role +from airflow.providers.fab.auth_manager.security_manager.override import EXISTING_ROLES from airflow.providers.fab.www.api_connexion.exceptions import EXCEPTIONS_LINK_MAP from airflow.providers.fab.www.security import permissions -from tests_common.test_utils.compat import ignore_provider_compatibility_error from unit.fab.auth_manager.api_endpoints.api_connexion_utils import ( assert_401, create_role, @@ -31,10 +32,6 @@ delete_user, ) -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.models import Role - from airflow.providers.fab.auth_manager.security_manager.override import EXISTING_ROLES - pytestmark = pytest.mark.db_test diff --git a/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_user_endpoint.py b/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_user_endpoint.py index 0b8b6eb2913fb..6a936d37fe841 100644 --- a/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_user_endpoint.py +++ b/providers/fab/tests/unit/fab/auth_manager/api_endpoints/test_user_endpoint.py @@ -25,7 +25,6 @@ from airflow.providers.fab.www.security import permissions from airflow.utils.session import create_session -from tests_common.test_utils.compat import ignore_provider_compatibility_error from tests_common.test_utils.config import conf_vars from unit.fab.auth_manager.api_endpoints.api_connexion_utils import ( assert_401, @@ -40,9 +39,7 @@ from airflow.sdk import timezone -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.models import User - +from airflow.providers.fab.auth_manager.models import User pytestmark = pytest.mark.db_test diff --git a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_definition.py b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_definition.py index 572cbee05e3db..b34f92875ba12 100644 --- a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_definition.py +++ b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_definition.py @@ -16,14 +16,11 @@ # under the License. from __future__ import annotations -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.cli_commands.definition import ( - ROLES_COMMANDS, - SYNC_PERM_COMMAND, - USERS_COMMANDS, - ) +from airflow.providers.fab.auth_manager.cli_commands.definition import ( + ROLES_COMMANDS, + SYNC_PERM_COMMAND, + USERS_COMMANDS, +) class TestCliDefinition: diff --git a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_permissions_command.py b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_permissions_command.py index cf4a0355647a6..234a18ef6175d 100644 --- a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_permissions_command.py +++ b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_permissions_command.py @@ -28,14 +28,11 @@ import pytest from airflow.cli import cli_parser +from airflow.providers.fab.auth_manager.cli_commands import permissions_command +from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder -from tests_common.test_utils.compat import ignore_provider_compatibility_error from tests_common.test_utils.config import conf_vars -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.cli_commands import permissions_command - from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder - pytestmark = pytest.mark.db_test diff --git a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_role_command.py b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_role_command.py index 2de83df4074e4..8be5f32c371bf 100644 --- a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_role_command.py +++ b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_role_command.py @@ -26,16 +26,12 @@ import pytest from airflow.cli import cli_parser +from airflow.providers.fab.auth_manager.cli_commands import role_command +from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder +from airflow.providers.fab.www.security import permissions -from tests_common.test_utils.compat import ignore_provider_compatibility_error from tests_common.test_utils.config import conf_vars -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.cli_commands import role_command - from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder - -from airflow.providers.fab.www.security import permissions - pytestmark = pytest.mark.db_test diff --git a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_sync_perm_command.py b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_sync_perm_command.py index 12b5fefe27761..3e331a838766b 100644 --- a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_sync_perm_command.py +++ b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_sync_perm_command.py @@ -23,13 +23,10 @@ import pytest from airflow.cli import cli_parser +from airflow.providers.fab.auth_manager.cli_commands import sync_perm_command -from tests_common.test_utils.compat import ignore_provider_compatibility_error from tests_common.test_utils.config import conf_vars -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.cli_commands import sync_perm_command - pytestmark = pytest.mark.db_test diff --git a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py index eb785e303cd7e..23f5056ca8832 100644 --- a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py +++ b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_user_command.py @@ -27,14 +27,11 @@ import pytest from airflow.cli import cli_parser +from airflow.providers.fab.auth_manager.cli_commands import user_command +from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder -from tests_common.test_utils.compat import ignore_provider_compatibility_error from tests_common.test_utils.config import conf_vars -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.cli_commands import user_command - from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder - pytestmark = pytest.mark.db_test TEST_USER1_EMAIL = "test-user1@example.com" diff --git a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_utils.py b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_utils.py index 262ecd0477765..79ae13e79e127 100644 --- a/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_utils.py +++ b/providers/fab/tests/unit/fab/auth_manager/cli_commands/test_utils.py @@ -23,15 +23,12 @@ import airflow from airflow.configuration import conf from airflow.exceptions import AirflowConfigException +from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder from airflow.providers.fab.www.extensions.init_appbuilder import AirflowAppBuilder from airflow.providers.fab.www.session import AirflowDatabaseSessionInterface -from tests_common.test_utils.compat import ignore_provider_compatibility_error from tests_common.test_utils.config import conf_vars -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.cli_commands.utils import get_application_builder - @pytest.fixture def flask_app(): diff --git a/providers/fab/tests/unit/fab/auth_manager/models/test_anonymous_user.py b/providers/fab/tests/unit/fab/auth_manager/models/test_anonymous_user.py index ea959bd25bfb2..44f3d606fdf92 100644 --- a/providers/fab/tests/unit/fab/auth_manager/models/test_anonymous_user.py +++ b/providers/fab/tests/unit/fab/auth_manager/models/test_anonymous_user.py @@ -17,10 +17,7 @@ # under the License. from __future__ import annotations -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.models.anonymous_user import AnonymousUser +from airflow.providers.fab.auth_manager.models.anonymous_user import AnonymousUser class TestAnonymousUser: diff --git a/providers/fab/tests/unit/fab/auth_manager/schemas/test_user_schema.py b/providers/fab/tests/unit/fab/auth_manager/schemas/test_user_schema.py index 91853b16eb3f0..033a09638374c 100644 --- a/providers/fab/tests/unit/fab/auth_manager/schemas/test_user_schema.py +++ b/providers/fab/tests/unit/fab/auth_manager/schemas/test_user_schema.py @@ -19,19 +19,15 @@ import pytest from sqlalchemy import select +from airflow.providers.fab.auth_manager.models import User +from airflow.providers.fab.auth_manager.schemas.user_schema import ( + user_collection_item_schema, + user_schema, +) from airflow.utils import timezone -from tests_common.test_utils.compat import ignore_provider_compatibility_error from unit.fab.auth_manager.api_endpoints.api_connexion_utils import create_role, delete_role -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.models import User - from airflow.providers.fab.auth_manager.schemas.user_schema import ( - user_collection_item_schema, - user_schema, - ) - - TEST_EMAIL = "test@example.org" DEFAULT_TIME = "2021-01-09T13:59:56.336000+00:00" diff --git a/providers/fab/tests/unit/fab/auth_manager/security_manager/test_constants.py b/providers/fab/tests/unit/fab/auth_manager/security_manager/test_constants.py index 401b9b108262c..177b97b1d1b1e 100644 --- a/providers/fab/tests/unit/fab/auth_manager/security_manager/test_constants.py +++ b/providers/fab/tests/unit/fab/auth_manager/security_manager/test_constants.py @@ -16,10 +16,7 @@ # under the License. from __future__ import annotations -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.security_manager.constants import EXISTING_ROLES +from airflow.providers.fab.auth_manager.security_manager.constants import EXISTING_ROLES class TestFbSecurityManagerConstants: diff --git a/providers/fab/tests/unit/fab/auth_manager/security_manager/test_override.py b/providers/fab/tests/unit/fab/auth_manager/security_manager/test_override.py index 7b9e9696e5776..15f92196573b0 100644 --- a/providers/fab/tests/unit/fab/auth_manager/security_manager/test_override.py +++ b/providers/fab/tests/unit/fab/auth_manager/security_manager/test_override.py @@ -21,10 +21,7 @@ import pytest -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride +from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride class EmptySecurityManager(FabAirflowSecurityManagerOverride): diff --git a/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py b/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py index 85fb85dace903..3b025d6c68410 100644 --- a/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py +++ b/providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py @@ -42,18 +42,13 @@ DagDetails, ) -from tests_common.test_utils.compat import ignore_provider_compatibility_error -from tests_common.test_utils.dag import sync_dag_to_db - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.fab_auth_manager import FabAuthManager - from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride - from airflow.providers.common.compat.security.permissions import ( RESOURCE_ASSET, RESOURCE_ASSET_ALIAS, RESOURCE_BACKFILL, ) +from airflow.providers.fab.auth_manager.fab_auth_manager import FabAuthManager +from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride from airflow.providers.fab.www.security.permissions import ( ACTION_CAN_ACCESS_MENU, ACTION_CAN_CREATE, @@ -75,6 +70,7 @@ RESOURCE_WEBSITE, ) +from tests_common.test_utils.dag import sync_dag_to_db from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS if AIRFLOW_V_3_1_PLUS: diff --git a/providers/fab/tests/unit/fab/auth_manager/test_models.py b/providers/fab/tests/unit/fab/auth_manager/test_models.py index a092bd3e311be..96f0fca598e30 100644 --- a/providers/fab/tests/unit/fab/auth_manager/test_models.py +++ b/providers/fab/tests/unit/fab/auth_manager/test_models.py @@ -20,13 +20,10 @@ from sqlalchemy import Column, MetaData, String, Table -from tests_common.test_utils.compat import ignore_provider_compatibility_error - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.models import ( - add_index_on_ab_register_user_username_postgres, - add_index_on_ab_user_username_postgres, - ) +from airflow.providers.fab.auth_manager.models import ( + add_index_on_ab_register_user_username_postgres, + add_index_on_ab_user_username_postgres, +) _mock_conn = mock.MagicMock() _mock_conn.dialect = mock.MagicMock() diff --git a/providers/fab/tests/unit/fab/auth_manager/test_security.py b/providers/fab/tests/unit/fab/auth_manager/test_security.py index 75dec27d8b268..e2e33f5b7b352 100644 --- a/providers/fab/tests/unit/fab/auth_manager/test_security.py +++ b/providers/fab/tests/unit/fab/auth_manager/test_security.py @@ -30,28 +30,23 @@ from flask_appbuilder.views import BaseView, ModelView from sqlalchemy import Column, Date, Float, Integer, String, delete, func, select +from airflow.api_fastapi.app import get_auth_manager from airflow.exceptions import AirflowException from airflow.models import DagModel from airflow.models.dag import DAG from airflow.models.dagbundle import DagBundleModel -from airflow.providers.fab.www.utils import CustomSQLAInterface - -from tests_common.test_utils.compat import ignore_provider_compatibility_error -from tests_common.test_utils.config import conf_vars - -with ignore_provider_compatibility_error("2.9.0+", __file__): - from airflow.providers.fab.auth_manager.fab_auth_manager import FabAuthManager - from airflow.providers.fab.auth_manager.models import assoc_permission_role - from airflow.providers.fab.auth_manager.models.anonymous_user import AnonymousUser - -from airflow.api_fastapi.app import get_auth_manager +from airflow.providers.fab.auth_manager.fab_auth_manager import FabAuthManager +from airflow.providers.fab.auth_manager.models import assoc_permission_role +from airflow.providers.fab.auth_manager.models.anonymous_user import AnonymousUser +from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride from airflow.providers.fab.www import app as application from airflow.providers.fab.www.security import permissions from airflow.providers.fab.www.security.permissions import ACTION_CAN_READ +from airflow.providers.fab.www.utils import CustomSQLAInterface from tests_common.test_utils.asserts import assert_queries_count +from tests_common.test_utils.config import conf_vars from tests_common.test_utils.db import clear_db_dag_bundles, clear_db_dags, clear_db_runs -from tests_common.test_utils.mock_security_manager import MockSecurityManager from tests_common.test_utils.permissions import _resource_name from tests_common.test_utils.version_compat import AIRFLOW_V_3_1_PLUS from unit.fab.auth_manager.api_endpoints.api_connexion_utils import ( @@ -86,6 +81,14 @@ log = logging.getLogger(__name__) +class MockSecurityManager(FabAirflowSecurityManagerOverride): + """Mock Security Manager for testing purposes.""" + + VIEWER_VMS = { + "Airflow", + } + + class SomeModel(Model): id = Column(Integer, primary_key=True) field_string = Column(String(50), unique=True, nullable=False)