]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add test of NULL SQL value handling
authorNick Porter <nick@portercomputing.co.uk>
Mon, 21 Oct 2024 14:05:03 +0000 (15:05 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 21 Oct 2024 15:38:02 +0000 (16:38 +0100)
src/tests/modules/sql/map.unlang

index 341256d15ec2ea69a05dd8805e5c27f4066893b2..ebc1517cc4bdcc8d9d4cd7d8ccef11d510870a53 100644 (file)
@@ -295,4 +295,28 @@ if (!notfound) {
        test_fail
 }
 
+# Clear the control list
+&control -= &User-Name[*]
+&control -= &Filter-Id[*]
+
+# Check behaviour of NULL vs empty string returns.
+# radacct is used here as the default schema allows NULL in many columns
+%sql("DELETE FROM radacct WHERE acctuniqueid = 'nullmap'")
+%sql("INSERT INTO radacct (acctuniqueid, acctsessionid, nasipaddress, username) VALUES ('nullmap', 'nullmap', '10.11.12.13', '')")
+map sql "SELECT username, connectinfo_start, nasipaddress FROM radacct WHERE acctuniqueid = 'nullmap'" {
+       &control.User-Name := 'username'
+       &control.Filter-Id := 'connectinfo_start'
+       &control.NAS-IP-Address := 'nasipaddress'
+}
+
+if !(&control.User-Name == '') {
+       test_fail
+}
+if (&control.Filter-Id) {
+       test_fail
+}
+if !(&control.NAS-IP-Address == 10.11.12.13) {
+       test_fail
+}
+
 test_pass