From: Jorge Pereira Date: Thu, 1 Sep 2022 20:21:46 +0000 (-0300) Subject: More convert from 'update {....}' to 'edit' against src/tests/keywords (#4710) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1af837d69b0c455ef62acac809a9d56cb44f69a;p=thirdparty%2Ffreeradius-server.git More convert from 'update {....}' to 'edit' against src/tests/keywords (#4710) --- diff --git a/src/tests/keywords/paircmp b/src/tests/keywords/paircmp index c4a1f9c34e8..8c8cef0904d 100644 --- a/src/tests/keywords/paircmp +++ b/src/tests/keywords/paircmp @@ -21,7 +21,6 @@ else { # if (&Test-Paircmp == &NAS-Identifier) { success - } else { test_fail diff --git a/src/tests/keywords/pap-ssha2 b/src/tests/keywords/pap-ssha2 index ce3b4b938e4..53ad8f2741b 100644 --- a/src/tests/keywords/pap-ssha2 +++ b/src/tests/keywords/pap-ssha2 @@ -22,8 +22,8 @@ if ('${feature.tls}' != 'yes') { # # Hex encoded SSHA2-512 password # -update { - &control.Password.With-Header += "{ssha512}%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%{hex:%{Tmp-String-0}}" +&control += { + &Password.With-Header = "{ssha512}%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%{hex:%{Tmp-String-0}}" } pap.authorize @@ -39,22 +39,16 @@ if (reject) { # # Base64 encoded SSHA2-512 password # -update { - &control.Tmp-String-1 := "%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%{hex:%{Tmp-String-0}}" -} +&control.Tmp-String-1 := "%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%{hex:%{Tmp-String-0}}" # To Binary -update { - &control.Tmp-Octets-0 := "%{bin:%{control.Tmp-String-1}}" -} +&control.Tmp-Octets-0 := "%{bin:%{control.Tmp-String-1}}" # To Base64 -update { - &control.Tmp-String-1 := "%{base64:%{control.Tmp-Octets-0}}" -} +&control.Tmp-String-1 := "%{base64:%{control.Tmp-Octets-0}}" -update { - &control.Password.With-Header += "{ssha512}%{control.Tmp-String-1}" +&control += { + &Password.With-Header = "{ssha512}%{control.Tmp-String-1}" } pap.authorize @@ -70,22 +64,16 @@ if (reject) { # # Base64 of Base64 encoded SSHA2-512 password # -update { - &control.Tmp-String-1 := "%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%{hex:%{Tmp-String-0}}" -} +&control.Tmp-String-1 := "%{hex:%{sha2_512:%{User-Password}%{Tmp-String-0}}}%{hex:%{Tmp-String-0}}" # To Binary -update { - &control.Tmp-Octets-0 := "%{bin:%{control.Tmp-String-1}}" -} +&control.Tmp-Octets-0 := "%{bin:%{control.Tmp-String-1}}" # To Base64 -update { - &control.Tmp-String-1 := "{ssha512}%{base64:%{control.Tmp-Octets-0}}" -} +&control.Tmp-String-1 := "{ssha512}%{base64:%{control.Tmp-Octets-0}}" -update { - &control.Password.With-Header += "%{base64:%{control.Tmp-String-1}}" +&control += { + &Password.With-Header = "%{base64:%{control.Tmp-String-1}}" } pap.authorize @@ -101,9 +89,7 @@ if (reject) { # # Base64 of SHA2-384 password (in SHA2-Password) # -update control { - &control.Password.SHA2 := "%{hex:%{sha2_384:%{User-Password}}}" -} +&control.Password.SHA2 := "%{hex:%{sha2_384:%{User-Password}}}" pap.authorize pap.authenticate { @@ -120,9 +106,7 @@ if (reject) { # # Base64 of SHA2-256 password (in SHA2-256-Password) # -update control { - &control.Password.SHA2-256 := "%{hex:%{sha2_256:%{User-Password}}}" -} +&control.Password.SHA2-256 := "%{hex:%{sha2_256:%{User-Password}}}" pap.authorize pap.authenticate { @@ -137,9 +121,7 @@ if (reject) { # # Base64 of SHA2-224 password (in SHA2-224-Password - No hex armour) # -update control { - &control.Password.SHA2-224 := "%{sha2_224:%{User-Password}}" -} +&control.Password.SHA2-224 := "%{sha2_224:%{User-Password}}" pap.authorize pap.authenticate { diff --git a/src/tests/keywords/radius.conf b/src/tests/keywords/radius.conf index 0e5a771a649..5283b2f04b6 100644 --- a/src/tests/keywords/radius.conf +++ b/src/tests/keywords/radius.conf @@ -119,9 +119,7 @@ server default { } recv Access-Request { - update control { - &Password.Cleartext := 'hello' - } + &control.Password.Cleartext := "hello" # # Include the test file specified by the diff --git a/src/tests/keywords/sha2 b/src/tests/keywords/sha2 index c82bd44f4e8..029eaa8b90b 100644 --- a/src/tests/keywords/sha2 +++ b/src/tests/keywords/sha2 @@ -1,18 +1,14 @@ # # PRE: update if # -update { - &request.Tmp-String-0 := "This is a string\n" - &request.Tmp-Octets-0 := 0x000504030201 -} +&request.Tmp-String-0 := "This is a string\n" +&request.Tmp-Octets-0 := 0x000504030201 -update { - &request.Tmp-Octets-1 := "%{sha2_256:This is a string\n}" - &request.Tmp-Octets-2 := "%{sha2_256:%{Tmp-String-0}}" - &request.Tmp-Octets-3 := "%{sha2_256:%{request.Tmp-String-0}}" - &request.Tmp-Octets-4 := "%{sha2_256:%{request.Tmp-Octets-0}}" - &request.Tmp-Octets-5 := "%{sha2_256:%{request.Tmp-Octets-9}}" -} +&request.Tmp-Octets-1 := "%{sha2_256:This is a string\n}" +&request.Tmp-Octets-2 := "%{sha2_256:%{Tmp-String-0}}" +&request.Tmp-Octets-3 := "%{sha2_256:%{request.Tmp-String-0}}" +&request.Tmp-Octets-4 := "%{sha2_256:%{request.Tmp-Octets-0}}" +&request.Tmp-Octets-5 := "%{sha2_256:%{request.Tmp-Octets-9}}" # # Put "This is a string" into a file and call "sha2_256sum" on it. @@ -48,11 +44,9 @@ if (&request.Tmp-Octets-5 != 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca # SHA512 and SHA256 share common code paths, so the tests don't need to be # as exhaustive. # -update { - &request.Tmp-Octets-1 := "%{sha2_512:This is a string\n}" - &request.Tmp-Octets-2 := "%{sha2_512:%{Tmp-String-0}}" - &request.Tmp-Octets-3 := "%{sha2_512:%{request.Tmp-Octets-0}}" -} +&request.Tmp-Octets-1 := "%{sha2_512:This is a string\n}" +&request.Tmp-Octets-2 := "%{sha2_512:%{Tmp-String-0}}" +&request.Tmp-Octets-3 := "%{sha2_512:%{request.Tmp-Octets-0}}" if (&request.Tmp-Octets-1 != 0x56b57df5cce42d4e35c644649798ea23ec16f4f4626e78faf4d2d8f430ea349bcc28cd5532457c82f0aa66bf68988346039fe75b900a92ff94fd53993d45990f) { test_fail diff --git a/src/tests/keywords/truncation b/src/tests/keywords/truncation index dd6fc0b96a8..bd52e37d172 100644 --- a/src/tests/keywords/truncation +++ b/src/tests/keywords/truncation @@ -1,8 +1,7 @@ # cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-f0-9' | head -c # 8192 - 0x (2) - '' (2) there are unlikely to be any static buffers this big outside of the conffile parser -update request { - &Tmp-Octets-0 := 0x\ +&Tmp-Octets-0 := 0x\ d8abccb7834711af1de1812be2579febe946f5d7beef6fa5c7074c0cb917e9b91e23e14b016f27610097c16c0e0fad88176e077b24198c770746159\ 05b8810d1c8b774d98889fa5c6027cde5e9c56dd4f7c48298c7713aeca5ba5dcfd506032ad05b1396f50e825b633d5a6af0dce6181b640287e03a65\ 8734df46a86341556f28455b3f377313a5a2ac8c8267b8a5de559b95f9b493a68b9e0278485f9e3914d702b2b7b90ee85ff393461f197386d09b836\ @@ -72,7 +71,6 @@ fc813bd2e58c6d0dfd951570dbff4b5e73ce547cd100ab320b6944e887d611b3425bfcdf3bfa852f fc6afab4c5dd4aae4a2e6f0293c15278d557c2925acba90c73eeea09ebb95f0d469aa77ae983a0e69dacd55bd8a7e78a41df5227de35af05127fa3b\ a02f4a3ab98d75992d68a15d393387fe9ef01041569570ad6fe884764e55567311bcacfcffae76554dcfebfde607500f50ec85f589eaade607500f5\ 3ae4bcef324b9a3f47ba5c835b54a010ca42f3b9cc5368278c148c9b02ea8c4c9f244fd49f -} # Actual length of octet string is 4083 bytes if (%(length:%{Tmp-Octets-0}) != 4083) { diff --git a/src/tests/keywords/unknown b/src/tests/keywords/unknown index a9bf0cb3fec..edd40f54e1a 100644 --- a/src/tests/keywords/unknown +++ b/src/tests/keywords/unknown @@ -8,9 +8,7 @@ update request { # # Check that a known but malformed attr is malformed # -update request { - &26.24757.84.9.5.7 = 0xab -} +&request.26.24757.84.9.5.7 := 0xab if (&26.24757.84.9.5.7 != 0xab) { test_fail @@ -19,9 +17,7 @@ if (&26.24757.84.9.5.7 != 0xab) { # # Check that an unknown attr is OK # -update request { - &26.24757.84.9.5.15 = 0xabcdef -} +&request.26.24757.84.9.5.15 := 0xabcdef if (&26.24757.84.9.5.15 != 0xabcdef) { test_fail @@ -39,9 +35,7 @@ if (&26.11344.1 != 127.0.0.2) { test_fail } -update request { - &26.11344.1 := 0x7f000001 -} +&request.26.11344.1 := 0x7f000001 if (&Vendor-Specific.FreeRADIUS.Proxied-To == 127.0.0.2) { test_fail @@ -59,9 +53,7 @@ if (&26.11344.1 != 127.0.0.1) { test_fail } -update request { - &26.66.1 = 0x01020304 -} +&request.26.66.1 = 0x01020304 if (&26.66.1 != 0x01020304) { test_fail