bito-code-review[bot] commented on code in PR #43388:
URL: https://github.com/apache/superset/pull/43388#discussion_r3831867578
##########
tests/unit_tests/mcp_service/dashboard/tool/test_restore_dashboard.py:
##########
@@ -248,3 +252,71 @@ async def
test_restore_dashboard_rejects_boolean_identifier(
await client.call_tool(
"restore_dashboard", {"request": {"identifier": True}}
)
+
+
+@patch(_FIND)
[email protected]
+async def test_restore_dashboard_inaccessible_dashboard_reads_as_not_found(
+ mock_find: Mock, mcp_server: object
+) -> None:
+ """A dashboard outside the caller's RBAC scope must not leak its
+ existence or title: the unfiltered restore lookup finds it, the
+ base-filtered re-lookup does not, so the tool must answer exactly as if it
+ does not exist."""
+ from superset.errors import ErrorLevel, SupersetError, SupersetErrorType
+ from superset.exceptions import SupersetSecurityException
+
+ mock_find.side_effect = [
+ _mock_dashboard(dashboard_id=10, title="Secret Board"),
+ None, # base-filtered re-lookup
+ ]
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Duplicate dashboard forbidden test code</b></div>
<div id="fix">
Detected syntactic duplication in test_restore_dashboard.py at lines 272-288
and 303-319. Consider extracting the forbidden error handling test logic into a
shared helper function to reduce code duplication.
</div>
</div>
<div><details><summary><b>Review Rule</b></summary><div>Bito updated an
existing rule <strong><code>Extract duplicated test utilities into shared
modules</code></strong> for <strong>repo:</strong>
<code>apache/superset</code>, <strong>language:</strong> <code>Python</code>.
Bito will avoid suggestions that match this rule. You can manage review rules
<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>here</a>.</div></details></div>
<small><i>Code Review Run #147078</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]