Skip to content

Commit

Permalink
More acceptance tests relevant to table permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
crisptrutski committed Oct 1, 2024
1 parent 13d0ab3 commit eec03c8
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/macaw/acceptance_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
(def broken-queries
"The DANGER ZONE
This map gives a pattern in the exception message we expect to receive when trying to analyze the given fixture."
{:broken/between #"Encountered unexpected token: \"BETWEEN\""
:broken/filter-where #"Encountered unexpected token: \"\(\""})
{:broken/between #"Encountered unexpected token: \"BETWEEN\""
:broken/filter-where #"Encountered unexpected token: \"\(\""
:sqlserver/execute #"Not supported yet"
:sqlserver/executesql #"Not supported yet"
:oracle/open-for #"Encountered unexpected token: \"OPEN\""})

(defn- fixture-analysis [fixture]
(some-> fixture (ct/fixture->filename "acceptance" ".analysis.edn") io/resource slurp read-string))
Expand Down Expand Up @@ -68,7 +71,8 @@
(testing (str prefix " analysis cannot be parsed")
(is (thrown-with-msg? Exception expected-msg (ct/components sql base-opts)))
(doseq [m test-modes]
(is (thrown-with-msg? Exception expected-msg (ct/tables sql (opts-mode m))))))
(when-not (not-implemented? m)
(is (thrown-with-msg? Exception expected-msg (ct/tables sql (opts-mode m)))))))
(do
(let [m :ast-walker-1
opts (opts-mode m)]
Expand Down
12 changes: 12 additions & 0 deletions test/resources/acceptance/bigquery__table_wildcard.analysis.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{:source-columns []
:tables ::not-sure-what-we-should-do-if-we-continue-supporting-this

:overrides
{:basic-select
;; do not allow wilcard selects
{:tables :macaw.error/illegal-expression}

;; Just plain old whacky
:source-columns [{:table "`project_id.dataset_id.table_*`", :column "_TABLE_SUFFIX"}]
;; Kinda makes sense, but very raw, and Metabase won't handle it.
:tables [{:table "`project_id.dataset_id.table_*`"}]}}
7 changes: 7 additions & 0 deletions test/resources/acceptance/bigquery__table_wildcard.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT
*
FROM
`project_id.dataset_id.table_*`
WHERE
_TABLE_SUFFIX BETWEEN '20230101' AND '20230131'
LIMIT 1000;
5 changes: 5 additions & 0 deletions test/resources/acceptance/oracle__open_for.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
OPEN ccur FOR
'select c.category
from ' || TABLE_NAME || ' c
where c.deptid=' || PI_N_Dept ||
' and c.category not in ('|| sExcludeCategories ||')';
2 changes: 2 additions & 0 deletions test/resources/acceptance/simple__select_star.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{:source-columns []
:tables [{:table "t"}]}
1 change: 1 addition & 0 deletions test/resources/acceptance/simple__select_star.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT * FROM t;
1 change: 1 addition & 0 deletions test/resources/acceptance/sqlserver__execute.analysis.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:tables ::should-not-succeed}
1 change: 1 addition & 0 deletions test/resources/acceptance/sqlserver__execute.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXECUTE stmt;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:tables ::should-not-succeed}
1 change: 1 addition & 0 deletions test/resources/acceptance/sqlserver__executesql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXEC sp_executesql @SQL

0 comments on commit eec03c8

Please sign in to comment.