From: Alan T. DeKok Date: Thu, 21 Jan 2021 15:25:05 +0000 (-0500) Subject: move non-protocol policies into their own file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=201eaa2cd15c94ffce44eeb53cf2e3de84c65a82;p=thirdparty%2Ffreeradius-server.git move non-protocol policies into their own file We should really have src/tests/modules do this, too --- diff --git a/src/tests/keywords/dhcpv6.conf b/src/tests/keywords/dhcpv6.conf index 96759a14669..c37bc8549c9 100644 --- a/src/tests/keywords/dhcpv6.conf +++ b/src/tests/keywords/dhcpv6.conf @@ -21,64 +21,7 @@ modules { } policy { - # - # Outputs the contents of the control list in debugging (-X) mode - # - debug_control { - if("%{debug_attr:control[*]}" == '') { - noop - } - } - - # - # Outputs the contents of the request list in debugging (-X) mode - # - debug_request { - if("%{debug_attr:request[*]}" == '') { - noop - } - } - - # - # Outputs the contents of the reply list in debugging (-X) mode - # - debug_reply { - if("%{debug_attr:reply[*]}" == '') { - noop - } - } - - # - # Outputs the contents of the main lists in debugging (-X) mode - # - debug_all { - debug_control - debug_request - debug_reply - } - - # - # Set the test to successful, but only if there are no failures. - # - success { - if (!&reply.Result-Status) { - update reply { - &Result-Status := "success" - } - } - } - - test_fail { - update reply { - &Result-Status += "Failure in test at line %{interpreter:...line}" - } - - if (&parent.request.User-Name) { - update parent.reply { - &Result-Status += "Failure in test at line %{interpreter:...line}" - } - } - } +$INCLUDE policy.conf } instantiate { diff --git a/src/tests/keywords/policy.conf b/src/tests/keywords/policy.conf new file mode 100644 index 00000000000..0f3c4eb5cfc --- /dev/null +++ b/src/tests/keywords/policy.conf @@ -0,0 +1,79 @@ +# +# Common policies for the test cases. +# + +# +# Outputs the contents of the control list in debugging (-X) mode +# +debug_control { + if("%{debug_attr:control[*]}" == '') { + noop + } +} + +# +# Outputs the contents of the request list in debugging (-X) mode +# +debug_request { + if("%{debug_attr:request[*]}" == '') { + noop + } +} + +# +# Outputs the contents of the reply list in debugging (-X) mode +# +debug_reply { + if("%{debug_attr:reply[*]}" == '') { + noop + } +} + +# +# Outputs the contents of the main lists in debugging (-X) mode +# +debug_all { + debug_control + debug_request + debug_reply +} + +# +# Just check that this can be referred to as "virtual_policy.post-auth" +# +virtual_policy { + ok +} + +with.dots { + ok +} + +# +# Set the test to successful, but only if there are no failures. +# +success { + if (!&reply.Result-Status) { + update reply { + &Result-Status := "success" + } + } + + if (&parent.request.User-Name && !&parent.reply.Result-Status) { + update parent.reply { + &Result-Status := "success" + } + } +} + +test_fail { + update reply { + &Result-Status += "Failure in test at line %{interpreter:...line}" + } + + if (&parent.request.User-Name) { + update parent.reply { + &Result-Status += "Failure in test at line %{interpreter:...line}" + } + } +} diff --git a/src/tests/keywords/radius.conf b/src/tests/keywords/radius.conf index 0e022fea0c2..88c4f12a9ce 100644 --- a/src/tests/keywords/radius.conf +++ b/src/tests/keywords/radius.conf @@ -33,81 +33,7 @@ modules { } policy { - # - # Outputs the contents of the control list in debugging (-X) mode - # - debug_control { - if("%{debug_attr:control[*]}" == '') { - noop - } - } - - # - # Outputs the contents of the request list in debugging (-X) mode - # - debug_request { - if("%{debug_attr:request[*]}" == '') { - noop - } - } - - # - # Outputs the contents of the reply list in debugging (-X) mode - # - debug_reply { - if("%{debug_attr:reply[*]}" == '') { - noop - } - } - - # - # Outputs the contents of the main lists in debugging (-X) mode - # - debug_all { - debug_control - debug_request - debug_reply - } - - # - # Just check that this can be referred to as "virtual_policy.post-auth" - # - virtual_policy { - ok - } - - with.dots { - ok - } - - # - # Set the test to successful, but only if there are no failures. - # - success { - if (!&reply.Result-Status) { - update reply { - &Result-Status := "success" - } - } - - if (&parent.request.User-Name && !&parent.reply.Result-Status) { - update parent.reply { - &Result-Status := "success" - } - } - } - - test_fail { - update reply { - &Result-Status += "Failure in test at line %{interpreter:...line}" - } - - if (&parent.request.User-Name) { - update parent.reply { - &Result-Status += "Failure in test at line %{interpreter:...line}" - } - } - } +$INCLUDE policy.conf # # Return within a policy