Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Test fixes in strip native_form changes (#84251)

Nathan Voxland421a100e3337
diff --git a/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.clj b/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.clj
index 011001e17f3..e58e0c49bb6 100644
--- a/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/sandbox/query_processor/middleware/sandboxing_test.clj
@@ -1401,8 +1401,13 @@
(:id model)))}]
(let [run-card #(mt/user-http-request % :post 202 (format "card/%d/query" (:id card)))
regular-result (run-card :crowberto)
- sandboxed-result (met/with-user-attributes! :rasta {"category" "Gizmo"}
- (run-card :rasta))]
+ [sandboxed-result
+ sandboxed-sql] (met/with-user-attributes! :rasta {"category" "Gizmo"}
+ ;; results don't include `:native_form` for a sandboxed user, so compile
+ ;; the Card's query separately to see which table it uses
+ [(run-card :rasta)
+ (mt/with-test-user :rasta
+ (:query (qp.compile/compile (:dataset_query card))))])]
(testing "Unsandboxed"
(testing "Sees full result set"
(is (= 200 (-> regular-result mt/rows ffirst))))
@@ -1415,8 +1420,7 @@
(is (= 51 (-> sandboxed-result mt/rows ffirst))
"Sandboxed user got whole results instead of filtered"))
(testing "Does not use the cache table"
- (is (not (str/includes? (-> sandboxed-result :data :native_form :query)
- (:table_name persisted-info)))
+ (is (not (str/includes? sandboxed-sql (:table_name persisted-info)))
"Erroneously used the persisted model cache")))))))))))))
(deftest model-metadata-overrides-preserved-for-sandboxed-users-test