You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/08/29 00:06:13 UTC

(superset) branch master updated: fix(dashboard): remove @has_access_api from filter state REST API (#43564)

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 058eaf78abe fix(dashboard): remove @has_access_api from filter state REST API (#43564)
058eaf78abe is described below

commit 058eaf78abe4b4a99d8499af06559596f645cd9f
Author: Francesco.Castaldi <in...@francescocastaldi.it>
AuthorDate: Sat Aug 29 02:06:06 2026 +0200

    fix(dashboard): remove @has_access_api from filter state REST API (#43564)
    
    Co-authored-by: FrancescoCastaldi <fr...@mapsgroup.it>
---
 superset/dashboards/filter_state/api.py            |   6 -
 .../dashboards/filter_state/api_tests.py           | 635 +++++++++++----------
 .../unit_tests/dashboards/filter_state_api_test.py |  66 +++
 3 files changed, 406 insertions(+), 301 deletions(-)

diff --git a/superset/dashboards/filter_state/api.py b/superset/dashboards/filter_state/api.py
index 5b6b2ac996a..25fb7ad2095 100644
--- a/superset/dashboards/filter_state/api.py
+++ b/superset/dashboards/filter_state/api.py
@@ -18,7 +18,6 @@ import logging
 
 from flask import Response
 from flask_appbuilder.api import expose, protect, safe
-from flask_appbuilder.security.decorators import has_access_api
 
 from superset.commands.dashboard.filter_state.create import CreateFilterStateCommand
 from superset.commands.dashboard.filter_state.delete import DeleteFilterStateCommand
@@ -26,7 +25,6 @@ from superset.commands.dashboard.filter_state.get import GetFilterStateCommand
 from superset.commands.dashboard.filter_state.update import UpdateFilterStateCommand
 from superset.extensions import event_logger
 from superset.temporary_cache.api import TemporaryCacheRestApi
-from superset.views.base import api
 
 logger = logging.getLogger(__name__)
 
@@ -48,8 +46,6 @@ class DashboardFilterStateRestApi(TemporaryCacheRestApi):
     def get_delete_command(self) -> type[DeleteFilterStateCommand]:
         return DeleteFilterStateCommand
 
-    @api
-    @has_access_api
     @expose("/<int:pk>/filter_state", methods=("POST",))
     @protect()
     @safe
@@ -173,8 +169,6 @@ class DashboardFilterStateRestApi(TemporaryCacheRestApi):
         """
         return super().post(pk)
 
-    @api
-    @has_access_api
     @expose("/<int:pk>/filter_state/<string:key>", methods=("PUT",))
     @protect()
     @safe
diff --git a/tests/integration_tests/dashboards/filter_state/api_tests.py b/tests/integration_tests/dashboards/filter_state/api_tests.py
index b050a326d5e..ef081efd4e1 100644
--- a/tests/integration_tests/dashboards/filter_state/api_tests.py
+++ b/tests/integration_tests/dashboards/filter_state/api_tests.py
@@ -1,295 +1,340 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-from unittest.mock import patch  # noqa: F401
-
-import pytest
-from flask.ctx import AppContext
-from flask_appbuilder.security.sqla.models import User
-from sqlalchemy.orm import Session  # noqa: F401
-
-from superset import db
-from superset.commands.dashboard.exceptions import (
-    DashboardAccessDeniedError,  # noqa: F401
-)
-from superset.commands.temporary_cache.entry import Entry
-from superset.extensions import cache_manager
-from superset.models.dashboard import Dashboard
-from superset.temporary_cache.utils import cache_key
-from superset.utils import json
-from tests.integration_tests.fixtures.world_bank_dashboard import (
-    load_world_bank_dashboard_with_slices,  # noqa: F401
-    load_world_bank_data,  # noqa: F401
-)
-from tests.integration_tests.test_app import app  # noqa: F401
-
-KEY = "test-key"
-INITIAL_VALUE = json.dumps({"test": "initial value"})
-UPDATED_VALUE = json.dumps({"test": "updated value"})
-
-
-@pytest.fixture
-def dashboard_id(app_context: AppContext, load_world_bank_dashboard_with_slices) -> int:  # noqa: F811
-    dashboard = db.session.query(Dashboard).filter_by(slug="world_health").one()
-    return dashboard.id
-
-
-@pytest.fixture
-def admin_id(app_context: AppContext) -> int:
-    admin = db.session.query(User).filter_by(username="admin").one_or_none()
-    return admin.id
-
-
-@pytest.fixture(autouse=True)
-def cache(dashboard_id, admin_id):
-    entry: Entry = {"owner": admin_id, "value": INITIAL_VALUE}
-    cache_manager.filter_state_cache.set(cache_key(dashboard_id, KEY), entry)
-
-
-def test_post(test_client, login_as_admin, dashboard_id: int):
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state",
-        json={
-            "value": INITIAL_VALUE,
-        },
-    )
-    assert resp.status_code == 201
-
-
-def test_post_bad_request_non_string(test_client, login_as_admin, dashboard_id: int):
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state",
-        json={
-            "value": 1234,
-        },
-    )
-    assert resp.status_code == 400
-
-
-def test_post_bad_request_non_json_string(
-    test_client, login_as_admin, dashboard_id: int
-):
-    payload = {
-        "value": "foo",
-    }
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
-    )
-    assert resp.status_code == 400
-
-
-def test_post_access_denied(test_client, login_as, dashboard_id: int):
-    login_as("gamma")
-    payload = {
-        "value": INITIAL_VALUE,
-    }
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
-    )
-    assert resp.status_code == 404
-
-
-def test_post_same_key_for_same_tab_id(test_client, login_as_admin, dashboard_id: int):
-    payload = {
-        "value": INITIAL_VALUE,
-    }
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=1", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    first_key = data.get("key")
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=1", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    second_key = data.get("key")
-    assert first_key == second_key
-
-
-def test_post_different_key_for_different_tab_id(
-    test_client, login_as_admin, dashboard_id: int
-):
-    payload = {
-        "value": INITIAL_VALUE,
-    }
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=1", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    first_key = data.get("key")
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=2", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    second_key = data.get("key")
-    assert first_key != second_key
-
-
-def test_post_different_key_for_no_tab_id(
-    test_client, login_as_admin, dashboard_id: int
-):
-    payload = {
-        "value": INITIAL_VALUE,
-    }
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    first_key = data.get("key")
-    resp = test_client.post(
-        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    second_key = data.get("key")
-    assert first_key != second_key
-
-
-def test_put(test_client, login_as_admin, dashboard_id: int):
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
-        json={
-            "value": UPDATED_VALUE,
-        },
-    )
-    assert resp.status_code == 200
-
-
-def test_put_same_key_for_same_tab_id(test_client, login_as_admin, dashboard_id: int):
-    payload = {
-        "value": INITIAL_VALUE,
-    }
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=1", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    first_key = data.get("key")
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=1", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    second_key = data.get("key")
-    assert first_key == second_key
-
-
-def test_put_different_key_for_different_tab_id(
-    test_client, login_as_admin, dashboard_id: int
-):
-    payload = {
-        "value": INITIAL_VALUE,
-    }
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=1", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    first_key = data.get("key")
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=2", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    second_key = data.get("key")
-    assert first_key != second_key
-
-
-def test_put_different_key_for_no_tab_id(
-    test_client, login_as_admin, dashboard_id: int
-):
-    payload = {
-        "value": INITIAL_VALUE,
-    }
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    first_key = data.get("key")
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}", json=payload
-    )
-    data = json.loads(resp.data.decode("utf-8"))
-    second_key = data.get("key")
-    assert first_key != second_key
-
-
-def test_put_bad_request_non_string(test_client, login_as_admin, dashboard_id: int):
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
-        json={
-            "value": 1234,
-        },
-    )
-    assert resp.status_code == 400
-
-
-def test_put_bad_request_non_json_string(
-    test_client, login_as_admin, dashboard_id: int
-):
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
-        json={
-            "value": "foo",
-        },
-    )
-    assert resp.status_code == 400
-
-
-def test_put_access_denied(test_client, login_as, dashboard_id: int):
-    login_as("gamma")
-    resp = test_client.put(
-        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
-        json={
-            "value": UPDATED_VALUE,
-        },
-    )
-    assert resp.status_code == 404
-
-
-def test_get_key_not_found(test_client, login_as_admin, dashboard_id: int):
-    resp = test_client.get(f"api/v1/dashboard/{dashboard_id}/filter_state/unknown-key/")
-    assert resp.status_code == 404
-
-
-def test_get_dashboard_not_found(test_client, login_as_admin):
-    resp = test_client.get(f"api/v1/dashboard/{-1}/filter_state/{KEY}")
-    assert resp.status_code == 404
-
-
-def test_get_dashboard_filter_state(test_client, login_as_admin, dashboard_id: int):
-    resp = test_client.get(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
-    assert resp.status_code == 200
-    data = json.loads(resp.data.decode("utf-8"))
-    assert INITIAL_VALUE == data.get("value")
-
-
-def test_get_access_denied(test_client, login_as, dashboard_id):
-    login_as("gamma")
-    resp = test_client.get(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
-    assert resp.status_code == 404
-
-
-def test_delete(test_client, login_as_admin, dashboard_id: int):
-    resp = test_client.delete(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
-    assert resp.status_code == 200
-
-
-def test_delete_access_denied(test_client, login_as, dashboard_id: int):
-    login_as("gamma")
-    resp = test_client.delete(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
-    assert resp.status_code == 404
-
-
-def test_delete_not_owner(test_client, login_as, dashboard_id: int):
-    login_as("gamma")
-    resp = test_client.delete(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
-    assert resp.status_code == 404
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from unittest.mock import patch  # noqa: F401
+
+import pytest
+from flask.ctx import AppContext
+from flask_appbuilder.security.sqla.models import User
+from sqlalchemy.orm import Session  # noqa: F401
+
+from superset import db
+from superset.commands.dashboard.exceptions import (
+    DashboardAccessDeniedError,  # noqa: F401
+)
+from superset.commands.temporary_cache.entry import Entry
+from superset.extensions import cache_manager
+from superset.models.dashboard import Dashboard
+from superset.temporary_cache.utils import cache_key
+from superset.utils import json
+from tests.integration_tests.fixtures.world_bank_dashboard import (
+    load_world_bank_dashboard_with_slices,  # noqa: F401
+    load_world_bank_data,  # noqa: F401
+)
+from tests.integration_tests.test_app import app  # noqa: F401
+
+KEY = "test-key"
+INITIAL_VALUE = json.dumps({"test": "initial value"})
+UPDATED_VALUE = json.dumps({"test": "updated value"})
+
+
+@pytest.fixture
+def dashboard_id(app_context: AppContext, load_world_bank_dashboard_with_slices) -> int:  # noqa: F811
+    dashboard = db.session.query(Dashboard).filter_by(slug="world_health").one()
+    return dashboard.id
+
+
+@pytest.fixture
+def admin_id(app_context: AppContext) -> int:
+    admin = db.session.query(User).filter_by(username="admin").one_or_none()
+    return admin.id
+
+
+@pytest.fixture(autouse=True)
+def cache(dashboard_id, admin_id):
+    entry: Entry = {"owner": admin_id, "value": INITIAL_VALUE}
+    cache_manager.filter_state_cache.set(cache_key(dashboard_id, KEY), entry)
+
+
+def test_post(test_client, login_as_admin, dashboard_id: int):
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state",
+        json={
+            "value": INITIAL_VALUE,
+        },
+    )
+    assert resp.status_code == 201
+
+
+def test_post_bad_request_non_string(test_client, login_as_admin, dashboard_id: int):
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state",
+        json={
+            "value": 1234,
+        },
+    )
+    assert resp.status_code == 400
+
+
+def test_post_bad_request_non_json_string(
+    test_client, login_as_admin, dashboard_id: int
+):
+    payload = {
+        "value": "foo",
+    }
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
+    )
+    assert resp.status_code == 400
+
+
+def test_post_access_denied(test_client, login_as, dashboard_id: int):
+    login_as("gamma")
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
+    )
+    assert resp.status_code == 404
+
+
+def test_post_same_key_for_same_tab_id(test_client, login_as_admin, dashboard_id: int):
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=1", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    first_key = data.get("key")
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=1", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    second_key = data.get("key")
+    assert first_key == second_key
+
+
+def test_post_different_key_for_different_tab_id(
+    test_client, login_as_admin, dashboard_id: int
+):
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=1", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    first_key = data.get("key")
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state?tab_id=2", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    second_key = data.get("key")
+    assert first_key != second_key
+
+
+def test_post_different_key_for_no_tab_id(
+    test_client, login_as_admin, dashboard_id: int
+):
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    first_key = data.get("key")
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    second_key = data.get("key")
+    assert first_key != second_key
+
+
+def test_put(test_client, login_as_admin, dashboard_id: int):
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
+        json={
+            "value": UPDATED_VALUE,
+        },
+    )
+    assert resp.status_code == 200
+
+
+def test_put_same_key_for_same_tab_id(test_client, login_as_admin, dashboard_id: int):
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=1", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    first_key = data.get("key")
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=1", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    second_key = data.get("key")
+    assert first_key == second_key
+
+
+def test_put_different_key_for_different_tab_id(
+    test_client, login_as_admin, dashboard_id: int
+):
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=1", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    first_key = data.get("key")
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}?tab_id=2", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    second_key = data.get("key")
+    assert first_key != second_key
+
+
+def test_put_different_key_for_no_tab_id(
+    test_client, login_as_admin, dashboard_id: int
+):
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    first_key = data.get("key")
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}", json=payload
+    )
+    data = json.loads(resp.data.decode("utf-8"))
+    second_key = data.get("key")
+    assert first_key != second_key
+
+
+def test_put_bad_request_non_string(test_client, login_as_admin, dashboard_id: int):
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
+        json={
+            "value": 1234,
+        },
+    )
+    assert resp.status_code == 400
+
+
+def test_put_bad_request_non_json_string(
+    test_client, login_as_admin, dashboard_id: int
+):
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
+        json={
+            "value": "foo",
+        },
+    )
+    assert resp.status_code == 400
+
+
+def test_put_access_denied(test_client, login_as, dashboard_id: int):
+    login_as("gamma")
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}",
+        json={
+            "value": UPDATED_VALUE,
+        },
+    )
+    assert resp.status_code == 404
+
+
+@patch("superset.commands.dashboard.filter_state.create.check_access")
+def test_post_authenticated_user_with_access(
+    mock_check_access, test_client, login_as, dashboard_id: int
+):
+    login_as("alpha")
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
+    )
+    assert resp.status_code == 201
+    mock_check_access.assert_called_once_with(dashboard_id)
+
+
+@patch("superset.commands.dashboard.filter_state.create.check_access")
+@patch("superset.commands.dashboard.filter_state.update.check_access")
+def test_put_authenticated_user_with_access(
+    mock_update_check_access,
+    mock_create_check_access,
+    test_client,
+    login_as,
+    dashboard_id: int,
+):
+    login_as("alpha")
+    payload = {
+        "value": INITIAL_VALUE,
+    }
+    post_resp = test_client.post(
+        f"api/v1/dashboard/{dashboard_id}/filter_state", json=payload
+    )
+    assert post_resp.status_code == 201
+    key = json.loads(post_resp.data.decode("utf-8"))["key"]
+
+    put_payload = {
+        "value": UPDATED_VALUE,
+    }
+    resp = test_client.put(
+        f"api/v1/dashboard/{dashboard_id}/filter_state/{key}", json=put_payload
+    )
+    assert resp.status_code == 200
+    mock_create_check_access.assert_called_once_with(dashboard_id)
+    mock_update_check_access.assert_called_once_with(dashboard_id)
+
+
+def test_get_key_not_found(test_client, login_as_admin, dashboard_id: int):
+    resp = test_client.get(f"api/v1/dashboard/{dashboard_id}/filter_state/unknown-key/")
+    assert resp.status_code == 404
+
+
+def test_get_dashboard_not_found(test_client, login_as_admin):
+    resp = test_client.get(f"api/v1/dashboard/{-1}/filter_state/{KEY}")
+    assert resp.status_code == 404
+
+
+def test_get_dashboard_filter_state(test_client, login_as_admin, dashboard_id: int):
+    resp = test_client.get(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
+    assert resp.status_code == 200
+    data = json.loads(resp.data.decode("utf-8"))
+    assert INITIAL_VALUE == data.get("value")
+
+
+def test_get_access_denied(test_client, login_as, dashboard_id):
+    login_as("gamma")
+    resp = test_client.get(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
+    assert resp.status_code == 404
+
+
+def test_delete(test_client, login_as_admin, dashboard_id: int):
+    resp = test_client.delete(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
+    assert resp.status_code == 200
+
+
+def test_delete_access_denied(test_client, login_as, dashboard_id: int):
+    login_as("gamma")
+    resp = test_client.delete(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
+    assert resp.status_code == 404
+
+
+def test_delete_not_owner(test_client, login_as, dashboard_id: int):
+    login_as("gamma")
+    resp = test_client.delete(f"api/v1/dashboard/{dashboard_id}/filter_state/{KEY}")
+    assert resp.status_code == 404
diff --git a/tests/unit_tests/dashboards/filter_state_api_test.py b/tests/unit_tests/dashboards/filter_state_api_test.py
new file mode 100644
index 00000000000..c009bf36240
--- /dev/null
+++ b/tests/unit_tests/dashboards/filter_state_api_test.py
@@ -0,0 +1,66 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Unit tests for DashboardFilterStateRestApi."""
+
+import inspect
+
+from superset.commands.dashboard.filter_state.create import CreateFilterStateCommand
+from superset.commands.dashboard.filter_state.delete import DeleteFilterStateCommand
+from superset.commands.dashboard.filter_state.get import GetFilterStateCommand
+from superset.commands.dashboard.filter_state.update import UpdateFilterStateCommand
+from superset.dashboards.filter_state.api import DashboardFilterStateRestApi
+from superset.temporary_cache.api import TemporaryCacheRestApi
+
+
+def test_dashboard_filter_state_rest_api_inheritance():
+    """Ensure DashboardFilterStateRestApi correctly subclasses TemporaryCacheRestApi."""
+    assert issubclass(DashboardFilterStateRestApi, TemporaryCacheRestApi)
+    assert (
+        DashboardFilterStateRestApi.class_permission_name
+        == "DashboardFilterStateRestApi"
+    )
+    assert DashboardFilterStateRestApi.resource_name == "dashboard"
+    assert DashboardFilterStateRestApi.openapi_spec_tag == "Dashboard Filter State"
+
+
+def test_dashboard_filter_state_command_factories():
+    """Ensure factory methods return the expected command classes."""
+    api = DashboardFilterStateRestApi()
+    assert api.get_create_command() is CreateFilterStateCommand
+    assert api.get_update_command() is UpdateFilterStateCommand
+    assert api.get_get_command() is GetFilterStateCommand
+    assert api.get_delete_command() is DeleteFilterStateCommand
+
+
+def test_post_put_methods_have_no_has_access_api_or_api_decorator():
+    """
+    Ensure post and put methods are not decorated with @has_access_api or @api.
+
+    Because DashboardFilterStateRestApi is a temporary cache API, permission
+    verification is handled dynamically at the command level via
+    CheckAccessDataCommand. @has_access_api causes 401 Unauthorized for regular
+    users due to missing FAB permissions. The @api wrapper would catch and convert
+    uncaught auth errors into 500s.
+    """
+    source_post = inspect.getsource(DashboardFilterStateRestApi.post)
+    source_put = inspect.getsource(DashboardFilterStateRestApi.put)
+
+    assert "has_access_api" not in source_post
+    assert "has_access_api" not in source_put
+
+    assert not any(line.strip().startswith("@api") for line in source_post.splitlines())
+    assert not any(line.strip().startswith("@api") for line in source_put.splitlines())