From: Nick Porter Date: Tue, 22 Oct 2024 07:10:13 +0000 (+0100) Subject: Move tests to be used by all SQL flavours X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ee6864efec26fd9703b576cd6125ff6d830c018;p=thirdparty%2Ffreeradius-server.git Move tests to be used by all SQL flavours --- diff --git a/src/tests/modules/sql/attrref.attrs b/src/tests/modules/sql/attrref.attrs new file mode 100644 index 00000000000..32d40c7d2d6 --- /dev/null +++ b/src/tests/modules/sql/attrref.attrs @@ -0,0 +1,14 @@ +# +# Input packet +# +Packet-Type = Access-Request +User-Name = "attrref" +User-Password = "password" +NAS-IP-Address = "1.2.3.4" +Framed-IP-Address = "1.2.3.4" + +# +# Expected answer +# +Packet-Type == Access-Accept +Idle-Timeout == 3600 diff --git a/src/tests/modules/sql/attrref.unlang b/src/tests/modules/sql/attrref.unlang new file mode 100644 index 00000000000..09544bdf7a7 --- /dev/null +++ b/src/tests/modules/sql/attrref.unlang @@ -0,0 +1,19 @@ +# +# Clear out old data +# +%sql("${delete_from_radcheck} 'attrref'") +%sql("${delete_from_radreply} 'attrref'") + +if (%sql("${insert_into_radcheck} ('attrref', 'NAS-IP-Address', '==', '&Framed-IP-Address')") != "1") { + test_fail +} + +if (%sql("${insert_into_radcheck} ('attrref', 'Password.Cleartext', ':=', 'password')") != "1") { + test_fail +} + +if (%sql("${insert_into_radreply} ('attrref', 'Idle-Timeout', ':=', '3600')") != "1") { + test_fail +} + +sql diff --git a/src/tests/modules/sql/nested.attrs b/src/tests/modules/sql/nested.attrs new file mode 100644 index 00000000000..40131c09370 --- /dev/null +++ b/src/tests/modules/sql/nested.attrs @@ -0,0 +1,14 @@ +# +# Input packet +# +Packet-Type = Access-Request +User-Name = "user_auth_nested" +User-Password = "password" +NAS-IP-Address = "1.2.3.4" + +# +# Expected answer +# +Packet-Type == Access-Accept +Idle-Timeout == 3600 +Digest-Attributes == { Nonce == "dcd98b7102dd2f0e8b11d0f600bfb0c093", Method == "Invite", URI == "sip:bob@biloxi.com" } diff --git a/src/tests/modules/sql/nested.unlang b/src/tests/modules/sql/nested.unlang new file mode 100644 index 00000000000..443a61b553a --- /dev/null +++ b/src/tests/modules/sql/nested.unlang @@ -0,0 +1,51 @@ +# +# 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'") + +# +# Add in the check items. +# +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") { + test_fail +} + +# +# Add in the reply items. +# +if (%sql("${insert_into_radreply} ('user_auth_nested', 'Idle-Timeout', ':=', '3600')") != "1") { + test_fail +} + +if (0) { +if (%sql("${insert_into_radreply} ('user_auth_nested', 'Digest-Attributes', ':=', 'Nonce = \"dcd98b7102dd2f0e8b11d0f600bfb0c093\", Method = \"Invite\", URI = \"sip:bob@biloxi.com\"')") != "1") { + test_fail +} + +} else { +if (%sql("${insert_into_radreply} ('user_auth_nested', 'Digest-Attributes', ':=', '')") != "1") { + test_fail +} + +if (%sql("${insert_into_radreply} ('user_auth_nested', '.Nonce', '=', 'dcd98b7102dd2f0e8b11d0f600bfb0c093')") != "1") { + test_fail +} + +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") { + test_fail +} +} + +# +# Run the SQL module to get the replies. +# +sql diff --git a/src/tests/modules/sql/xlat.attrs b/src/tests/modules/sql/xlat.attrs new file mode 100644 index 00000000000..3e1af7b75a5 --- /dev/null +++ b/src/tests/modules/sql/xlat.attrs @@ -0,0 +1,13 @@ +# +# Input packet +# +Packet-Type = Access-Request +User-Name = "xlat" +User-Password = "password" +NAS-IP-Address = "1.2.3.4" + +# +# Expected answer +# +Packet-Type == Access-Accept +Reply-Message == "Hello xlat" diff --git a/src/tests/modules/sql/xlat.unlang b/src/tests/modules/sql/xlat.unlang new file mode 100644 index 00000000000..be14a371dce --- /dev/null +++ b/src/tests/modules/sql/xlat.unlang @@ -0,0 +1,15 @@ +# +# Clear out old data +# +%sql("${delete_from_radcheck} 'xlat'") +%sql("${delete_from_radreply} 'xlat'") + +if (%sql("${insert_into_radcheck} ('%{User-Name}', 'Password.Cleartext', ':=', 'password')") != "1") { + test_fail +} + +if (%sql("${insert_into_radreply} ('%{User-Name}', 'Reply-Message', ':=', '\"Hello \%{User-Name}\"')") != "1") { + test_fail +} + +sql diff --git a/src/tests/modules/sql_mysql/attrref.attrs b/src/tests/modules/sql_mysql/attrref.attrs new file mode 120000 index 00000000000..a8a5c1bb227 --- /dev/null +++ b/src/tests/modules/sql_mysql/attrref.attrs @@ -0,0 +1 @@ +../sql/attrref.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_mysql/attrref.unlang b/src/tests/modules/sql_mysql/attrref.unlang new file mode 120000 index 00000000000..f001171bccf --- /dev/null +++ b/src/tests/modules/sql_mysql/attrref.unlang @@ -0,0 +1 @@ +../sql/attrref.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_mysql/nested.attrs b/src/tests/modules/sql_mysql/nested.attrs new file mode 120000 index 00000000000..c59106145be --- /dev/null +++ b/src/tests/modules/sql_mysql/nested.attrs @@ -0,0 +1 @@ +../sql/nested.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_mysql/nested.unlang b/src/tests/modules/sql_mysql/nested.unlang new file mode 120000 index 00000000000..b742ca954b7 --- /dev/null +++ b/src/tests/modules/sql_mysql/nested.unlang @@ -0,0 +1 @@ +../sql/nested.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_mysql/xlat.attrs b/src/tests/modules/sql_mysql/xlat.attrs new file mode 120000 index 00000000000..08ddf2e7aa1 --- /dev/null +++ b/src/tests/modules/sql_mysql/xlat.attrs @@ -0,0 +1 @@ +../sql/xlat.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_mysql/xlat.unlang b/src/tests/modules/sql_mysql/xlat.unlang new file mode 120000 index 00000000000..4d14f02b3a2 --- /dev/null +++ b/src/tests/modules/sql_mysql/xlat.unlang @@ -0,0 +1 @@ +../sql/xlat.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_postgresql/attrref.attrs b/src/tests/modules/sql_postgresql/attrref.attrs new file mode 120000 index 00000000000..a8a5c1bb227 --- /dev/null +++ b/src/tests/modules/sql_postgresql/attrref.attrs @@ -0,0 +1 @@ +../sql/attrref.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_postgresql/attrref.unlang b/src/tests/modules/sql_postgresql/attrref.unlang new file mode 120000 index 00000000000..f001171bccf --- /dev/null +++ b/src/tests/modules/sql_postgresql/attrref.unlang @@ -0,0 +1 @@ +../sql/attrref.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_postgresql/nested.attrs b/src/tests/modules/sql_postgresql/nested.attrs new file mode 120000 index 00000000000..c59106145be --- /dev/null +++ b/src/tests/modules/sql_postgresql/nested.attrs @@ -0,0 +1 @@ +../sql/nested.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_postgresql/nested.unlang b/src/tests/modules/sql_postgresql/nested.unlang new file mode 120000 index 00000000000..b742ca954b7 --- /dev/null +++ b/src/tests/modules/sql_postgresql/nested.unlang @@ -0,0 +1 @@ +../sql/nested.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_postgresql/xlat.attrs b/src/tests/modules/sql_postgresql/xlat.attrs new file mode 120000 index 00000000000..08ddf2e7aa1 --- /dev/null +++ b/src/tests/modules/sql_postgresql/xlat.attrs @@ -0,0 +1 @@ +../sql/xlat.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_postgresql/xlat.unlang b/src/tests/modules/sql_postgresql/xlat.unlang new file mode 120000 index 00000000000..4d14f02b3a2 --- /dev/null +++ b/src/tests/modules/sql_postgresql/xlat.unlang @@ -0,0 +1 @@ +../sql/xlat.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_sqlite/attrref.attrs b/src/tests/modules/sql_sqlite/attrref.attrs deleted file mode 100644 index 32d40c7d2d6..00000000000 --- a/src/tests/modules/sql_sqlite/attrref.attrs +++ /dev/null @@ -1,14 +0,0 @@ -# -# Input packet -# -Packet-Type = Access-Request -User-Name = "attrref" -User-Password = "password" -NAS-IP-Address = "1.2.3.4" -Framed-IP-Address = "1.2.3.4" - -# -# Expected answer -# -Packet-Type == Access-Accept -Idle-Timeout == 3600 diff --git a/src/tests/modules/sql_sqlite/attrref.attrs b/src/tests/modules/sql_sqlite/attrref.attrs new file mode 120000 index 00000000000..a8a5c1bb227 --- /dev/null +++ b/src/tests/modules/sql_sqlite/attrref.attrs @@ -0,0 +1 @@ +../sql/attrref.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_sqlite/attrref.unlang b/src/tests/modules/sql_sqlite/attrref.unlang deleted file mode 100644 index 09544bdf7a7..00000000000 --- a/src/tests/modules/sql_sqlite/attrref.unlang +++ /dev/null @@ -1,19 +0,0 @@ -# -# Clear out old data -# -%sql("${delete_from_radcheck} 'attrref'") -%sql("${delete_from_radreply} 'attrref'") - -if (%sql("${insert_into_radcheck} ('attrref', 'NAS-IP-Address', '==', '&Framed-IP-Address')") != "1") { - test_fail -} - -if (%sql("${insert_into_radcheck} ('attrref', 'Password.Cleartext', ':=', 'password')") != "1") { - test_fail -} - -if (%sql("${insert_into_radreply} ('attrref', 'Idle-Timeout', ':=', '3600')") != "1") { - test_fail -} - -sql diff --git a/src/tests/modules/sql_sqlite/attrref.unlang b/src/tests/modules/sql_sqlite/attrref.unlang new file mode 120000 index 00000000000..f001171bccf --- /dev/null +++ b/src/tests/modules/sql_sqlite/attrref.unlang @@ -0,0 +1 @@ +../sql/attrref.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_sqlite/nested.attrs b/src/tests/modules/sql_sqlite/nested.attrs deleted file mode 100644 index 40131c09370..00000000000 --- a/src/tests/modules/sql_sqlite/nested.attrs +++ /dev/null @@ -1,14 +0,0 @@ -# -# Input packet -# -Packet-Type = Access-Request -User-Name = "user_auth_nested" -User-Password = "password" -NAS-IP-Address = "1.2.3.4" - -# -# Expected answer -# -Packet-Type == Access-Accept -Idle-Timeout == 3600 -Digest-Attributes == { Nonce == "dcd98b7102dd2f0e8b11d0f600bfb0c093", Method == "Invite", URI == "sip:bob@biloxi.com" } diff --git a/src/tests/modules/sql_sqlite/nested.attrs b/src/tests/modules/sql_sqlite/nested.attrs new file mode 120000 index 00000000000..c59106145be --- /dev/null +++ b/src/tests/modules/sql_sqlite/nested.attrs @@ -0,0 +1 @@ +../sql/nested.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_sqlite/nested.unlang b/src/tests/modules/sql_sqlite/nested.unlang deleted file mode 100644 index 443a61b553a..00000000000 --- a/src/tests/modules/sql_sqlite/nested.unlang +++ /dev/null @@ -1,51 +0,0 @@ -# -# 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'") - -# -# Add in the check items. -# -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") { - test_fail -} - -# -# Add in the reply items. -# -if (%sql("${insert_into_radreply} ('user_auth_nested', 'Idle-Timeout', ':=', '3600')") != "1") { - test_fail -} - -if (0) { -if (%sql("${insert_into_radreply} ('user_auth_nested', 'Digest-Attributes', ':=', 'Nonce = \"dcd98b7102dd2f0e8b11d0f600bfb0c093\", Method = \"Invite\", URI = \"sip:bob@biloxi.com\"')") != "1") { - test_fail -} - -} else { -if (%sql("${insert_into_radreply} ('user_auth_nested', 'Digest-Attributes', ':=', '')") != "1") { - test_fail -} - -if (%sql("${insert_into_radreply} ('user_auth_nested', '.Nonce', '=', 'dcd98b7102dd2f0e8b11d0f600bfb0c093')") != "1") { - test_fail -} - -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") { - test_fail -} -} - -# -# Run the SQL module to get the replies. -# -sql diff --git a/src/tests/modules/sql_sqlite/nested.unlang b/src/tests/modules/sql_sqlite/nested.unlang new file mode 120000 index 00000000000..b742ca954b7 --- /dev/null +++ b/src/tests/modules/sql_sqlite/nested.unlang @@ -0,0 +1 @@ +../sql/nested.unlang \ No newline at end of file diff --git a/src/tests/modules/sql_sqlite/xlat.attrs b/src/tests/modules/sql_sqlite/xlat.attrs deleted file mode 100644 index 3e1af7b75a5..00000000000 --- a/src/tests/modules/sql_sqlite/xlat.attrs +++ /dev/null @@ -1,13 +0,0 @@ -# -# Input packet -# -Packet-Type = Access-Request -User-Name = "xlat" -User-Password = "password" -NAS-IP-Address = "1.2.3.4" - -# -# Expected answer -# -Packet-Type == Access-Accept -Reply-Message == "Hello xlat" diff --git a/src/tests/modules/sql_sqlite/xlat.attrs b/src/tests/modules/sql_sqlite/xlat.attrs new file mode 120000 index 00000000000..08ddf2e7aa1 --- /dev/null +++ b/src/tests/modules/sql_sqlite/xlat.attrs @@ -0,0 +1 @@ +../sql/xlat.attrs \ No newline at end of file diff --git a/src/tests/modules/sql_sqlite/xlat.unlang b/src/tests/modules/sql_sqlite/xlat.unlang deleted file mode 100644 index be14a371dce..00000000000 --- a/src/tests/modules/sql_sqlite/xlat.unlang +++ /dev/null @@ -1,15 +0,0 @@ -# -# Clear out old data -# -%sql("${delete_from_radcheck} 'xlat'") -%sql("${delete_from_radreply} 'xlat'") - -if (%sql("${insert_into_radcheck} ('%{User-Name}', 'Password.Cleartext', ':=', 'password')") != "1") { - test_fail -} - -if (%sql("${insert_into_radreply} ('%{User-Name}', 'Reply-Message', ':=', '\"Hello \%{User-Name}\"')") != "1") { - test_fail -} - -sql diff --git a/src/tests/modules/sql_sqlite/xlat.unlang b/src/tests/modules/sql_sqlite/xlat.unlang new file mode 120000 index 00000000000..4d14f02b3a2 --- /dev/null +++ b/src/tests/modules/sql_sqlite/xlat.unlang @@ -0,0 +1 @@ +../sql/xlat.unlang \ No newline at end of file