From: Alan T. DeKok Date: Thu, 4 Aug 2022 22:55:05 +0000 (-0400) Subject: more "convert to edit" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05dba1ab067431ce79fcc7aaa7df9bdc4622daf5;p=thirdparty%2Ffreeradius-server.git more "convert to edit" --- diff --git a/src/tests/keywords/map-2arg-error b/src/tests/keywords/map-2arg-error index df2221d7a1d..53006379284 100644 --- a/src/tests/keywords/map-2arg-error +++ b/src/tests/keywords/map-2arg-error @@ -1,6 +1,3 @@ -# -# PRE: update -# map foo { # ERROR User-Name = 'foo' } diff --git a/src/tests/keywords/map-csv-prepend b/src/tests/keywords/map-csv-prepend index e3e3bd5f54c..b83755737e8 100644 --- a/src/tests/keywords/map-csv-prepend +++ b/src/tests/keywords/map-csv-prepend @@ -1,10 +1,8 @@ # -# PRE: update map +# PRE: map # -update control { - &Tmp-String-0 := "fail" -} +&control.Tmp-String-0 := "fail" map csv &User-Name { &control.Tmp-String-0 ^= 'field3' diff --git a/src/tests/keywords/map-xlat b/src/tests/keywords/map-xlat index 884a7bf5599..0cb53f48dfe 100644 --- a/src/tests/keywords/map-xlat +++ b/src/tests/keywords/map-xlat @@ -1,12 +1,12 @@ # -# PRE: update +# PRE: map foreach # # Test the map xlat # -update { - &Tmp-String-0 := '&control.Tmp-String-0 := \'testing123\'' - &Tmp-String-1 := "request.Vendor-Specific.Nokia-SR.MSAP-Interface = 'UNICAST_7360OLT3'" - &Tmp-String-1 += "request.Vendor-Specific.Nokia-SR.MSAP-Interface += 'UNICAST_7360OLT4'" +&request += { + &Tmp-String-0 = '&control.Tmp-String-0 := \'testing123\'' + &Tmp-String-1 = "request.Vendor-Specific.Nokia-SR.MSAP-Interface = 'UNICAST_7360OLT3'" + &Tmp-String-1 = "request.Vendor-Specific.Nokia-SR.MSAP-Interface += 'UNICAST_7360OLT4'" } if ("%{map:%{Tmp-String-0}}" != 1) { diff --git a/src/tests/keywords/map-xlat-nested b/src/tests/keywords/map-xlat-nested index 379385168b3..e2f4242601d 100644 --- a/src/tests/keywords/map-xlat-nested +++ b/src/tests/keywords/map-xlat-nested @@ -1,11 +1,9 @@ # -# PRE: update +# PRE: map-xlat # # Test the map xlat # -update { - &Tmp-String-0 := "request.Tmp-Group-0.Tmp-String-1 = 'testing123'" -} +&Tmp-String-0 := "request.Tmp-Group-0.Tmp-String-1 = 'testing123'" if ("%{map:%{Tmp-String-0}}" != 1) { test_fail diff --git a/src/tests/keywords/map-xlat-nested-overwrite b/src/tests/keywords/map-xlat-nested-overwrite index 505ea2474cb..9d23ad17f14 100644 --- a/src/tests/keywords/map-xlat-nested-overwrite +++ b/src/tests/keywords/map-xlat-nested-overwrite @@ -1,11 +1,9 @@ # -# PRE: update +# PRE: map-xlat # # Test the map xlat # -update { - &Tmp-String-0 := "request.Tmp-Group-0.Tmp-String-0 := 'testing123'" -} +&Tmp-String-0 := "request.Tmp-Group-0.Tmp-String-0 := 'testing123'" if ("%{map:%{Tmp-String-0}}" != 1) { test_fail diff --git a/src/tests/keywords/map-xlat-struct b/src/tests/keywords/map-xlat-struct index fb0fbe041e3..664f3781cb3 100644 --- a/src/tests/keywords/map-xlat-struct +++ b/src/tests/keywords/map-xlat-struct @@ -1,12 +1,10 @@ # -# PRE: update +# PRE: map # PROTOCOL: dhcpv6 # # Test the map xlat # -update { - &Tmp-String-0 := "IA-PD.IAID = 11" -} +&Tmp-String-0 := "IA-PD.IAID = 11" if ("%{map:%{Tmp-String-0}}" != 1) { test_fail diff --git a/src/tests/keywords/md4 b/src/tests/keywords/md4 index 91a4a80a8e4..b6cef289bd6 100644 --- a/src/tests/keywords/md4 +++ b/src/tests/keywords/md4 @@ -1,21 +1,21 @@ # -# PRE: update if -# -update { - &request.Tmp-String-0 := "This is a string\n" - &request.Tmp-Octets-0 := 0x000504030201 - &request.Tmp-String-1 := "what do ya want for nothing?" - &request.Tmp-String-2 := "Jefe" - &request.Tmp-String-3 := "" +# PRE: if +# +&request += { + &Tmp-String-0 = "This is a string\n" + &Tmp-Octets-0 = 0x000504030201 + &Tmp-String-1 = "what do ya want for nothing?" + &Tmp-String-2 = "Jefe" + &Tmp-String-3 = "" } -update request { - &Tmp-Octets-1 := "%{md4:This is a string\n}" - &Tmp-Octets-2 := "%{md4:%{Tmp-String-0}}" - &Tmp-Octets-3 := "%{md4:%{request.Tmp-String-0}}" - &Tmp-Octets-4 := "%{md4:%{request.Tmp-Octets-0}}" - &Tmp-Octets-5 := "%{md4:%{Tmp-String-9}}" +&request += { + &Tmp-Octets-1 = "%{md4:This is a string\n}" + &Tmp-Octets-2 = "%{md4:%{Tmp-String-0}}" + &Tmp-Octets-3 = "%{md4:%{request.Tmp-String-0}}" + &Tmp-Octets-4 = "%{md4:%{request.Tmp-Octets-0}}" + &Tmp-Octets-5 = "%{md4:%{Tmp-String-9}}" } # diff --git a/src/tests/keywords/md5 b/src/tests/keywords/md5 index d2b523d2953..fda682a5b62 100644 --- a/src/tests/keywords/md5 +++ b/src/tests/keywords/md5 @@ -1,23 +1,23 @@ # -# PRE: update if +# PRE: if # -update { - &request.Tmp-String-0 := "This is a string\n" - &request.Tmp-Octets-0 := 0x000504030201 - &request.Tmp-String-1 := "what do ya want for nothing?" - &request.Tmp-String-2 := "Jefe" - &request.Tmp-String-3 := "" +&request += { + &Tmp-String-0 = "This is a string\n" + &Tmp-Octets-0 = 0x000504030201 + &Tmp-String-1 = "what do ya want for nothing?" + &Tmp-String-2 = "Jefe" + &Tmp-String-3 = "" } -update request { - &Tmp-Octets-1 := "%{md5:This is a string\n}" - &Tmp-Octets-2 := "%{md5:%{Tmp-String-0}}" - &Tmp-Octets-3 := "%{md5:%{request.Tmp-String-0}}" - &Tmp-Octets-4 := "%{md5:%{request.Tmp-Octets-0}}" - &Tmp-Octets-5 := "%{md5:%{Tmp-String-9}}" - &Tmp-Octets-6 := "%(hmacmd5:%{Tmp-String-1} %{Tmp-String-2})" - &Tmp-Octets-7 := "%(hmacmd5:%{Tmp-String-3} %{Tmp-String-3})" +&request += { + &Tmp-Octets-1 = "%{md5:This is a string\n}" + &Tmp-Octets-2 = "%{md5:%{Tmp-String-0}}" + &Tmp-Octets-3 = "%{md5:%{request.Tmp-String-0}}" + &Tmp-Octets-4 = "%{md5:%{request.Tmp-Octets-0}}" + &Tmp-Octets-5 = "%{md5:%{Tmp-String-9}}" + &Tmp-Octets-6 = "%(hmacmd5:%{Tmp-String-1} %{Tmp-String-2})" + &Tmp-Octets-7 = "%(hmacmd5:%{Tmp-String-3} %{Tmp-String-3})" } # diff --git a/src/tests/keywords/md5-error b/src/tests/keywords/md5-error index 25ff43b1ab3..f04f980ea8b 100644 --- a/src/tests/keywords/md5-error +++ b/src/tests/keywords/md5-error @@ -1,16 +1,12 @@ # -# PRE: update +# PRE: md5 # -update request { - &Tmp-String-1 := "hello" -} +&Tmp-String-1 := "hello" # # MD5 HMAC with missing key should fail # -update request { - &Tmp-Octets-1 := "%(hmacmd5:%{Tmp-String-1} )" # ERROR -} +&Tmp-Octets-1 := "%(hmacmd5:%{Tmp-String-1} )" # ERROR test_fail diff --git a/src/tests/keywords/module-action-error b/src/tests/keywords/module-action-error index 0022d36f8fa..3753f8f9eb4 100644 --- a/src/tests/keywords/module-action-error +++ b/src/tests/keywords/module-action-error @@ -1,5 +1,5 @@ # -# PRE: update ok-return +# PRE: ok-return # ok { diff --git a/src/tests/keywords/module-action-ok b/src/tests/keywords/module-action-ok index 63176ce94e3..424297175cb 100644 --- a/src/tests/keywords/module-action-ok +++ b/src/tests/keywords/module-action-ok @@ -1,5 +1,5 @@ # -# PRE: update ok-return +# PRE: ok-return # ok { diff --git a/src/tests/keywords/module-failure-message b/src/tests/keywords/module-failure-message index 6c787e73082..c528e876b63 100644 --- a/src/tests/keywords/module-failure-message +++ b/src/tests/keywords/module-failure-message @@ -1,5 +1,5 @@ # -# PRE: update +# PRE: if # test diff --git a/src/tests/keywords/mschap b/src/tests/keywords/mschap index bcceaf6d58f..3bb2a9730f0 100644 --- a/src/tests/keywords/mschap +++ b/src/tests/keywords/mschap @@ -1,5 +1,5 @@ # -# PRE: update +# PRE: if # # MS CHAPv1 @@ -9,11 +9,11 @@ update request { &Vendor-Specific.Microsoft.CHAP-Response := 0x00010000000000000000000000000000000000000000000000008860bbaac0cd3960b4ce5dc6f0f7a462b897ef530484e80f } -update request { - &Tmp-Octets-0 := "%(mschap:Challenge)" - &Tmp-Octets-1 := "%(mschap:NT-Response)" - &Tmp-String-0 := "%(mschap:NT-Domain)" - &Tmp-String-1 := "%(mschap:User-Name)" +&request += { + &Tmp-Octets-0 = "%(mschap:Challenge)" + &Tmp-Octets-1 = "%(mschap:NT-Response)" + &Tmp-String-0 = "%(mschap:NT-Domain)" + &Tmp-String-1 = "%(mschap:User-Name)" } if (&Tmp-Octets-0 != 0xe96e4fff2955c4f1) { diff --git a/src/tests/keywords/nexttime b/src/tests/keywords/nexttime index b8e64e73857..7b93dfc169b 100644 --- a/src/tests/keywords/nexttime +++ b/src/tests/keywords/nexttime @@ -1,5 +1,5 @@ # -# PRE: update expr +# PRE: expr # # @@ -7,27 +7,25 @@ # different numbers of days involved. Check hour / day / week # -update request { - &Tmp-Integer-0 := "%{expr:%(nexttime:2h) - %(nexttime:1h)}" -} +&Tmp-Integer-0 := "%{expr:%(nexttime:2h) - %(nexttime:1h)}" # We have a fudge factor of 1 second either way if ((&Tmp-Integer-0 < 3599) || (&Tmp-Integer-0 > 3601)) { test_fail } -update request { - &Tmp-Integer-0 := "%{expr:%(nexttime:3d) - %(nexttime:1d)}" -} - +# +# Day +# +&Tmp-Integer-0 := "%{expr:%(nexttime:3d) - %(nexttime:1d)}" if ((&Tmp-Integer-0 < 172799) || (&Tmp-Integer-0 > 172801)) { test_fail } -update request { - &Tmp-Integer-0 := "%{expr:%(nexttime:4w) - %(nexttime:2w)}" -} - +# +# Week +# +&Tmp-Integer-0 := "%{expr:%(nexttime:4w) - %(nexttime:2w)}" if ((&Tmp-Integer-0 < 1209599) || (&Tmp-Integer-0 > 1209601)) { test_fail } diff --git a/src/tests/keywords/notfound b/src/tests/keywords/notfound index e617fe2d844..169e90082c3 100644 --- a/src/tests/keywords/notfound +++ b/src/tests/keywords/notfound @@ -1,5 +1,5 @@ # -# PRE: if update +# PRE: if # # diff --git a/src/tests/keywords/ok-return b/src/tests/keywords/ok-return index 90afe25bf33..9262160dca6 100644 --- a/src/tests/keywords/ok-return +++ b/src/tests/keywords/ok-return @@ -1,13 +1,13 @@ -update { - &control.Auth-Type = 'Accept' - &reply.Reply-Message = 'pass' -} +&control.Auth-Type := 'Accept' +&reply.Reply-Message := 'pass' + # Section should exit after this statement ok { ok = return } -update { - &reply.Reply-Message := 'fail' -} +# +# If we hit this statement, that's an error. +# +test_fail diff --git a/src/tests/keywords/pack b/src/tests/keywords/pack index 2b5079483d0..c4ac78b54dd 100644 --- a/src/tests/keywords/pack +++ b/src/tests/keywords/pack @@ -1,12 +1,14 @@ -update request { - &Framed-IP-Address := 127.0.0.1 +# +# PRE: if +# +&request += { + &Framed-IP-Address = 127.0.0.1 &NAS-Port = 2112 - &NAS-IP-Address := 127.0.0.2 + &NAS-IP-Address = 127.0.0.2 } -update request { - &Tmp-Octets-0 := "%{pack:%{Framed-IP-Address}%{NAS-Port}%{NAS-IP-Address}}" -} + +&Tmp-Octets-0 := "%{pack:%{Framed-IP-Address}%{NAS-Port}%{NAS-IP-Address}}" if (&Tmp-Octets-0 != 0x7f000001000008407f000002) { fail diff --git a/src/tests/keywords/pad b/src/tests/keywords/pad index 5fef6fe297b..1ffebb7a84c 100644 --- a/src/tests/keywords/pad +++ b/src/tests/keywords/pad @@ -1,10 +1,8 @@ # -# PRE: if update return +# PRE: if return # -update request { - &Tmp-String-0 = "test" -} +&Tmp-String-0 = "test" # # rpad tests diff --git a/src/tests/keywords/parallel b/src/tests/keywords/parallel index fe424019f87..d9af45c9b49 100644 --- a/src/tests/keywords/parallel +++ b/src/tests/keywords/parallel @@ -1,25 +1,37 @@ # -# PRE: update +# PRE: # parallel { - update parent.control { - &Tmp-Integer-0 += 1 + group { + &parent.control += { + &Tmp-Integer-0 = 1 + } } - update parent.control { - &Tmp-Integer-0 += 2 + group { + &parent.control += { + &Tmp-Integer-0 = 3 + } } - update parent.control { - &Tmp-Integer-0 += 3 + group { + &parent.control += { + &Tmp-Integer-0 = 5 + } } - update parent.control { - &Tmp-Integer-0 += 4 + group { + &parent.control += { + &Tmp-Integer-0 = 7 + } } } if ("%{control.Tmp-Integer-0[#]}" != 4) { test_fail - - return } +# +# We can't check order, as there's offically no guarantee on the +# order in which child sections will be evaluated. +# + + success