Skip to content

Commit 5f4fa9d

Browse files
committed
Run fab provider tests in v2-11-test
Since we are releasing fab provider from v2-11-test we should also run fab provider tests there. This chang consists of: * migrating to FAB 4.5.3 (includes scrypt algorithm fix) * monkeypatching flask-session so that it works well with new flask-sqlalchey * caching initial$aization of Session class from flask-session and AirflowDatabaseSessionInterface so that DB connection is not created multiple times during tests * fixing imports from tests
1 parent 1d9cf9e commit 5f4fa9d

File tree

63 files changed

+494
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+494
-592
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -466,26 +466,26 @@ jobs:
466466
debug-resources: ${{ needs.build-info.outputs.debug-resources }}
467467
use-uv: ${{ needs.build-info.outputs.use-uv }}
468468

469-
tests-integration-system:
470-
name: Integration and System Tests
471-
needs: [build-info, build-ci-images]
472-
uses: ./.github/workflows/integration-system-tests.yml
473-
permissions:
474-
contents: read
475-
packages: read
476-
with:
477-
runs-on-as-json-public: ${{ needs.build-info.outputs.runs-on-as-json-public }}
478-
testable-core-integrations: ${{ needs.build-info.outputs.testable-core-integrations }}
479-
testable-providers-integrations: ${{ needs.build-info.outputs.testable-providers-integrations }}
480-
run-system-tests: ${{ needs.build-info.outputs.run-tests }}
481-
default-python-version: ${{ needs.build-info.outputs.default-python-version }}
482-
default-postgres-version: ${{ needs.build-info.outputs.default-postgres-version }}
483-
default-mysql-version: ${{ needs.build-info.outputs.default-mysql-version }}
484-
skip-providers-tests: ${{ needs.build-info.outputs.skip-providers-tests }}
485-
run-coverage: ${{ needs.build-info.outputs.run-coverage }}
486-
debug-resources: ${{ needs.build-info.outputs.debug-resources }}
487-
use-uv: ${{ needs.build-info.outputs.use-uv }}
488-
if: needs.build-info.outputs.run-tests == 'true'
469+
# tests-integration-system:
470+
# name: Integration and System Tests
471+
# needs: [build-info, build-ci-images]
472+
# uses: ./.github/workflows/integration-system-tests.yml
473+
# permissions:
474+
# contents: read
475+
# packages: read
476+
# with:
477+
# runs-on-as-json-public: ${{ needs.build-info.outputs.runs-on-as-json-public }}
478+
# testable-core-integrations: ${{ needs.build-info.outputs.testable-core-integrations }}
479+
# testable-providers-integrations: ${{ needs.build-info.outputs.testable-providers-integrations }}
480+
# run-system-tests: ${{ needs.build-info.outputs.run-tests }}
481+
# default-python-version: ${{ needs.build-info.outputs.default-python-version }}
482+
# default-postgres-version: ${{ needs.build-info.outputs.default-postgres-version }}
483+
# default-mysql-version: ${{ needs.build-info.outputs.default-mysql-version }}
484+
# skip-providers-tests: ${{ needs.build-info.outputs.skip-providers-tests }}
485+
# run-coverage: ${{ needs.build-info.outputs.run-coverage }}
486+
# debug-resources: ${{ needs.build-info.outputs.debug-resources }}
487+
# use-uv: ${{ needs.build-info.outputs.use-uv }}
488+
# if: needs.build-info.outputs.run-tests == 'true'
489489

490490
tests-with-lowest-direct-resolution:
491491
name: "Lowest direct dependency providers tests"
@@ -593,7 +593,6 @@ jobs:
593593
- tests-mysql
594594
- tests-postgres
595595
- tests-non-db
596-
- tests-integration-system
597596
- build-prod-images
598597
uses: ./.github/workflows/finalize-tests.yml
599598
with:

.github/workflows/test-provider-packages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ jobs:
9999
- name: "Prepare provider documentation"
100100
run: >
101101
breeze release-management prepare-provider-documentation --include-not-ready-providers
102-
--non-interactive
102+
--non-interactive fab
103103
if: matrix.package-format == 'wheel'
104104
- name: "Prepare provider packages: ${{ matrix.package-format }}"
105105
run: >
106106
breeze release-management prepare-provider-packages --include-not-ready-providers
107-
--version-suffix-for-pypi dev0 --package-format ${{ matrix.package-format }}
107+
--version-suffix-for-pypi dev0 --package-format ${{ matrix.package-format }} fab
108108
- name: "Prepare airflow package: ${{ matrix.package-format }}"
109109
run: >
110110
breeze release-management prepare-airflow-package --version-suffix-for-pypi dev0

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ repos:
11111111
stages: ['manual']
11121112
name: Run mypy for providers (manual)
11131113
language: python
1114-
entry: ./scripts/ci/pre_commit/mypy_folder.py providers/src/airflow/providers
1114+
entry: ./scripts/ci/pre_commit/mypy_folder.py airflow/providers/fab
11151115
pass_filenames: false
11161116
files: ^.*\.py$
11171117
require_serial: true

airflow/api_connexion/security.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545

4646
def check_authentication() -> None:
4747
"""Check that the request has valid authorization information."""
48-
for auth in get_airflow_app().api_auth:
48+
airflow_app = get_airflow_app()
49+
for auth in airflow_app.api_auth:
4950
response = auth.requires_authentication(Response)()
5051
if response.status_code == 200:
5152
return
5253

5354
# Even if the current_user is anonymous, the AUTH_ROLE_PUBLIC might still have permission.
54-
appbuilder = get_airflow_app().appbuilder
55+
appbuilder = airflow_app.appbuilder
5556
if appbuilder.get_app.config.get("AUTH_ROLE_PUBLIC", None):
5657
return
5758

airflow/providers/fab/README.rst

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
2+
.. Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
.. http://www.apache.org/licenses/LICENSE-2.0
11+
12+
.. Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
19+
.. NOTE! THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE OVERWRITTEN!
20+
21+
.. IF YOU WANT TO MODIFY TEMPLATE FOR THIS FILE, YOU SHOULD MODIFY THE TEMPLATE
22+
`PROVIDER_README_TEMPLATE.rst.jinja2` IN the `dev/breeze/src/airflow_breeze/templates` DIRECTORY
23+
24+
25+
Package ``apache-airflow-providers-fab``
26+
27+
Release: ``1.5.4``
28+
29+
30+
`Flask App Builder <https://flask-appbuilder.readthedocs.io/>`__
31+
32+
33+
Provider package
34+
----------------
35+
36+
This is a provider package for ``fab`` provider. All classes for this provider package
37+
are in ``airflow.providers.fab`` python package.
38+
39+
You can find package information and changelog for the provider
40+
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-fab/1.5.4/>`_.
41+
42+
Installation
43+
------------
44+
45+
You can install this package on top of an existing Airflow 2 installation (see ``Requirements`` below
46+
for the minimum Airflow version supported) via
47+
``pip install apache-airflow-providers-fab``
48+
49+
The package supports the following python versions: 3.10,3.11,3.12
50+
51+
Requirements
52+
------------
53+
54+
========================================== ==================
55+
PIP package Version required
56+
========================================== ==================
57+
``apache-airflow`` ``>=2.9.0``
58+
``apache-airflow-providers-common-compat`` ``>=1.2.1``
59+
``flask-login`` ``>=0.6.3``
60+
``flask-session`` ``>=0.8.0``
61+
``flask`` ``>=2.2,<3``
62+
``flask-appbuilder`` ``==4.5.4``
63+
``google-re2`` ``>=1.0``
64+
``jmespath`` ``>=0.7.0``
65+
========================================== ==================
66+
67+
Cross provider package dependencies
68+
-----------------------------------
69+
70+
Those are dependencies that might be needed in order to use all the features of the package.
71+
You need to install the specified provider packages in order to use them.
72+
73+
You can install such cross-provider dependencies when installing from PyPI. For example:
74+
75+
.. code-block:: bash
76+
77+
pip install apache-airflow-providers-fab[common.compat]
78+
79+
80+
================================================================================================================== =================
81+
Dependent package Extra
82+
================================================================================================================== =================
83+
`apache-airflow-providers-common-compat <https://airflow.apache.org/docs/apache-airflow-providers-common-compat>`_ ``common.compat``
84+
================================================================================================================== =================
85+
86+
The changelog for the provider package can be found in the
87+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-fab/1.5.4/changelog.html>`_.

airflow/providers/fab/auth_manager/cli_commands/db_command.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
from __future__ import annotations
1818

1919
from airflow import settings
20-
from airflow.cli.commands.db_command import run_db_downgrade_command, run_db_migrate_command
20+
from airflow.cli.commands.db_command import ( # type:ignore [attr-defined]
21+
run_db_downgrade_command,
22+
run_db_migrate_command,
23+
)
2124
from airflow.providers.fab.auth_manager.models.db import _REVISION_HEADS_MAP, FABDBManager
2225
from airflow.utils import cli as cli_utils
2326
from airflow.utils.providers_configuration_loader import providers_configuration_loaded

airflow/providers/fab/auth_manager/cli_commands/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _return_appbuilder(app: Flask) -> AirflowAppBuilder:
4242
"""Return an appbuilder instance for the given app."""
4343
init_appbuilder(app)
4444
init_plugins(app)
45-
init_airflow_session_interface(app)
45+
init_airflow_session_interface(app, None)
4646
return app.appbuilder # type: ignore[attr-defined]
4747

4848

airflow/providers/fab/auth_manager/fab_auth_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
)
9696
from airflow.providers.common.compat.assets import AssetDetails
9797
from airflow.providers.fab.auth_manager.security_manager.override import FabAirflowSecurityManagerOverride
98-
from airflow.security.permissions import RESOURCE_ASSET
98+
from airflow.security.permissions import RESOURCE_ASSET # type: ignore[attr-defined]
9999
else:
100100
from airflow.providers.common.compat.security.permissions import RESOURCE_ASSET
101101

@@ -403,9 +403,7 @@ def get_url_logout(self):
403403

404404
def get_url_user_profile(self) -> str | None:
405405
"""Return the url to a page displaying info about the current user."""
406-
if not self.security_manager.user_view or self.appbuilder.get_app.config.get(
407-
"AUTH_ROLE_PUBLIC", None
408-
):
406+
if not self.security_manager.user_view:
409407
return None
410408
return url_for(f"{self.security_manager.user_view.endpoint}.userinfo")
411409

airflow/providers/fab/auth_manager/security_manager/override.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
from flask_login import LoginManager
7070
from itsdangerous import want_bytes
7171
from markupsafe import Markup
72-
from packaging.version import Version
7372
from sqlalchemy import and_, func, inspect, literal, or_, select
7473
from sqlalchemy.exc import MultipleResultsFound
7574
from sqlalchemy.orm import Session, joinedload
@@ -850,7 +849,8 @@ def _init_config(self):
850849
app.config.setdefault("AUTH_ROLES_SYNC_AT_LOGIN", False)
851850
app.config.setdefault("AUTH_API_LOGIN_ALLOW_MULTIPLE_PROVIDERS", False)
852851

853-
# Werkzeug prior to 3.0.0 does not support scrypt
852+
from packaging.version import Version
853+
854854
parsed_werkzeug_version = Version(importlib.metadata.version("werkzeug"))
855855
if parsed_werkzeug_version < Version("3.0.0"):
856856
app.config.setdefault(
@@ -861,9 +861,10 @@ def _init_config(self):
861861
else:
862862
app.config.setdefault(
863863
"AUTH_DB_FAKE_PASSWORD_HASH_CHECK",
864-
"scrypt:32768:8:1$wiDa0ruWlIPhp9LM$6e409d093e62ad54df2af895d0e125b05ff6cf6414"
865-
"8350189ffc4bcc71286edf1b8ad94a442c00f890224bf2b32153d0750c89ee9"
866-
"401e62f9dcee5399065e4e5",
864+
"scrypt:32768:8:1$wiDa0ruWlIPhp9LM$6e40"
865+
"9d093e62ad54df2af895d0e125b05ff6cf6414"
866+
"8350189ffc4bcc71286edf1b8ad94a442c00f8"
867+
"90224bf2b32153d0750c89ee9401e62f9dcee5399065e4e5",
867868
)
868869

869870
# LDAP Config

airflow/providers/fab/provider.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ dependencies:
6262
# Every time we update FAB version here, please make sure that you review the classes and models in
6363
# `airflow/providers/fab/auth_manager/security_manager/override.py` with their upstream counterparts.
6464
# In particular, make sure any breaking changes, for example any new methods, are accounted for.
65-
- flask-appbuilder==4.5.3
65+
- flask-appbuilder==4.5.4
6666
- google-re2>=1.0
6767
- jmespath>=0.7.0
6868

0 commit comments

Comments
 (0)