sjyangkevin commented on code in PR #77619:
URL: https://github.com/apache/airflow/pull/77619#discussion_r4721601922
##########
providers/fab/tests/unit/fab/auth_manager/views/test_auth_login.py:
##########
@@ -140,6 +143,42 @@ def test_anonymous_login_uses_parent(self, flask_app,
view_class, parent_class,
parent_login.assert_called_once_with(*expected_args)
+class TestEndSessionOnLogout:
+ @pytest.mark.parametrize(
+ "view_class",
+ [CustomAuthDBView, CustomAuthLDAPView, CustomAuthOAuthView,
CustomAuthRemoteUserView],
+ )
+ @pytest.mark.parametrize(
+ ("logout_redirect_url", "expected_location"),
+ [
+ (None, "/login/"),
+ ("https://idp.example.com/logout",
"https://idp.example.com/logout"),
+ ],
+ )
+ @mock.patch.object(AuthView, "logout", autospec=True,
return_value=Response(status=302))
+ def test_logout_clears_session_and_redirects(
+ self, parent_logout, flask_app, view_class, logout_redirect_url,
expected_location
+ ):
+ flask_app.secret_key = "test-secret"
+ if logout_redirect_url:
+ flask_app.config["LOGOUT_REDIRECT_URL"] = logout_redirect_url
+ view = view_class()
+ view.appbuilder = mock.Mock(spec=AppBuilder,
get_url_for_login="/login/")
+ with flask_app.test_request_context("/logout/"):
+ session["csrf_token"] = "token"
+ response = view.logout()
+
+ assert not session
+
+ parent_logout.assert_called_once_with(view)
+ assert response.status_code == 302
+ assert response.location == expected_location
+
+
+def test_security_manager_uses_custom_remote_user_view():
Review Comment:
thanks, removed. I also simplified `test_logout_ends_the_flask_session` in
`routes/test_login.py`. It followed the logout redirects with a `while` loop,
but the path seems only two steps (`/auth/logout` → `/auth/logout/` → login
page), so the loop only ever ran once. It now follows that one redirect
explicitly. The test checks the same things and still fails without the fix.
This was the block for that `while` loop
https://github.com/apache/airflow/pull/77619/changes#diff-e9fa02212dec96bb71cce4697a4429f090490fff7e70467ed86c91b4be30dd4fR109-R110
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]