]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
auto-convert SQL
authorAlan T. DeKok <aland@freeradius.org>
Mon, 9 Oct 2023 13:04:03 +0000 (09:04 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 9 Oct 2023 13:04:03 +0000 (09:04 -0400)
perl -p -i -e 's/"%{sql:(.*?)}"/%sql("$1")/' $(git grep -lE '%\{[a-z]+:' src/tests/modules/)

src/tests/modules/sql/acct_0_start.unlang
src/tests/modules/sql/acct_1_update.unlang
src/tests/modules/sql/acct_2_stop.unlang
src/tests/modules/sql/acct_start_conflict.unlang
src/tests/modules/sql/acct_update_no_start.unlang
src/tests/modules/sql/auth.unlang
src/tests/modules/sql/groups.unlang
src/tests/modules/sql/map.unlang
src/tests/modules/sql/reject.unlang
src/tests/modules/sql_sqlite/nested.unlang

index c3a225acc7921ac07dd9983d595f60e7b7f98c76..56525a7d4ddd0b6db4e15f01b6cac06f50ddd857 100644 (file)
@@ -2,7 +2,7 @@
 #  Clear out old data.  We don't care if the deletion deletes any rows.
 #
 
-"%{sql:${delete_from_radacct} '00000000'}"
+%sql("${delete_from_radacct} '00000000'")
 
 sql.accounting
 if (ok) {
@@ -12,10 +12,10 @@ else {
        test_fail
 }
 
-if ("%{sql:SELECT count(*) FROM radacct WHERE AcctSessionId = '00000000'}" != "1") {
+if (%sql("SELECT count(*) FROM radacct WHERE AcctSessionId = '00000000'") != "1") {
        test_fail
 }
 
-if ("%{sql:SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000000'}" != "0") {
+if (%sql("SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000000'") != "0") {
        test_fail
 }
index 12362e09bb8bfc592a5c7c0b86048735ca1eb33a..f892d6354e4a11477a7ce226b3cbb86f630b3ae5 100644 (file)
@@ -9,10 +9,10 @@ else {
        test_fail
 }
 
-if ("%{sql:SELECT count(*) FROM radacct WHERE AcctSessionId = '00000001'}" != "1") {
+if (%sql("SELECT count(*) FROM radacct WHERE AcctSessionId = '00000001'") != "1") {
        test_fail
 }
 
-if ("%{sql:SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000001'}" != "30") {
+if (%sql("SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000001'") != "30") {
        test_pass
 }
index cf51d50c9e73e0cb2a8cc95286338c2ce2ffba87..83b64e906d3a2afa7f44005a6f993a11ddf7c309 100644 (file)
@@ -9,14 +9,14 @@ else {
        test_fail
 }
 
-if("%{sql:SELECT count(*) FROM radacct WHERE AcctSessionId = '00000002'}" != "1") {
+if(%sql("SELECT count(*) FROM radacct WHERE AcctSessionId = '00000002'") != "1") {
        test_fail
 }
 
-if("%{sql:SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000002'}" != "120") {
+if(%sql("SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000002'") != "120") {
        test_fail
 }
 
-if("%{sql:SELECT AcctTerminateCause FROM radacct WHERE AcctSessionId = '00000002'}" != 'User-Request') {
+if(%sql("SELECT AcctTerminateCause FROM radacct WHERE AcctSessionId = '00000002'") != 'User-Request') {
        test_fail
 }
index 49ce9f91ccab49383b22b4a291a8ae0e9d3c98ff..88259cdc0c36b19b1fac60a7dff0a7b4feba26a7 100644 (file)
@@ -5,7 +5,7 @@
 #
 #  Clear out old data
 #
-"%{sql:${delete_from_radacct} '00000003'}"
+%sql("${delete_from_radacct} '00000003'")
 
 #
 #  Insert the Accounting-Request start
@@ -21,14 +21,14 @@ else {
 #
 #  Check the database has at least one row
 #
-if ("%{sql:SELECT count(*) FROM radacct WHERE AcctSessionId = '00000003'}" != "1") {
+if (%sql("SELECT count(*) FROM radacct WHERE AcctSessionId = '00000003'") != "1") {
        test_fail
 }
 
 #
 #  Check acctsessiontime matches the value in the request
 #
-if ("%{sql:SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000003'}" != "0") {
+if (%sql("SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000003'") != "0") {
        test_fail
 }
 
@@ -45,6 +45,6 @@ else {
        test_fail
 }
 
-if ("%{sql:SELECT connectinfo_start FROM radacct WHERE AcctSessionId = '00000003'}" != 'updated') {
+if (%sql("SELECT connectinfo_start FROM radacct WHERE AcctSessionId = '00000003'") != 'updated') {
        test_fail
 }
index 2ec432a3d8410fd9ab6df677297eb455f5dde387..87c8ce667db100d1053fab59aafafcc99c25910e 100644 (file)
@@ -1,18 +1,18 @@
 #
 #  Clear out old data
 #
-"%{sql:${delete_from_radacct} '00000004'}"
+%sql("${delete_from_radacct} '00000004'")
 
 sql.accounting
 if (!ok) {
        test_fail
 }
 
-if ("%{sql:SELECT count(*) FROM radacct WHERE AcctSessionId = '00000004'}" != "1") {
+if (%sql("SELECT count(*) FROM radacct WHERE AcctSessionId = '00000004'") != "1") {
        test_fail
 }
 
-if ("%{sql:SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000004'}" != "30") {
+if (%sql("SELECT acctsessiontime FROM radacct WHERE AcctSessionId = '00000004'") != "30") {
        test_fail
 }
 
index 947a1eb3a23c32c14e62469599e42c031e643879..b628d54ab904e33afacbeb3138dfbefe71aa7647 100644 (file)
@@ -1,18 +1,18 @@
 #
 #  Clear out old data
 #
-"%{sql:${delete_from_radcheck} 'user_auth'}"
-"%{sql:${delete_from_radreply} 'user_auth'}"
+%sql("${delete_from_radcheck} 'user_auth'")
+%sql("${delete_from_radreply} 'user_auth'")
 
-if ("%{sql:${insert_into_radcheck} ('user_auth', 'NAS-IP-Address', '==', '1.2.3.4')}" != "1") {
+if (%sql("${insert_into_radcheck} ('user_auth', 'NAS-IP-Address', '==', '1.2.3.4')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radcheck} ('user_auth', 'Password.Cleartext', ':=', 'password')}" != "1") {
+if (%sql("${insert_into_radcheck} ('user_auth', 'Password.Cleartext', ':=', 'password')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radreply} ('user_auth', 'Idle-Timeout', ':=', '3600')}" != "1") {
+if (%sql("${insert_into_radreply} ('user_auth', 'Idle-Timeout', ':=', '3600')") != "1") {
        test_fail
 }
 
index a23d43b32e0b5c52a679d83c6f1c933d46a502cb..7fb50139344e4694def68b02fa85efff878087cb 100644 (file)
@@ -2,29 +2,29 @@
 #  Clear out old data
 #
 
-"%{sql:DELETE FROM radgroupcheck WHERE groupname = 'groups_group_a'}"
-"%{sql:DELETE FROM radgroupcheck WHERE groupname = 'groups_group_b'}"
-"%{sql:DELETE FROM radgroupcheck WHERE groupname = 'groups_group_c'}"
+%sql("DELETE FROM radgroupcheck WHERE groupname = 'groups_group_a'")
+%sql("DELETE FROM radgroupcheck WHERE groupname = 'groups_group_b'")
+%sql("DELETE FROM radgroupcheck WHERE groupname = 'groups_group_c'")
 
-"%{sql:DELETE FROM radgroupreply WHERE groupname = 'groups_group_a'}"
-"%{sql:DELETE FROM radgroupreply WHERE groupname = 'groups_group_b'}"
-"%{sql:DELETE FROM radgroupreply WHERE groupname = 'groups_group_c'}"
+%sql("DELETE FROM radgroupreply WHERE groupname = 'groups_group_a'")
+%sql("DELETE FROM radgroupreply WHERE groupname = 'groups_group_b'")
+%sql("DELETE FROM radgroupreply WHERE groupname = 'groups_group_c'")
 
-"%{sql:DELETE FROM radusergroup WHERE priority = 1000}"
+%sql("DELETE FROM radusergroup WHERE priority = 1000")
 
 #
 #  Insert new test data
 #
-"%{sql:INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_a', 'groups_group_a', 1000)}"
-"%{sql:INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_b', 'groups_group_b', 1000)}"
-"%{sql:INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_a', 'groups_group_c', 1000)}"
-"%{sql:INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_b', 'groups_group_c', 1000)}"
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_a', 'groups_group_a', 1000)")
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_b', 'groups_group_b', 1000)")
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_a', 'groups_group_c', 1000)")
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_user_b', 'groups_group_c', 1000)")
 
-"%{sql:INSERT INTO radgroupcheck (groupname, attribute, op, value) VALUES ('groups_group_a', 'Password.Cleartext', ':=', 'UserAPassword')}"
-"%{sql:INSERT INTO radgroupcheck (groupname, attribute, op, value) VALUES ('groups_group_b', 'Password.Cleartext', ':=', 'UserBPassword')}"
+%sql("INSERT INTO radgroupcheck (groupname, attribute, op, value) VALUES ('groups_group_a', 'Password.Cleartext', ':=', 'UserAPassword')")
+%sql("INSERT INTO radgroupcheck (groupname, attribute, op, value) VALUES ('groups_group_b', 'Password.Cleartext', ':=', 'UserBPassword')")
 
-"%{sql:INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('groups_group_a', 'Reply-Message', ':=', 'Hello User A')}"
-"%{sql:INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('groups_group_b', 'Reply-Message', ':=', 'Hello User B')}"
+%sql("INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('groups_group_a', 'Reply-Message', ':=', 'Hello User A')")
+%sql("INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('groups_group_b', 'Reply-Message', ':=', 'Hello User B')")
 
 #
 #  Run SQL
index 2c9897312fa446321e76e5a048c6b2a88421763a..a26950fa84c732234f36d6eee197914972f93568 100644 (file)
@@ -1,6 +1,6 @@
 # Clear out any rows with priority 0 (each test should use a different
 # priority, so they don't interfere with each other).
-"%{sql:DELETE FROM radusergroup WHERE priority <= 1}"
+%sql("DELETE FROM radusergroup WHERE priority <= 1")
 
 # Module should return NOOP if there's no result set to work with
 map sql 'SELECT * FROM radusergroup WHERE priority <= 1' {
@@ -25,7 +25,7 @@ if (&control.Tmp-Integer-0) {
 }
 
 # Insert our first test row
-"%{sql:INSERT INTO radusergroup (username, groupname, priority) VALUES ('bob', 'bar', 0)}"
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('bob', 'bar', 0)")
 
 # Retrieve our test row
 map sql 'SELECT * FROM radusergroup WHERE priority = 0' {
@@ -55,7 +55,7 @@ if !(&control.Tmp-Integer-0 == 0) {
 &control -= &Tmp-Integer-0[*]
 
 # Insert our second test row
-"%{sql:INSERT INTO radusergroup (username, groupname, priority) VALUES ('oof', 'rab', 1)}"
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('oof', 'rab', 1)")
 
 # Retrieve our test row(s) - With := we should get the values from the second row
 map sql 'SELECT * FROM radusergroup WHERE priority <= 1 ORDER BY priority' {
index 880198a476027ee328109a5a0587a646a68f8b2c..0380f72033b7f51ac9355bbe68f58fc1e611abf2 100644 (file)
@@ -1,21 +1,21 @@
 #
 #  Clear out old data
 #
-"%{sql:${delete_from_radcheck} 'user_reject'}"
-"%{sql:${delete_from_radreply} 'user_reject'}"
+%sql("${delete_from_radcheck} 'user_reject'")
+%sql("${delete_from_radreply} 'user_reject'")
 
 #
 #  Add in the check items.
 #
-if ("%{sql:${insert_into_radcheck} ('user_reject', 'NAS-IP-Address', '==', '1.2.3.4')}" != "1") {
+if (%sql("${insert_into_radcheck} ('user_reject', 'NAS-IP-Address', '==', '1.2.3.4')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radcheck} ('user_reject', 'Password.Cleartext', ':=', 'wrong-password')}" != "1") {
+if (%sql("${insert_into_radcheck} ('user_reject', 'Password.Cleartext', ':=', 'wrong-password')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radreply} ('user_reject', 'Reply-Message', ':=', 'Authentication failed')}" != "1") {
+if (%sql("${insert_into_radreply} ('user_reject', 'Reply-Message', ':=', 'Authentication failed')") != "1") {
        test_fail
 }
 
index b07da1f739e426c690a2058848603d3f3537fc25..a5a1cb66a31b2181667b935f88e16499f0a83470 100644 (file)
@@ -1,41 +1,41 @@
 #
 #  Clear out old data.  We don't care if the deletion deletes any rows.
 #
-"%{sql:${delete_from_radcheck} 'user_auth_nested'}"
-"%{sql:${delete_from_radreply} 'user_auth_nested'}"
+%sql("${delete_from_radcheck} 'user_auth_nested'")
+%sql("${delete_from_radreply} 'user_auth_nested'")
 
 #
 #  Add in the check items.
 #
-if ("%{sql:${insert_into_radcheck} ('user_auth_nested', 'NAS-IP-Address', '==', '1.2.3.4')}" != "1") {
+if (%sql("${insert_into_radcheck} ('user_auth_nested', 'NAS-IP-Address', '==', '1.2.3.4')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radcheck} ('user_auth_nested', 'Password.Cleartext', ':=', 'password')}" != "1") {
+if (%sql("${insert_into_radcheck} ('user_auth_nested', 'Password.Cleartext', ':=', 'password')") != "1") {
        test_fail
 }
 
 #
 #  Add in the reply items.
 #
-if ("%{sql:${insert_into_radreply} ('user_auth_nested', 'Idle-Timeout', ':=', '3600')}" != "1") {
+if (%sql("${insert_into_radreply} ('user_auth_nested', 'Idle-Timeout', ':=', '3600')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radreply} ('user_auth_nested', 'Digest-Attributes', ':=', '')}" != "1") {
+if (%sql("${insert_into_radreply} ('user_auth_nested', 'Digest-Attributes', ':=', '')") != "1") {
        test_fail
 }
 
 
-if ("%{sql:${insert_into_radreply} ('user_auth_nested', '.Nonce', ':=', 'dcd98b7102dd2f0e8b11d0f600bfb0c093')}" != "1") {
+if (%sql("${insert_into_radreply} ('user_auth_nested', '.Nonce', ':=', 'dcd98b7102dd2f0e8b11d0f600bfb0c093')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radreply} ('user_auth_nested', '.Method', ':=', 'Invite')}" != "1") {
+if (%sql("${insert_into_radreply} ('user_auth_nested', '.Method', ':=', 'Invite')") != "1") {
        test_fail
 }
 
-if ("%{sql:${insert_into_radreply} ('user_auth_nested', '.URI', ':=', 'sip:bob@biloxi.com')}" != "1") {
+if (%sql("${insert_into_radreply} ('user_auth_nested', '.URI', ':=', 'sip:bob@biloxi.com')") != "1") {
        test_fail
 }