From: Alan T. DeKok Date: Sun, 24 Jul 2022 13:55:26 +0000 (-0400) Subject: move to using new edit syntax X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8343426e4f6abcabf49003cfd166e0059fb9d48d;p=thirdparty%2Ffreeradius-server.git move to using new edit syntax --- diff --git a/src/tests/keywords/action-not-end-error b/src/tests/keywords/action-not-end-error index 890eded0c5b..4deca1879fa 100644 --- a/src/tests/keywords/action-not-end-error +++ b/src/tests/keywords/action-not-end-error @@ -1,5 +1,5 @@ # -# PRE: update +# PRE: if # # Static if condition # @@ -8,9 +8,7 @@ if (1) { # We're not running the 'pap' module, so # we have to set this ourselves. # - update control { - &Auth-Type := pap - } + &control.Auth-Type := pap # not at the end of a section actions { # ERROR @@ -20,4 +18,4 @@ if (1) { ok } -test_fail +test_fail \ No newline at end of file diff --git a/src/tests/keywords/action-return b/src/tests/keywords/action-return index 8c38cd396e5..2e5ea80796d 100644 --- a/src/tests/keywords/action-return +++ b/src/tests/keywords/action-return @@ -1,5 +1,5 @@ # -# PRE: update +# PRE: if # # Static if condition # @@ -10,9 +10,7 @@ if (1) { # We're not running the 'pap' module, so # we have to set this ourselves. # - update control { - &Auth-Type := pap - } + &control.Auth-Type := pap actions { ok = return diff --git a/src/tests/keywords/array b/src/tests/keywords/array index d252ff375b4..700fed0bc6d 100644 --- a/src/tests/keywords/array +++ b/src/tests/keywords/array @@ -3,13 +3,15 @@ # # Tests for dereferencing the Nth attribute # -update request { - &Class := 0x01020304 - &Class += 0x05060708 - &Class += 0x090a0b0c +&request += { + &Class = 0x01020304, + &Class = 0x05060708, + &Class = 0x090a0b0c, } -debug_request +if (%{Class[#]} != 3) { + test_fail +} if (&Class[0] != 0x01020304) { test_fail diff --git a/src/tests/keywords/base64 b/src/tests/keywords/base64 index e2a7e36bc3f..d96f8ed57a0 100644 --- a/src/tests/keywords/base64 +++ b/src/tests/keywords/base64 @@ -1,31 +1,35 @@ # # PRE: hex # -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 := "%{base64:%{Tmp-String-0}}" - &Tmp-String-1 := "%{base64:%{Tmp-Octets-0}}" - &Tmp-String-2 := "%{base64:%{Tmp-IP-Address-0}}" - &Tmp-String-4 := "%{base64:%{Tmp-Integer-0}}" - &Tmp-String-6 := "%{base64:%{Tmp-Cast-Ifid}}" - &Tmp-String-7 := "%{base64:%{Tmp-Cast-IPv6Addr}}" - &Tmp-String-8 := "%{base64:%{Tmp-Cast-IPv6Prefix}}" - &Tmp-String-9 := "%{base64:%{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 + +&request <= { + &Tmp-String-0 = "%{base64:%{Tmp-String-0}}" + &Tmp-String-1 = "%{base64:%{Tmp-Octets-0}}" + &Tmp-String-2 = "%{base64:%{Tmp-IP-Address-0}}" + &Tmp-String-4 = "%{base64:%{Tmp-Integer-0}}" + &Tmp-String-6 = "%{base64:%{Tmp-Cast-Ifid}}" + &Tmp-String-7 = "%{base64:%{Tmp-Cast-IPv6Addr}}" + &Tmp-String-8 = "%{base64:%{Tmp-Cast-IPv6Prefix}}" + &Tmp-String-9 = "%{base64:%{Tmp-Cast-Byte}}" +} + +%(debug_attr:request[*]) # String - bin 0x39383730 if (&Tmp-String-0[0] != 'OTg3MA==') { @@ -67,11 +71,11 @@ if (&Tmp-String-9[0] != 'Og==') { test_fail } -update request { - &Tmp-String-0 := "%{base64:%{Tmp-Cast-Short}}" - &Tmp-String-1 := "%{base64:%{Tmp-Cast-Ether}}" - &Tmp-String-2 := "%{base64:%{Tmp-Cast-Integer64}}" - &Tmp-String-3 := "%{base64:%{Tmp-Cast-IPv4Prefix}}" +&request <= { + &Tmp-String-0 = "%{base64:%{Tmp-Cast-Short}}" + &Tmp-String-1 = "%{base64:%{Tmp-Cast-Ether}}" + &Tmp-String-2 = "%{base64:%{Tmp-Cast-Integer64}}" + &Tmp-String-3 = "%{base64:%{Tmp-Cast-IPv4Prefix}}" } # short - bin 0x373b @@ -94,9 +98,9 @@ if (&Tmp-String-3[0] != 'IDk4Nz4=') { test_fail } -update request { - &Tmp-Octets-0 := "%{base64decode:Zm9v}" - &Tmp-Octets-1 := "%{base64decode:AIAAAAAAAAAAAAAAAAA5ODc5}" +&request <= { + &Tmp-Octets-0 = "%{base64decode:Zm9v}" + &Tmp-Octets-1 = "%{base64decode:AIAAAAAAAAAAAAAAAAA5ODc5}" } if (&Tmp-Octets-0 != "foo") { @@ -108,16 +112,16 @@ if (&Tmp-Octets-1 != 0x008000000000000000000000000039383739) { } # Regression tests -update request { - &Tmp-Octets-0 := %{base64decode:5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK} +&request <= { + &Tmp-Octets-0 = %{base64decode:5RNqNl8iYLbkCc7JhR8as4TtDDCX6otuuWtcja8rITUyx9zrnHSe9tTHGmKK} } if (&Tmp-Octets-0 != 0xe5136a365f2260b6e409cec9851f1ab384ed0c3097ea8b6eb96b5c8daf2b213532c7dceb9c749ef6d4c71a628a) { test_fail } -update request { - &Tmp-Octets-0 := "%{base64decode:eHfXPKZ+2iv9cnMV1MOmE/moYYA1Uk5xTmw4aVlMYmtDYzdKaFI4YXM0VHRERENYNm90dXVXdGNqYThySVRVeXg5enJuSFNlOXRUSEdtS0s=}" +&request <= { + &Tmp-Octets-0 = "%{base64decode:eHfXPKZ+2iv9cnMV1MOmE/moYYA1Uk5xTmw4aVlMYmtDYzdKaFI4YXM0VHRERENYNm90dXVXdGNqYThySVRVeXg5enJuSFNlOXRUSEdtS0s=}" } if (&Tmp-Octets-0 != 0x7877d73ca67eda2bfd727315d4c3a613f9a8618035524e714e6c3869594c626b4363374a685238617334547444444358366f7475755774636a6138724954557978397a726e48536539745448476d4b4b) { diff --git a/src/tests/keywords/call b/src/tests/keywords/call index 13685528c92..fd852c422e1 100644 --- a/src/tests/keywords/call +++ b/src/tests/keywords/call @@ -1,10 +1,8 @@ # -# PRE: update +# PRE: if # call second { - update reply { - &Reply-Message += 'call second post' - } + &reply.Reply-Message += 'call second post' } if (!&reply.Reply-Message) { @@ -19,8 +17,6 @@ if (&reply.Reply-Message[1] != "call second post") { test_fail } -update reply { - &Reply-Message !* ANY -} +&reply -= &Reply-Message success diff --git a/src/tests/keywords/call-empty b/src/tests/keywords/call-empty index 1e523407aae..de8a0b7320c 100644 --- a/src/tests/keywords/call-empty +++ b/src/tests/keywords/call-empty @@ -1,5 +1,5 @@ # -# PRE: update +# PRE: if call # # Test empty call section @@ -14,8 +14,6 @@ if (&reply.Reply-Message[0] != "call second") { test_fail } -update reply { - &Reply-Message !* ANY -} +&reply -= &Reply-Message success diff --git a/src/tests/keywords/call-loop b/src/tests/keywords/call-loop index 6c537e505eb..23c35b1d719 100644 --- a/src/tests/keywords/call-loop +++ b/src/tests/keywords/call-loop @@ -1,5 +1,5 @@ # -# PRE: update +# PRE: # # Doesn't yet pass because we need to stop processing diff --git a/src/tests/keywords/case-empty-string b/src/tests/keywords/case-empty-string index 97d83b96809..209697abdf3 100644 --- a/src/tests/keywords/case-empty-string +++ b/src/tests/keywords/case-empty-string @@ -1,8 +1,6 @@ # PRE: switch # -update request { - &Filter-Id := "" -} +&request.Filter-Id := "" switch &Filter-Id { case "" { @@ -10,14 +8,10 @@ switch &Filter-Id { } case "doug" { - update reply { - &Filter-Id := "doug" - } + &reply.Filter-Id := "doug" } case { - update reply { - &Filter-Id := "default" - } + &reply.Filter-Id := "default" } } diff --git a/src/tests/keywords/cast-byte b/src/tests/keywords/cast-byte index 0ffd6bc1681..496b854c593 100644 --- a/src/tests/keywords/cast-byte +++ b/src/tests/keywords/cast-byte @@ -1,22 +1,16 @@ # -# PRE: update if +# PRE: if # -update { - &request.Class := 0xad -} +&request.Class := 0xad if (&Class == 173) { success } if (&Class < 173) { - update reply { - &Filter-Id += "wrong" - } + test_fail } if (&Class > 173) { - update reply { - &Filter-Id += "wrong" - } + test_fail } diff --git a/src/tests/keywords/cast-integer b/src/tests/keywords/cast-integer index ccc2f638a11..9b111f94db9 100644 --- a/src/tests/keywords/cast-integer +++ b/src/tests/keywords/cast-integer @@ -1,22 +1,16 @@ # -# PRE: update if +# PRE: if # -update { - &request.Class := 0x00000101 -} +&request.Class := 0x00000101 if (&Class[0] == 257) { success } if (&Class[0] < 256) { - update reply { - &Filter-Id += "wrong" - } + test_fail } if (&Class[0] > 257) { - update reply { - &Filter-Id += "wrong" - } + test_fail } diff --git a/src/tests/keywords/cast-ipaddr b/src/tests/keywords/cast-ipaddr index b5f3e85239c..4479480b57e 100644 --- a/src/tests/keywords/cast-ipaddr +++ b/src/tests/keywords/cast-ipaddr @@ -1,14 +1,10 @@ # # PRE: update if redundant # -update { - &request.NAS-IP-Address := 127.0.0.1 - &request.Tmp-Integer-0 := 0x7f000001 -} +&request.NAS-IP-Address := 127.0.0.1 +&request.Tmp-Integer-0 := 0x7f000001 -update request { - &Tmp-String-0[0] := &NAS-IP-Address -} +&Tmp-String-0 := &NAS-IP-Address if (&Tmp-Integer-0[0] != &NAS-IP-Address) { test_fail diff --git a/src/tests/keywords/cast-short b/src/tests/keywords/cast-short index 4caddc631fa..c7c0bee88c4 100644 --- a/src/tests/keywords/cast-short +++ b/src/tests/keywords/cast-short @@ -1,22 +1,16 @@ # -# PRE: update if +# PRE: if # -update { - &request.Class := 0x0101 -} +&request.Class := 0x0101 if (&Class == 257) { success } if (&Class < 256) { - update reply { - &Filter-Id += "wrong" - } + test_fail } if (&Class > 257) { - update reply { - &Filter-Id += "wrong" - } + test_fail } diff --git a/src/tests/keywords/cmp b/src/tests/keywords/cmp index 88df349dbdf..25e002ffa04 100644 --- a/src/tests/keywords/cmp +++ b/src/tests/keywords/cmp @@ -1,10 +1,8 @@ # -# PRE: update +# PRE: # -update request { - &Called-Station-Id := "This is a test" - &Calling-Station-Id := "This is a test" -} +&request.Called-Station-Id := "This is a test" +&request.Calling-Station-Id := "This is a test" # # Check attribute references diff --git a/src/tests/keywords/comments b/src/tests/keywords/comments index 7b4a3df6d91..d504de15987 100644 --- a/src/tests/keywords/comments +++ b/src/tests/keywords/comments @@ -1,5 +1,5 @@ # -# PRE: update if +# PRE: if # # One comment @@ -18,10 +18,8 @@ update { #}'{ Opening block with extra special chars {} '" update { &request.Tmp-String-0 := 'candy' } # Comment after unicorn block -update request { - &request.Reply-Message += 'I am #literally a comment #' - &request.Reply-Message += "I am #literally a comment #" -} +&request.Reply-Message += 'I am #literally a comment #' +&request.Reply-Message += "I am #literally a comment #" if (&request.Tmp-String-0 != 'candy') { test_fail diff --git a/src/tests/keywords/concat b/src/tests/keywords/concat index 78649a42656..ab22ed785d9 100644 --- a/src/tests/keywords/concat +++ b/src/tests/keywords/concat @@ -1,22 +1,22 @@ # -# PRE: update if +# PRE: if # -update { - &request.Packet-Type !* ANY -} +&request -= &Packet-Type -update { - &request.Tmp-String-0 := "ab c" - &request.Tmp-String-0 += "de fg" - &request.Tmp-Integer-0 := 123 +&request += { + &Tmp-String-0 = "ab c" + &Tmp-String-0 = "de fg" + &Tmp-Integer-0 = 123 } -update { - &request.Tmp-String-1 := "%(concat:%{request[*]} ', ')" - &request.Tmp-String-2 := "%(concat:%{Tmp-String-0[*]} ', ')" - &request.Tmp-String-3 := "%(concat:%{Tmp-String-0[*]})" - &request.Tmp-String-4 := "%(concat:%{Tmp-String-0[*]} ,)" - &request.Tmp-String-5 := "%(concat:%{Tmp-String-0[*]} |-)" +ok # separate updates + +&request += { + &Tmp-String-1 = "%(concat:%{request[*]} ', ')" + &Tmp-String-2 = "%(concat:%{Tmp-String-0[*]} ', ')" + &Tmp-String-3 = "%(concat:%{Tmp-String-0[*]})" + &Tmp-String-4 = "%(concat:%{Tmp-String-0[*]} ,)" + &Tmp-String-5 = "%(concat:%{Tmp-String-0[*]} |-)" } if (&request.Tmp-String-1 != "bob, hello, ab c, de fg, 123") { diff --git a/src/tests/keywords/edit b/src/tests/keywords/edit index 5c9c44ac895..a2be2d11929 100644 --- a/src/tests/keywords/edit +++ b/src/tests/keywords/edit @@ -20,5 +20,4 @@ if (&Tmp-Integer-0 != 15) { test_fail } - success diff --git a/src/tests/keywords/ethernet b/src/tests/keywords/ethernet index 30160f57a3c..788a150b785 100644 --- a/src/tests/keywords/ethernet +++ b/src/tests/keywords/ethernet @@ -1,7 +1,7 @@ -update request { - &Tmp-Ethernet-0 := "00:11:22:33:44:54" - &Tmp-Ethernet-0 += "00:11:22:33:44:55" - &Tmp-Octets-0 := 0x001122334456 +&request += { + &Tmp-Ethernet-0 = 00:11:22:33:44:54, + &Tmp-Ethernet-0 = 00:11:22:33:44:55, + &Tmp-Octets-0 = 0x001122334456, } if (&Tmp-Ethernet-0[0] != 00:11:22:33:44:54) { @@ -12,26 +12,24 @@ if (&Tmp-Ethernet-0[1] != 00:11:22:33:44:55) { test_fail } -update request { - &Tmp-Ethernet-0 += &Tmp-Octets-0[0] +&request += { + &Tmp-Ethernet-0 = &Tmp-Octets-0[0] } if (&Tmp-Ethernet-0[2] != 00:11:22:33:44:56) { test_fail } -# NULL assignment -group { - update request { - &Tmp-Ethernet-0 += "%{Tmp-Ethernet-1[42]}" - } +# invalid assignment +&request += { + &Tmp-Ethernet-0 = %{Tmp-Ethernet-1[42]} +} - actions { - fail = 1 - } +if (&request.Module-Failure-Message != "No value found for assignment") { + test_fail } -if (!fail) { +if (%{request.Tmp-Ethernet-0[#]} != 3) { test_fail }