mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix(API): Updating assets via the API should preserve ownership configuration (#27364)
This commit is contained in:
@@ -1550,6 +1550,43 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
|
||||
db.session.delete(model)
|
||||
db.session.commit()
|
||||
|
||||
def test_update_dashboard_clear_owner_list(self):
|
||||
"""
|
||||
Dashboard API: Test update admin can clear up owners list
|
||||
"""
|
||||
admin = self.get_user("admin")
|
||||
dashboard_id = self.insert_dashboard("title1", "slug1", [admin.id]).id
|
||||
self.login(username="admin")
|
||||
uri = f"api/v1/dashboard/{dashboard_id}"
|
||||
dashboard_data = {"owners": []}
|
||||
rv = self.client.put(uri, json=dashboard_data)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
model = db.session.query(Dashboard).get(dashboard_id)
|
||||
self.assertEqual([], model.owners)
|
||||
db.session.delete(model)
|
||||
db.session.commit()
|
||||
|
||||
def test_update_dashboard_populate_owner(self):
|
||||
"""
|
||||
Dashboard API: Test update admin can update dashboard with
|
||||
no owners to a different owner
|
||||
"""
|
||||
self.login(username="admin")
|
||||
gamma = self.get_user("gamma")
|
||||
dashboard = self.insert_dashboard(
|
||||
"title1",
|
||||
"slug1",
|
||||
[],
|
||||
)
|
||||
uri = f"api/v1/dashboard/{dashboard.id}"
|
||||
dashboard_data = {"owners": [gamma.id]}
|
||||
rv = self.client.put(uri, json=dashboard_data)
|
||||
self.assertEqual(rv.status_code, 200)
|
||||
model = db.session.query(Dashboard).get(dashboard.id)
|
||||
self.assertEqual([gamma], model.owners)
|
||||
db.session.delete(model)
|
||||
db.session.commit()
|
||||
|
||||
def test_update_dashboard_slug_formatting(self):
|
||||
"""
|
||||
Dashboard API: Test update slug formatting
|
||||
|
||||
Reference in New Issue
Block a user