]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
more "update -> edit"
authorAlan T. DeKok <aland@freeradius.org>
Wed, 27 Jul 2022 12:52:05 +0000 (08:52 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 27 Jul 2022 14:34:59 +0000 (10:34 -0400)
src/tests/keywords/3gpp
src/tests/keywords/date
src/tests/keywords/debug
src/tests/keywords/else-empty
src/tests/keywords/else-error
src/tests/keywords/escape
src/tests/keywords/expr
src/tests/keywords/foreach
src/tests/keywords/hex

index ca615933ea7e7ab2e1d97dbf8e39f8c2686b9ae6..b70b7b53d559dbb6623aaf60464e2fcd782d32a2 100644 (file)
@@ -1,17 +1,10 @@
-#
-#  PRE: update
-#
-update request {
-       &Vendor-Specific.3GPP.IMSI := "hello"
-}
+&request.Vendor-Specific.3GPP.IMSI := "hello"
 
 #
 #  "request.[0-9]" should be parsed as a list followed
 #  by an attribute.
 #
-update control {
-       &Tmp-String-0 := &Vendor-Specific.3GPP.IMSI
-       &Tmp-String-1 := &request.Vendor-Specific.3GPP.IMSI
-}
+&control.Tmp-String-0 := &Vendor-Specific.3GPP.IMSI
+&control.Tmp-String-1 := &request.Vendor-Specific.3GPP.IMSI
 
 success
index daa1c9f0facbad7c142dd0a1a41d53a8e99330f6..7efbb0f3cc27c4b0efaf75503d49c9994e3bf761 100644 (file)
@@ -1,16 +1,12 @@
 #
-#  PRE: update if
+#  PRE: if
 #
 
 # Use pre-defined date and time
-update request {
-       &Tmp-Integer-0 := 1506101100;
-}
+&Tmp-Integer-0 := 1506101100
 
 # Convert to string representation
-update request {
-       &Tmp-String-0 := "%(date:%{Tmp-Integer-0})"
-}
+&Tmp-String-0 := %(date:%{Tmp-Integer-0})
 
 # Some systems report GMT some UTC...
 if (&Tmp-String-0 != "Fri 22 Sep 17:25:00 GMT 2017") && (&Tmp-String-0 != "Fri 22 Sep 17:25:00 UTC 2017") {
@@ -18,58 +14,40 @@ if (&Tmp-String-0 != "Fri 22 Sep 17:25:00 GMT 2017") && (&Tmp-String-0 != "Fri 2
 }
 
 # Convert string to integer
-update request {
-       &Tmp-Integer-1 := %(integer:%(date:%{Tmp-String-0}))
-}
+&Tmp-Integer-1 := %(integer:%(date:%{Tmp-String-0}))
 
 if (&Tmp-Integer-1 != &Tmp-Integer-0) {
        test_fail
 }
 
 # Compare two methods of reading request timestamp in local timezone
-update request {
-       &Tmp-String-0 := "%(localdate:request)"
-       &Tmp-String-1 := "%S"
-}
+&Tmp-String-0 := %(localdate:request)
+&Tmp-String-1 := "%S"
 
 if (&Tmp-String-0 != &Tmp-String-1) {
        test_fail
 }
 
 # Convert different string format
-update request {
-       &Tmp-String-2 := "2017-09-22 17:25:00"
-}
+&Tmp-String-2 := "2017-09-22 17:25:00"
 
-update request {
-       &Tmp-Integer-2 := %(integer:%(sqldate:%{Tmp-String-2}))
-}
+&Tmp-Integer-2 := %(integer:%(sqldate:%{Tmp-String-2}))
 
 if (&Tmp-Integer-2 != &Tmp-Integer-0) {
        test_fail
 }
 
 # Use a date attribute
-update request {
-       &Tmp-Date-0 := 1659985459
-}
-
-update request {
-       &Tmp-String-2 := "%(sqldate:%{Tmp-Date-0})"
-}
+&Tmp-Date-0 := 1659985459
+&Tmp-String-2 := "%(sqldate:%{Tmp-Date-0})"
 
 if (&Tmp-String-2 != '2022-08-08 19:04:19') {
        test_fail
 }
 
 # Invalid format
-update request {
-       &Tmp-String-3 := '201-32-22 17:25:00'
-}
-
-update request {
-       &Tmp-String-0 := "%(sqldate:%{Tmp-String-3})"
-}
+&Tmp-String-3 := '201-32-22 17:25:00'
+&Tmp-String-0 := "%(sqldate:%{Tmp-String-3})"
 
 if (&Tmp-String-0 != "") {
        test_fail
@@ -79,14 +57,9 @@ if (&Module-Failure-Message != "Failed to parse time string \"201-32-22 17:25:00
        test_fail
 }
 
-update request {
-       &NAS-IP-Address := "192.168.1.1"
-}
-
 # Invalid type
-update request {
-       &Tmp-String-4 := "%(date:%{NAS-IP-Address})"
-}
+&NAS-IP-Address := "192.168.1.1"
+&Tmp-String-4 := %(date:%{NAS-IP-Address})
 
 if (&Tmp-String-4 != "") {
        test_fail
index 3d5c447d8a48b4ab120addc365fd97cbd60136af..39d63e86f05ebcf5a0efe2cbf780a82cffda2b08 100644 (file)
@@ -1,10 +1,8 @@
 #
-#  PRE: update if
+#  PRE: if
 #
 
-update request {
-       &Tmp-Integer-0 := "%(debug:4)"
-}
+&Tmp-Integer-0 := "%(debug:4)"
 
 # Check debug level is now 4
 if ("%(debug:3)" != 4) {
index ef77c3903cbb9489ec246ca89b933fba92862515..cbe07e4e09a2795eb160c2367fcd05313d8fa435 100644 (file)
@@ -1,5 +1,5 @@
 #
-#  PRE: update if-empty-allow
+#  PRE: if-empty-allow
 #
 
 if (&User-Name == 'bob') {
index 0812437cc95be5c85ce4a46a4ed50fd4de7159aa..2650ad010a6669ed90524951f03871eed0892048 100644 (file)
@@ -1,12 +1,10 @@
 #
-#  PRE: update if
+#  PRE: if
 #
 #  "else" has to be preceded by an "if" or "elsif"
 #
 if (1) {
-       update control {
-               &Password.Cleartext := "fail"
-       }
+       &control.Password.Cleartext := "fail"
 
        else {  # ERROR
             ok
index 8b6e9302a181aa5e4a3a9ca293467ca78d15fa0e..04afee6cbca4614b870215f3db48aa26b413b5a1 100644 (file)
@@ -1,21 +1,19 @@
 #
 #  PRE: update if xlat-attr-index
 #
-update request {
-       &Tmp-String-0 := '@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /'
-       &Tmp-String-1 := '±§#$%^&+={[}];<,>?`|"'
-       &Tmp-String-2 := '™¥¤'
-       &Tmp-String-3 := '=C2=B1=C2=A7=23=24=25=5E=26=2B=3D=7B=5B=7D=5D=3B=3C=2C=3E=3F=60=7C=22'
-       &Tmp-String-4 := '=E2=84=A2=C2=A5=C2=A4'
-       &Tmp-String-5 := '=40=61=62=63=64=65=66=67'
-
-       # Mixture of safe and unsafe chars
-       &Tmp-String-6 := 'ŒČÿ'
-       &Tmp-String-7 := 'Œ=C4=8Cÿ'
-
-       # = not followed by hex and without 2 following chars
-       &Tmp-String-8 := 'a=Az=y'
-}
+&Tmp-String-0 := '@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_: /'
+&Tmp-String-1 := '±§#$%^&+={[}];<,>?`|"'
+&Tmp-String-2 := '™¥¤'
+&Tmp-String-3 := '=C2=B1=C2=A7=23=24=25=5E=26=2B=3D=7B=5B=7D=5D=3B=3C=2C=3E=3F=60=7C=22'
+&Tmp-String-4 := '=E2=84=A2=C2=A5=C2=A4'
+&Tmp-String-5 := '=40=61=62=63=64=65=66=67'
+
+# Mixture of safe and unsafe chars
+&Tmp-String-6 := 'ŒČÿ'
+&Tmp-String-7 := 'Œ=C4=8Cÿ'
+
+# = not followed by hex and without 2 following chars
+&Tmp-String-8 := 'a=Az=y'
 
 if (<string>"%{escape:%{Tmp-String-0}}" != &Tmp-String-0) {
        test_fail
index c1f43921e4ed540779435a7db3f146a0dcdb4463..4eaea70b094459fadfd4f093db4c810573c7417b 100644 (file)
@@ -1,5 +1,5 @@
 #
-#  PRE: update if
+#  PRE: if
 #
 
 #
@@ -19,17 +19,16 @@ if ("%{expr: 1 + 2 * 3 + 4}" != 11) {
 #
 #  attribute references
 #
-update request {
-       &Tmp-Integer-0 = 1
-       &Tmp-Integer-1 = 3
-       &Tmp-Integer-2 = 4
-       &Tmp-Date-0 = "%l"
-}
+&Tmp-Integer-0 := 1
+&Tmp-Integer-1 := 3
+&Tmp-Integer-2 := 4
+&Tmp-Date-0 := "%l"
 
 if ("%{expr: 1 + 2 * &Tmp-Integer-1 + 4}" != 11) {
        test_fail
 }
 
+
 if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + 4)}" != 15) {
        test_fail
 }
index 0762b167f60cab1715f213571cd29e9edb44ae6c..3eb97c29f56c3fcb8cb2be9bdeadd70ddcc0cd17 100644 (file)
@@ -1,9 +1,5 @@
-update {
-        &request.Packet-Type !* ANY
-}
+&request -= &Packet-Type
 
 foreach &Filter-Id {
-       update reply {
-              &Called-Station-Id += "%{Foreach-Variable-0}"
-       }
+       &Called-Station-Id += "%{Foreach-Variable-0}"
 }
index 6fadd740e26e8372ec77a1b1007884d5ca1a0d2d..d0f52a40044b66a834f02e3e45e72ba4da72fa8d 100644 (file)
@@ -1,30 +1,32 @@
 #
-# PRE: update
+# PRE: if
 #
-update request {
-       &Tmp-String-0           := '9870'
-       &Tmp-Octets-0           := 0x39383731
-       &Tmp-IP-Address-0       := 57.56.55.50
-       &Tmp-Integer-0          := 959985460
-       &Tmp-Cast-IfId          := '0000:0000:3938:3737'
-       &Tmp-Cast-IPv6Addr      := '::3938:3738'
-       &Tmp-Cast-IPv6Prefix    := '::3938:3739/128'
-       &Tmp-Cast-Byte          := 58
-       &Tmp-Cast-Short         := 14139
-       &Tmp-Cast-Ether         := 00:00:39:38:37:3c
-       &Tmp-Cast-Integer64     := 1152921505566832445
-       &Tmp-Cast-IPv4Prefix    := 57.56.55.62/32
-}
-
-update request {
-       &Tmp-String-0           := "%{hex:%{Tmp-String-0}}"
-       &Tmp-String-1           := "%{hex:%{Tmp-Octets-0}}"
-       &Tmp-String-2           := "%{hex:%{Tmp-IP-Address-0}}"
-       &Tmp-String-4           := "%{hex:%{Tmp-Integer-0}}"
-       &Tmp-String-6           := "%{hex:%{Tmp-Cast-Ifid}}"
-       &Tmp-String-7           := "%{hex:%{Tmp-Cast-IPv6Addr}}"
-       &Tmp-String-8           := "%{hex:%{Tmp-Cast-IPv6Prefix}}"
-       &Tmp-String-9           := "%{hex:%{Tmp-Cast-Byte}}"
+&request <= {
+       &Tmp-String-0           = '9870'
+       &Tmp-Octets-0           = 0x39383731
+       &Tmp-IP-Address-0       = 57.56.55.50
+       &Tmp-Integer-0          = 959985460
+       &Tmp-Cast-IfId          = '0000:0000:3938:3737'
+       &Tmp-Cast-IPv6Addr      = '::3938:3738'
+       &Tmp-Cast-IPv6Prefix    = '::3938:3739/128'
+       &Tmp-Cast-Byte          = 58
+       &Tmp-Cast-Short         = 14139
+       &Tmp-Cast-Ether         = 00:00:39:38:37:3c
+       &Tmp-Cast-Integer64     = 1152921505566832445
+       &Tmp-Cast-IPv4Prefix    = 57.56.55.62/32
+}
+
+ok  # break up edit sections
+
+&request <= {
+       &Tmp-String-0           = "%{hex:%{Tmp-String-0}}"
+       &Tmp-String-1           = "%{hex:%{Tmp-Octets-0}}"
+       &Tmp-String-2           = "%{hex:%{Tmp-IP-Address-0}}"
+       &Tmp-String-4           = "%{hex:%{Tmp-Integer-0}}"
+       &Tmp-String-6           = "%{hex:%{Tmp-Cast-Ifid}}"
+       &Tmp-String-7           = "%{hex:%{Tmp-Cast-IPv6Addr}}"
+       &Tmp-String-8           = "%{hex:%{Tmp-Cast-IPv6Prefix}}"
+       &Tmp-String-9           = "%{hex:%{Tmp-Cast-Byte}}"
 }
 
 # String
@@ -67,12 +69,12 @@ if (&Tmp-String-9 != '3a') {
        test_fail
 }
 
-update request {
-       &Tmp-String-0        := "%{hex:%{Tmp-Cast-Short}}"
-       &Tmp-String-1        := "%{hex:%{Tmp-Cast-Ether}}"
-       &Tmp-String-2        := "%{hex:%{Tmp-Cast-Integer64}}"
-       &Tmp-String-3        := "%{hex:%{Tmp-Cast-IPv4Prefix}}"
-       &Tmp-String-4        := "%{hex:%{Tmp-Octets-9}}"
+&request <= {
+       &Tmp-String-0        = "%{hex:%{Tmp-Cast-Short}}"
+       &Tmp-String-1        = "%{hex:%{Tmp-Cast-Ether}}"
+       &Tmp-String-2        = "%{hex:%{Tmp-Cast-Integer64}}"
+       &Tmp-String-3        = "%{hex:%{Tmp-Cast-IPv4Prefix}}"
+       &Tmp-String-4        = "%{hex:%{Tmp-Octets-9}}"
 }
 
 # short