From 1e2e43a96e2b885df161ac7f7f0483b00a4a16c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 7 Sep 2017 15:38:54 +0300 Subject: [PATCH] MXS-1389: Add test for uses_function The test uses a uses_function type rule to restrict access to the name and address columns. --- maxscale-system-test/fw/deny13 | 10 ++++++++++ maxscale-system-test/fw/pass13 | 5 +++++ maxscale-system-test/fw/rules13 | 2 ++ maxscale-system-test/fwf.cpp | 2 +- maxscale-system-test/fwf_reload.cpp | 2 +- 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 maxscale-system-test/fw/deny13 create mode 100644 maxscale-system-test/fw/pass13 create mode 100644 maxscale-system-test/fw/rules13 diff --git a/maxscale-system-test/fw/deny13 b/maxscale-system-test/fw/deny13 new file mode 100644 index 000000000..6c4a2c343 --- /dev/null +++ b/maxscale-system-test/fw/deny13 @@ -0,0 +1,10 @@ +SELECT SUM(name), address FROM t1; +SELECT name, SUM(address) FROM t1; +SELECT address, SUM(name) FROM t1; +SELECT SUM(address), name FROM t1; +SELECT AVG(name), address FROM t1; +SELECT name, AVG(address) FROM t1; +SELECT address, AVG(name) FROM t1; +SELECT AVG(address), name FROM t1; +SELECT AVG(name), SUM(address) FROM t1; +SELECT SUM(name), AVG(address) FROM t1; diff --git a/maxscale-system-test/fw/pass13 b/maxscale-system-test/fw/pass13 new file mode 100644 index 000000000..b2cad4521 --- /dev/null +++ b/maxscale-system-test/fw/pass13 @@ -0,0 +1,5 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 (name int, address int, email int); +INSERT INTO t1 VALUES (1, 1, 1); +SELECT name, address, email FROM t1; +SELECT name, address, SUM(email) FROM t1; diff --git a/maxscale-system-test/fw/rules13 b/maxscale-system-test/fw/rules13 new file mode 100644 index 000000000..04c09a540 --- /dev/null +++ b/maxscale-system-test/fw/rules13 @@ -0,0 +1,2 @@ +rule no_func_usage deny uses_function name address +users %@% match any rules no_func_usage diff --git a/maxscale-system-test/fwf.cpp b/maxscale-system-test/fwf.cpp index 53356b31b..f518dc4bf 100644 --- a/maxscale-system-test/fwf.cpp +++ b/maxscale-system-test/fwf.cpp @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) FILE* file; sprintf(rules_dir, "%s/fw/", test_dir); - int N = 12; + int N = 13; int i; for (i = 1; i < N + 1; i++) diff --git a/maxscale-system-test/fwf_reload.cpp b/maxscale-system-test/fwf_reload.cpp index 38c3d3c8a..e57c07481 100644 --- a/maxscale-system-test/fwf_reload.cpp +++ b/maxscale-system-test/fwf_reload.cpp @@ -20,7 +20,7 @@ int main(int argc, char *argv[]) char rules_dir[4096]; sprintf(rules_dir, "%s/fw/", test_dir); - int N = 12; + int N = 13; int i; Test->stop_maxscale();