Skip to content
Snippets Groups Projects
Unverified Commit ba06b99e authored by Aleksandr Lesnenko's avatar Aleksandr Lesnenko Committed by GitHub
Browse files

fix iframe dashcards crash subscriptions (#48589)


* fix iframe dashcards crash subscriptions

* add a test to ensure iframes are filtered out of subscriptions

---------

Co-authored-by: default avatarAdam James <adam.vermeer2@gmail.com>
Co-authored-by: default avataradam-james <21064735+adam-james-v@users.noreply.github.com>
parent b8997a1e
No related branches found
No related tags found
No related merge requests found
......@@ -339,11 +339,12 @@
collection_id [:maybe ms/PositiveInt]
collection_position [:maybe ms/PositiveInt]
dashboard_id [:maybe ms/PositiveInt]}
;; Check permissions on cards that exist. Placeholders don't matter.
;; Check permissions on cards that exist. Placeholders and iframes don't matter.
(check-card-read-permissions
(remove (fn [{:keys [id display]}]
(and (nil? id)
(= "placeholder" display))) cards))
(or (= "placeholder" display)
(= "iframe" display)))) cards))
;; make sure any email addresses that are specified are allowed before sending the test Pulse.
(doseq [channel channels]
(pulse-channel/validate-email-domains channel))
......
......@@ -112,6 +112,10 @@
(let [parameters (merge-default-values (pulse-params/parameters pulse dashboard))]
(pu/execute-dashboard-subscription-card dashcard parameters))
;; iframes
(virtual-card-of-type? dashcard "iframe")
nil
;; actions
(virtual-card-of-type? dashcard "action")
nil
......
......@@ -769,6 +769,58 @@
{:text (format "### [https://metabase.com](https://metabase.com)")}]
(@#'metabase.pulse/execute-dashboard {:creator_id (mt/user->id :lucky)} dashboard)))))))))
(deftest iframe-cards-are-skipped-test
(testing "iframe cards should be filtered out"
(t2.with-temp/with-temp
[Dashboard {dashboard-id :id
:as dashboard} {:name "Dashboard"}
DashboardCard _ {:dashboard_id dashboard-id
:visualization_settings {:text "Markdown"}
:row 1}
DashboardCard _ {:dashboard_id dashboard-id
:visualization_settings {:virtual_card {:display "link"}
:link {:url "https://metabase.com"}}
:row 2}
DashboardCard _ {:dashboard_id dashboard-id
:visualization_settings {:virtual_card {:display "iframe"}}
:row 3}]
(is (=? [{:text "Markdown"}
{:text "### [https://metabase.com](https://metabase.com)"}]
(@#'metabase.pulse/execute-dashboard {:creator_id (mt/user->id :rasta)} dashboard)))))
(testing "Link cards are returned and info should be newly fetched"
(t2.with-temp/with-temp [Dashboard dashboard {:name "Test Dashboard"}]
(with-link-card-fixture-for-dashboard dashboard [{:keys [collection-owner-id
collection-id
database-id
table-id
card-id
model-id
dashboard-id]}]
(let [site-url (public-settings/site-url)]
(testing "should returns all link cards and name are newly fetched"
(doseq [[model id] [[Card card-id]
[Table table-id]
[Database database-id]
[Dashboard dashboard-id]
[Collection collection-id]
[Card model-id]]]
(t2/update! model id {:name (format "New %s name" (name model))}))
(is (=? [{:text (format "### [New Collection name](%s/collection/%d)\nLinked collection desc" site-url collection-id)}
{:text (format "### [New Database name](%s/browse/%d)\nLinked database desc" site-url database-id)}
{:text (format "### [Linked table dname](%s/question?db=%d&table=%d)\nLinked table desc" site-url database-id table-id)}
{:text (format "### [New Dashboard name](%s/dashboard/%d)\nLinked Dashboard desc" site-url dashboard-id)}
{:text (format "### [New Card name](%s/question/%d)\nLinked card desc" site-url card-id)}
{:text (format "### [New Card name](%s/question/%d)\nLinked model desc" site-url model-id)}
{:text (format "### [https://metabase.com](https://metabase.com)")}]
(@#'metabase.pulse/execute-dashboard {:creator_id collection-owner-id} dashboard))))
(testing "it should filter out models that current users does not have permission to read"
(is (=? [{:text (format "### [New Database name](%s/browse/%d)\nLinked database desc" site-url database-id)}
{:text (format "### [Linked table dname](%s/question?db=%d&table=%d)\nLinked table desc" site-url database-id table-id)}
{:text (format "### [https://metabase.com](https://metabase.com)")}]
(@#'metabase.pulse/execute-dashboard {:creator_id (mt/user->id :lucky)} dashboard)))))))))
(deftest execute-dashboard-with-tabs-test
(t2.with-temp/with-temp
[Dashboard {dashboard-id :id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment