Skip to content

Commit

Permalink
Use next_url instead of next (apache#37225)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincbeck authored Feb 7, 2024
1 parent e75522b commit daa2bce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion airflow/providers/fab/auth_manager/fab_auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion tests/providers/fab/auth_manager/test_fab_auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 4 additions & 1 deletion tests/www/views/test_anonymous_as_admin_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/www/views/test_views_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit daa2bce

Please sign in to comment.