From: Nick Porter Date: Wed, 3 Apr 2024 09:49:32 +0000 (+0100) Subject: Add testing of Fall-Through to SQL groups X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afbc1236a63d9eabf4f844a67c649062c3338863;p=thirdparty%2Ffreeradius-server.git Add testing of Fall-Through to SQL groups --- diff --git a/src/tests/modules/sql/groups_fall_through.attrs b/src/tests/modules/sql/groups_fall_through.attrs new file mode 100644 index 00000000000..1009bddf2f4 --- /dev/null +++ b/src/tests/modules/sql/groups_fall_through.attrs @@ -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 index 00000000000..bbb6951dd76 --- /dev/null +++ b/src/tests/modules/sql/groups_fall_through.unlang @@ -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 index 00000000000..7a13dbe4d34 --- /dev/null +++ b/src/tests/modules/sql/groups_no_fall_through.attrs @@ -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 index 00000000000..7be243e84ec --- /dev/null +++ b/src/tests/modules/sql/groups_no_fall_through.unlang @@ -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 index 00000000000..8007bfd7a8e --- /dev/null +++ b/src/tests/modules/sql_mysql/groups_fall_through.attrs @@ -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 index 00000000000..4a2e1a02558 --- /dev/null +++ b/src/tests/modules/sql_mysql/groups_fall_through.unlang @@ -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 index 00000000000..5ff7cfbc4eb --- /dev/null +++ b/src/tests/modules/sql_mysql/groups_no_fall_through.attrs @@ -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 index 00000000000..3361cb979a4 --- /dev/null +++ b/src/tests/modules/sql_mysql/groups_no_fall_through.unlang @@ -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 index 00000000000..8007bfd7a8e --- /dev/null +++ b/src/tests/modules/sql_postgresql/groups_fall_through.attrs @@ -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 index 00000000000..4a2e1a02558 --- /dev/null +++ b/src/tests/modules/sql_postgresql/groups_fall_through.unlang @@ -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 index 00000000000..5ff7cfbc4eb --- /dev/null +++ b/src/tests/modules/sql_postgresql/groups_no_fall_through.attrs @@ -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 index 00000000000..3361cb979a4 --- /dev/null +++ b/src/tests/modules/sql_postgresql/groups_no_fall_through.unlang @@ -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 index 00000000000..8007bfd7a8e --- /dev/null +++ b/src/tests/modules/sql_sqlite/groups_fall_through.attrs @@ -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 index 00000000000..4a2e1a02558 --- /dev/null +++ b/src/tests/modules/sql_sqlite/groups_fall_through.unlang @@ -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 index 00000000000..5ff7cfbc4eb --- /dev/null +++ b/src/tests/modules/sql_sqlite/groups_no_fall_through.attrs @@ -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 index 00000000000..3361cb979a4 --- /dev/null +++ b/src/tests/modules/sql_sqlite/groups_no_fall_through.unlang @@ -0,0 +1 @@ +../sql/groups_no_fall_through.unlang \ No newline at end of file