rusackas commented on code in PR #41965:
URL: https://github.com/apache/superset/pull/41965#discussion_r3564822967


##########
tests/unit_tests/security/api_test.py:
##########
@@ -66,6 +66,50 @@ def test_csrf_exempt_blueprints_with_api_key(app: Any, 
app_context: None) -> Non
     assert "ApiKeyApi" in {blueprint.name for blueprint in 
csrf._exempt_blueprints}
 
 
+def test_security_api_trailing_slash_handled_consistently(client: Any) -> None:
+    """Regression for #29934: sibling ``/api/v1/security/*`` endpoints handle a
+    misspelled (wrong trailing-slash) URL inconsistently.
+
+    Three routes live under the same ``/api/v1/security/`` prefix but are
+    declared with different slash conventions:
+
+      * ``login``       -> ``@expose("/login")``        (no trailing slash, 
FAB)
+      * ``csrf_token``  -> ``@expose("/csrf_token/")``  (trailing slash, 
Superset)
+      * ``guest_token`` -> ``@expose("/guest_token/")`` (trailing slash, 
Superset)
+
+    Because of that mix, a client that gets the slash "wrong" is treated three
+    different ways by Werkzeug routing:
+
+      * ``POST /api/v1/security/login/``  -> 404 (no redirect for the extra 
slash)
+      * ``GET  /api/v1/security/csrf_token`` -> 308 redirect to the canonical 
URL
+      * ``POST /api/v1/security/guest_token`` -> 308 redirect to the canonical 
URL
+
+    A user hitting one misspelled security URL gets a clean redirect while
+    another gets a hard 404, which is exactly the inconsistency reported in the
+    issue. This asserts the *desired* contract — that a trailing-slash
+    misspelling is handled uniformly across the sibling endpoints — so it fails
+    (red) on master where the responses diverge, and would pass once the slash
+    conventions are unified. It does not prescribe which uniform behavior is
+    correct (all-redirect or all-404), only that they agree.
+    """
+    # (method, canonical route, misspelled route)

Review Comment:
   Good catch, fixed the comment to describe the two-tuples (method, URL).



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to