From daa2bceba181193d675dae575a55bc3f39aba192 Mon Sep 17 00:00:00 2001 From: Vincent <97131062+vincbeck@users.noreply.github.com> Date: Wed, 7 Feb 2024 11:47:30 -0500 Subject: [PATCH] Use `next_url` instead of `next` (#37225) --- airflow/providers/fab/auth_manager/fab_auth_manager.py | 2 +- tests/providers/fab/auth_manager/test_fab_auth_manager.py | 2 +- tests/www/views/test_anonymous_as_admin_role.py | 5 ++++- tests/www/views/test_views_tasks.py | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/airflow/providers/fab/auth_manager/fab_auth_manager.py b/airflow/providers/fab/auth_manager/fab_auth_manager.py index 76d910eead3d7..dfa53ef78b5b0 100644 --- a/airflow/providers/fab/auth_manager/fab_auth_manager.py +++ b/airflow/providers/fab/auth_manager/fab_auth_manager.py @@ -351,7 +351,7 @@ def get_url_login(self, **kwargs) -> str: if not self.security_manager.auth_view: raise AirflowException("`auth_view` not defined in the security manager.") if "next_url" in kwargs and kwargs["next_url"]: - return url_for(f"{self.security_manager.auth_view.endpoint}.login", next=kwargs["next_url"]) + return url_for(f"{self.security_manager.auth_view.endpoint}.login", next_url=kwargs["next_url"]) else: return url_for(f"{self.security_manager.auth_view.endpoint}.login") diff --git a/tests/providers/fab/auth_manager/test_fab_auth_manager.py b/tests/providers/fab/auth_manager/test_fab_auth_manager.py index 72f5a76355f2c..41f76b69f8171 100644 --- a/tests/providers/fab/auth_manager/test_fab_auth_manager.py +++ b/tests/providers/fab/auth_manager/test_fab_auth_manager.py @@ -400,7 +400,7 @@ def test_get_url_login_with_next(self, mock_url_for, auth_manager_with_appbuilde auth_manager_with_appbuilder.security_manager.auth_view = Mock() auth_manager_with_appbuilder.security_manager.auth_view.endpoint = "test_endpoint" auth_manager_with_appbuilder.get_url_login(next_url="next_url") - mock_url_for.assert_called_once_with("test_endpoint.login", next="next_url") + mock_url_for.assert_called_once_with("test_endpoint.login", next_url="next_url") @pytest.mark.db_test def test_get_url_logout_when_auth_view_not_defined(self, auth_manager_with_appbuilder): diff --git a/tests/www/views/test_anonymous_as_admin_role.py b/tests/www/views/test_anonymous_as_admin_role.py index a78485ea97f53..895b885175948 100644 --- a/tests/www/views/test_anonymous_as_admin_role.py +++ b/tests/www/views/test_anonymous_as_admin_role.py @@ -56,7 +56,10 @@ def test_delete_pool_anonymous_user_no_role(anonymous_client, pool_factory): pool = pool_factory() resp = anonymous_client.post(f"pool/delete/{pool.id}") assert 302 == resp.status_code - assert f"/login/?next={quote_plus(f'http://localhost/pool/delete/{pool.id}')}" == resp.headers["Location"] + assert ( + f"/login/?next_url={quote_plus(f'http://localhost/pool/delete/{pool.id}')}" + == resp.headers["Location"] + ) def test_delete_pool_anonymous_user_as_admin(anonymous_client_as_admin, pool_factory): diff --git a/tests/www/views/test_views_tasks.py b/tests/www/views/test_views_tasks.py index ae8ecfb78f2dc..1e64cfeeeb628 100644 --- a/tests/www/views/test_views_tasks.py +++ b/tests/www/views/test_views_tasks.py @@ -713,13 +713,13 @@ def one_dag_perm_user_client(app): def test_delete_just_dag_per_dag_permissions(new_dag_to_delete, per_dag_perm_user_client): resp = per_dag_perm_user_client.post( - f"delete?dag_id={new_dag_to_delete.dag_id}&next=/home", follow_redirects=True + f"delete?dag_id={new_dag_to_delete.dag_id}&next_url=/home", follow_redirects=True ) check_content_in_response(f"Deleting DAG with id {new_dag_to_delete.dag_id}.", resp) def test_delete_just_dag_resource_permissions(new_dag_to_delete, user_client): - resp = user_client.post(f"delete?dag_id={new_dag_to_delete.dag_id}&next=/home", follow_redirects=True) + resp = user_client.post(f"delete?dag_id={new_dag_to_delete.dag_id}&next_url=/home", follow_redirects=True) check_content_in_response(f"Deleting DAG with id {new_dag_to_delete.dag_id}.", resp)