]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add testing of Fall-Through to SQL groups
authorNick Porter <nick@portercomputing.co.uk>
Wed, 3 Apr 2024 09:49:32 +0000 (10:49 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 8 Apr 2024 13:25:36 +0000 (14:25 +0100)
16 files changed:
src/tests/modules/sql/groups_fall_through.attrs [new file with mode: 0644]
src/tests/modules/sql/groups_fall_through.unlang [new file with mode: 0644]
src/tests/modules/sql/groups_no_fall_through.attrs [new file with mode: 0644]
src/tests/modules/sql/groups_no_fall_through.unlang [new file with mode: 0644]
src/tests/modules/sql_mysql/groups_fall_through.attrs [new symlink]
src/tests/modules/sql_mysql/groups_fall_through.unlang [new symlink]
src/tests/modules/sql_mysql/groups_no_fall_through.attrs [new symlink]
src/tests/modules/sql_mysql/groups_no_fall_through.unlang [new symlink]
src/tests/modules/sql_postgresql/groups_fall_through.attrs [new symlink]
src/tests/modules/sql_postgresql/groups_fall_through.unlang [new symlink]
src/tests/modules/sql_postgresql/groups_no_fall_through.attrs [new symlink]
src/tests/modules/sql_postgresql/groups_no_fall_through.unlang [new symlink]
src/tests/modules/sql_sqlite/groups_fall_through.attrs [new symlink]
src/tests/modules/sql_sqlite/groups_fall_through.unlang [new symlink]
src/tests/modules/sql_sqlite/groups_no_fall_through.attrs [new symlink]
src/tests/modules/sql_sqlite/groups_no_fall_through.unlang [new symlink]

diff --git a/src/tests/modules/sql/groups_fall_through.attrs b/src/tests/modules/sql/groups_fall_through.attrs
new file mode 100644 (file)
index 0000000..1009bdd
--- /dev/null
@@ -0,0 +1,13 @@
+#
+#  Input packet
+#
+Packet-Type = Access-Request
+User-Name = "groups_fall_through"
+User-Password = "secret"
+NAS-IP-Address = "1.2.3.4"
+
+#
+#  Expected answer
+#
+Packet-Type == Access-Accept
+Reply-Message == "Hello Fallthrough User"
diff --git a/src/tests/modules/sql/groups_fall_through.unlang b/src/tests/modules/sql/groups_fall_through.unlang
new file mode 100644 (file)
index 0000000..bbb6951
--- /dev/null
@@ -0,0 +1,47 @@
+#
+#  Clear out old data
+#
+string groupname
+
+%sql("DELETE FROM radgroupcheck WHERE groupname = 'fallthrough_group_a'")
+%sql("DELETE FROM radgroupcheck WHERE groupname = 'fallthrough_group_b'")
+%sql("DELETE FROM radgroupcheck WHERE groupname = 'fallthrough_group_c'")
+
+%sql("DELETE FROM radgroupreply WHERE groupname = 'fallthrough_group_a'")
+%sql("DELETE FROM radgroupreply WHERE groupname = 'fallthrough_group_b'")
+%sql("DELETE FROM radgroupreply WHERE groupname = 'fallthrough_group_c'")
+
+%sql("DELETE FROM radusergroup WHERE username = 'groups_fall_through'")
+
+#
+#  Insert new test data
+#
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_fall_through', 'fallthrough_group_a', 1010)")
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_fall_through', 'fallthrough_group_b', 1020)")
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_fall_through', 'fallthrough_group_c', 1030)")
+
+%sql("INSERT INTO radgroupcheck (groupname, attribute, op, value) VALUES ('fallthrough_group_a', 'Password.Cleartext', ':=', 'UserAPassword')")
+%sql("INSERT INTO radgroupcheck (groupname, attribute, op, value) VALUES ('fallthrough_group_b', 'Password.Cleartext', ':=', 'secret')")
+
+%sql("INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('fallthrough_group_a', 'Reply-Message', ':=', 'Hello User A')")
+%sql("INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('fallthrough_group_a', 'Fall-Through', '=', 'yes')")
+%sql("INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('fallthrough_group_b', 'Reply-Message', ':=', 'Hello Fallthrough User')")
+%sql("INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('fallthrough_group_c', 'Reply-Message', ':=', 'Hello User B')")
+
+#
+#  Run SQL
+#
+sql
+if (!updated) {
+       test_fail
+}
+
+if !(&control.Password.Cleartext == &User-Password) {
+       test_fail
+}
+
+if !(&reply.Reply-Message == "Hello Fallthrough User") {
+       test_fail
+}
+
+test_pass
diff --git a/src/tests/modules/sql/groups_no_fall_through.attrs b/src/tests/modules/sql/groups_no_fall_through.attrs
new file mode 100644 (file)
index 0000000..7a13dbe
--- /dev/null
@@ -0,0 +1,13 @@
+#
+#  Input packet
+#
+Packet-Type = Access-Request
+User-Name = "groups_no_fall_through"
+User-Password = "topsecret"
+NAS-IP-Address = "1.2.3.4"
+
+#
+#  Expected answer
+#
+Packet-Type == Access-Accept
+Reply-Message == "Hello No-Fallthrough User"
diff --git a/src/tests/modules/sql/groups_no_fall_through.unlang b/src/tests/modules/sql/groups_no_fall_through.unlang
new file mode 100644 (file)
index 0000000..7be243e
--- /dev/null
@@ -0,0 +1,40 @@
+#
+#  Clear out old data
+#
+string groupname
+
+%sql("${delete_from_radcheck} 'groups_no_fall_through'")
+%sql("${delete_from_radreply} 'groups_no_fall_through'")
+
+%sql("DELETE FROM radgroupcheck WHERE groupname = 'nofallthrough_group'")
+%sql("DELETE FROM radgroupreply WHERE groupname = 'nofallthrough_group'")
+
+%sql("DELETE FROM radusergroup WHERE username = 'groups_no_fall_through'")
+
+#
+#  Insert new test data
+#
+%sql("${insert_into_radcheck} ('groups_no_fall_through', 'Password.Cleartext', ':=', 'topsecret')")
+%sql("${insert_into_radreply} ('groups_no_fall_through', 'Reply-Message', ':=', 'Hello No-Fallthrough User')")
+%sql("${insert_into_radreply} ('groups_no_fall_through', 'Fall-Through', ':=', 'no')")
+%sql("INSERT INTO radusergroup (username, groupname, priority) VALUES ('groups_no_fall_through', 'fallthrough_group', 1010)")
+%sql("INSERT INTO radgroupcheck (groupname, attribute, op, value) VALUES ('nofallthrough_group', 'Password.Cleartext', ':=', 'UserAPassword')")
+%sql("INSERT INTO radgroupreply (groupname, attribute, op, value) VALUES ('nofallthrough_group', 'Reply-Message', ':=', 'Hello User A')")
+
+#
+#  Run SQL
+#
+sql
+if (!ok) {
+       test_fail
+}
+
+if !(&control.Password.Cleartext == &User-Password) {
+       test_fail
+}
+
+if !(&reply.Reply-Message == "Hello No-Fallthrough User") {
+       test_fail
+}
+
+test_pass
diff --git a/src/tests/modules/sql_mysql/groups_fall_through.attrs b/src/tests/modules/sql_mysql/groups_fall_through.attrs
new file mode 120000 (symlink)
index 0000000..8007bfd
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_fall_through.attrs
\ No newline at end of file
diff --git a/src/tests/modules/sql_mysql/groups_fall_through.unlang b/src/tests/modules/sql_mysql/groups_fall_through.unlang
new file mode 120000 (symlink)
index 0000000..4a2e1a0
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_fall_through.unlang
\ No newline at end of file
diff --git a/src/tests/modules/sql_mysql/groups_no_fall_through.attrs b/src/tests/modules/sql_mysql/groups_no_fall_through.attrs
new file mode 120000 (symlink)
index 0000000..5ff7cfb
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_no_fall_through.attrs
\ No newline at end of file
diff --git a/src/tests/modules/sql_mysql/groups_no_fall_through.unlang b/src/tests/modules/sql_mysql/groups_no_fall_through.unlang
new file mode 120000 (symlink)
index 0000000..3361cb9
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_no_fall_through.unlang
\ No newline at end of file
diff --git a/src/tests/modules/sql_postgresql/groups_fall_through.attrs b/src/tests/modules/sql_postgresql/groups_fall_through.attrs
new file mode 120000 (symlink)
index 0000000..8007bfd
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_fall_through.attrs
\ No newline at end of file
diff --git a/src/tests/modules/sql_postgresql/groups_fall_through.unlang b/src/tests/modules/sql_postgresql/groups_fall_through.unlang
new file mode 120000 (symlink)
index 0000000..4a2e1a0
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_fall_through.unlang
\ No newline at end of file
diff --git a/src/tests/modules/sql_postgresql/groups_no_fall_through.attrs b/src/tests/modules/sql_postgresql/groups_no_fall_through.attrs
new file mode 120000 (symlink)
index 0000000..5ff7cfb
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_no_fall_through.attrs
\ No newline at end of file
diff --git a/src/tests/modules/sql_postgresql/groups_no_fall_through.unlang b/src/tests/modules/sql_postgresql/groups_no_fall_through.unlang
new file mode 120000 (symlink)
index 0000000..3361cb9
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_no_fall_through.unlang
\ No newline at end of file
diff --git a/src/tests/modules/sql_sqlite/groups_fall_through.attrs b/src/tests/modules/sql_sqlite/groups_fall_through.attrs
new file mode 120000 (symlink)
index 0000000..8007bfd
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_fall_through.attrs
\ No newline at end of file
diff --git a/src/tests/modules/sql_sqlite/groups_fall_through.unlang b/src/tests/modules/sql_sqlite/groups_fall_through.unlang
new file mode 120000 (symlink)
index 0000000..4a2e1a0
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_fall_through.unlang
\ No newline at end of file
diff --git a/src/tests/modules/sql_sqlite/groups_no_fall_through.attrs b/src/tests/modules/sql_sqlite/groups_no_fall_through.attrs
new file mode 120000 (symlink)
index 0000000..5ff7cfb
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_no_fall_through.attrs
\ No newline at end of file
diff --git a/src/tests/modules/sql_sqlite/groups_no_fall_through.unlang b/src/tests/modules/sql_sqlite/groups_no_fall_through.unlang
new file mode 120000 (symlink)
index 0000000..3361cb9
--- /dev/null
@@ -0,0 +1 @@
+../sql/groups_no_fall_through.unlang
\ No newline at end of file