]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Fix JSON 64bit integer tests
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 7 Dec 2021 03:23:02 +0000 (22:23 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 7 Dec 2021 03:23:02 +0000 (22:23 -0500)
raddb/policy.d/time
share/dictionary/freeradius/dictionary.freeradius.internal
src/tests/keywords/xlat-double-alternation
src/tests/keywords/xlat-integer
src/tests/modules/json/eval.unlang
src/tests/unit/condition/base.txt

index 308d8fa718413d3f1dad8f752fb3a3b70c3aac00..709f267cda8d3925cbcd1f31cf2af41d1fff6249 100644 (file)
@@ -1,18 +1,18 @@
 # Returns the current epoch time in ms
 #
-# Sets Tmp-Integer64-0 with the current epoch time in ms
+# Sets Tmp-uint64-0 with the current epoch time in ms
 time_current_ms {
        update request {
-               Tmp-Integer64-0 := "%{expr:(%c*1000) + (%C/1000)}"
+               Tmp-uint64-0 := "%{expr:(%c*1000) + (%C/1000)}"
        }
 }
 
 # Returns elapsed time in ms since time_current_ms
 #
-# Sets Tmp-Integer64-1 with number of milliseconds
+# Sets Tmp-uint64-1 with number of milliseconds
 time_elapsed_ms {
        update request {
-               Tmp-Integer64-1 := "%{expr:(%c*1000) + (%C/1000) - %{Tmp-Integer64-0}}"
+               Tmp-uint64-1 := "%{expr:(%c*1000) + (%C/1000) - %{Tmp-uint64-0}}"
        }
 }
 
index 3f85dd9badb5755468fc0031520383f7cee00088..6b4b8dcbb9e5b0c8d8035238e94ddd99d8879ec9 100644 (file)
@@ -209,8 +209,8 @@ ATTRIBUTE   MS-CHAP-New-NT-Password                 1137    octets
 
 ATTRIBUTE      Called-Station-SSID                     1139    string
 
-ATTRIBUTE      Acct-Input-Octets64                     1148    integer64
-ATTRIBUTE      Acct-Output-Octets64                    1149    integer64
+ATTRIBUTE      Acct-Input-Octets64                     1148    uint64
+ATTRIBUTE      Acct-Output-Octets64                    1149    uint64
 
 ATTRIBUTE      FreeRADIUS-Client-IP-Prefix             1150    ipv4prefix
 ATTRIBUTE      FreeRADIUS-Client-IPv6-Prefix           1151    ipv6prefix
@@ -362,33 +362,44 @@ ATTRIBUTE Tmp-Date-9                              1759    date
 #  Attributes 1850 through 1850 + FR_TYPE_MAX are reserved.
 #
 
-ATTRIBUTE      Tmp-Integer64-0                         1760    integer64
-ATTRIBUTE      Tmp-Integer64-1                         1761    integer64
-ATTRIBUTE      Tmp-Integer64-2                         1762    integer64
-ATTRIBUTE      Tmp-Integer64-3                         1763    integer64
-ATTRIBUTE      Tmp-Integer64-4                         1764    integer64
-ATTRIBUTE      Tmp-Integer64-5                         1765    integer64
-ATTRIBUTE      Tmp-Integer64-6                         1766    integer64
-ATTRIBUTE      Tmp-Integer64-7                         1767    integer64
-ATTRIBUTE      Tmp-Integer64-8                         1768    integer64
-ATTRIBUTE      Tmp-Integer64-9                         1769    integer64
-
-ATTRIBUTE      Tmp-Signed-0                            1770    signed
-ATTRIBUTE      Tmp-Signed-1                            1771    signed
-ATTRIBUTE      Tmp-Signed-2                            1772    signed
-ATTRIBUTE      Tmp-Signed-3                            1773    signed
-ATTRIBUTE      Tmp-Signed-4                            1774    signed
-ATTRIBUTE      Tmp-Signed-5                            1775    signed
-ATTRIBUTE      Tmp-Signed-6                            1776    signed
-ATTRIBUTE      Tmp-Signed-7                            1777    signed
-ATTRIBUTE      Tmp-Signed-8                            1778    signed
-ATTRIBUTE      Tmp-Signed-9                            1779    signed
-
-ATTRIBUTE      Tmp-Ethernet-0                          1780    ether
-ATTRIBUTE      Tmp-Ethernet-1                          1781    ether
-ATTRIBUTE      Tmp-Ethernet-2                          1782    ether
-ATTRIBUTE      Tmp-Ethernet-3                          1783    ether
-ATTRIBUTE      Tmp-Ethernet-4                          1784    ether
+ATTRIBUTE      Tmp-uint64-0                            1760    uint64
+ATTRIBUTE      Tmp-uint64-1                            1761    uint64
+ATTRIBUTE      Tmp-uint64-2                            1762    uint64
+ATTRIBUTE      Tmp-uint64-3                            1763    uint64
+ATTRIBUTE      Tmp-uint64-4                            1764    uint64
+ATTRIBUTE      Tmp-uint64-5                            1765    uint64
+ATTRIBUTE      Tmp-uint64-6                            1766    uint64
+ATTRIBUTE      Tmp-uint64-7                            1767    uint64
+ATTRIBUTE      Tmp-uint64-8                            1768    uint64
+ATTRIBUTE      Tmp-uint64-9                            1769    uint64
+
+ATTRIBUTE      Tmp-int64-0                             1770    int64
+ATTRIBUTE      Tmp-int64-1                             1771    int64
+ATTRIBUTE      Tmp-int64-2                             1772    int64
+ATTRIBUTE      Tmp-int64-3                             1773    int64
+ATTRIBUTE      Tmp-int64-4                             1774    int64
+ATTRIBUTE      Tmp-int64-5                             1775    int64
+ATTRIBUTE      Tmp-int64-6                             1776    int64
+ATTRIBUTE      Tmp-int64-7                             1777    int64
+ATTRIBUTE      Tmp-int64-8                             1778    int64
+ATTRIBUTE      Tmp-int64-9                             1779    int64
+
+ATTRIBUTE      Tmp-Signed-0                            1780    signed
+ATTRIBUTE      Tmp-Signed-1                            1781    signed
+ATTRIBUTE      Tmp-Signed-2                            1782    signed
+ATTRIBUTE      Tmp-Signed-3                            1783    signed
+ATTRIBUTE      Tmp-Signed-4                            1784    signed
+ATTRIBUTE      Tmp-Signed-5                            1785    signed
+ATTRIBUTE      Tmp-Signed-6                            1786    signed
+ATTRIBUTE      Tmp-Signed-7                            1787    signed
+ATTRIBUTE      Tmp-Signed-8                            1788    signed
+ATTRIBUTE      Tmp-Signed-9                            1789    signed
+
+ATTRIBUTE      Tmp-Ethernet-0                          1790    ether
+ATTRIBUTE      Tmp-Ethernet-1                          1791    ether
+ATTRIBUTE      Tmp-Ethernet-2                          1792    ether
+ATTRIBUTE      Tmp-Ethernet-3                          1793    ether
+ATTRIBUTE      Tmp-Ethernet-4                          1794    ether
 
 ATTRIBUTE      Tmp-Float-0                             1880    float32
 
index dc8dfd31a1ccd0510371318fd4e1a3777d305156..986069067221cabbb01c9a9bb36cac888e8dae36 100644 (file)
@@ -4,10 +4,10 @@
 
 # Regression test for double consecutive alternations
 update request {
-       &Tmp-Integer64-0 := "%{%{Acct-Input-Octets}:-2}%{%{Acct-Input-Gigawords}:-1}"
+       &Tmp-uint64-0 := "%{%{Acct-Input-Octets}:-2}%{%{Acct-Input-Gigawords}:-1}"
 }
 
-if (&Tmp-Integer64-0 != 21) {
+if (&Tmp-uint64-0 != 21) {
        fail
 }
 
index 489c54075ba32b7eaa6b06ed27cced6637028fa2..1194ed2b252240fa0d43e432828ef545b793cb0d 100644 (file)
@@ -31,9 +31,9 @@ if ((<integer>&Tmp-String-0 != &Tmp-Integer-1) || (&Tmp-Integer-1 != 9870)) {
 
 # String - network order representation of a 8 char string
 update request {
-       &Tmp-Integer64-0 := "%(integer:%{Tmp-String-1})"
+       &Tmp-uint64-0 := "%(integer:%{Tmp-String-1})"
 }
-if ((<integer64>&Tmp-String-1 != &Tmp-Integer64-0) || (&Tmp-Integer64-0 != 98709870)) {
+if ((<integer64>&Tmp-String-1 != &Tmp-uint64-0) || (&Tmp-uint64-0 != 98709870)) {
        test_fail
 }
 
@@ -59,17 +59,17 @@ if (&Tmp-Integer-1 != 959985457) {
 
 # Octets - network order representation of a 8 byte octet string
 update request {
-       &Tmp-Integer64-0 := "%(integer:%{Tmp-Octets-1})"
+       &Tmp-uint64-0 := "%(integer:%{Tmp-Octets-1})"
 }
 
 #
 #  Disabled until xlats can return binary data
 #
-#if (&Tmp-Octets-1 != "%{hex:Tmp-Integer64-0}") {
+#if (&Tmp-Octets-1 != "%{hex:Tmp-uint64-0}") {
 #      test_fail
 #}
 
-if (&Tmp-Integer64-0 != 4123106143410599729) {
+if (&Tmp-uint64-0 != 4123106143410599729) {
        test_fail
 }
 
@@ -123,7 +123,7 @@ if (&Tmp-String-8 != '959985465') {
 update request {
        &Tmp-String-0        := "%(integer:%{Tmp-Cast-Byte})"
        &Tmp-String-1        := "%(integer:%{Tmp-Cast-Short})"
-       &Tmp-Integer64-2     := "%(integer:%{Tmp-Cast-Ether})"
+       &Tmp-uint64-2     := "%(integer:%{Tmp-Cast-Ether})"
        &Tmp-String-3        := "%(integer:%{Tmp-Cast-Integer64})"
        &Tmp-String-4        := "%(integer:%{Tmp-Cast-IPv4Prefix})"
 }
@@ -139,7 +139,7 @@ if (&Tmp-String-1 != '14139') {
 }
 
 # ethernet
-if (&Tmp-Integer64-2 != 959985468) {
+if (&Tmp-uint64-2 != 959985468) {
        test_fail
 }
 
@@ -148,7 +148,7 @@ if (&Tmp-Integer64-2 != 959985468) {
 #  with the lowest octet of the integer mapping to the right-most
 #  ethernet octet (in network order)
 #
-if (<ether>&Tmp-Integer64-2 != &Tmp-Cast-Ether) {
+if (<ether>&Tmp-uint64-2 != &Tmp-Cast-Ether) {
        test_fail
 }
 
index fc9f62d7010847620fd28145c46c7160068714b7..faedb8c1f07e7cd24cf79824f7d428fe5e8edf4a 100644 (file)
@@ -282,9 +282,7 @@ update request {
 map json &Tmp-String-0 {
        &Tmp-Integer-0 += '$.my_array[3::-3]'
 }
-if ((&Tmp-Integer-0[0] == 3) && (&Tmp-Integer-0[1] == 0) && !&Tmp-Integer-0[2]) {
-       test_pass
-} else {
+if ((&Tmp-Integer-0[0] != 3) || (&Tmp-Integer-0[1] != 0) || &Tmp-Integer-0[2]) {
        test_fail
 }
 update request {
@@ -386,9 +384,7 @@ redundant {
        }
        noop
 }
-if (noop || ((&Tmp-Integer-0 == 4294967295) || (&Tmp-Integer-0 == 2147483647))) {
-       test_pass
-} else {
+if (!noop && ((&Tmp-Integer-0 != 4294967295) && (&Tmp-Integer-0 != 2147483647))) {
        test_fail
 }
 
@@ -403,7 +399,40 @@ update request {
        &Tmp-Integer-0 !* ANY
 }
 
-# 33. Multiple array indicies
+# 33. Signed 64bit integers
+map json &Tmp-String-0 {
+       &Tmp-int64-0 := '$[0]'
+}
+if (&Tmp-int64-0 != 9223372036854775807) {
+       test_fail
+}
+update request {
+       &Tmp-int64-0 !* ANY
+}
+
+# 34. Signed 64bit integers
+map json &Tmp-String-0 {
+       &Tmp-int64-0 := '$[1]'
+}
+if (&Tmp-int64-0 != -9223372036854775807) {
+       test_fail
+}
+update request {
+       &Tmp-int64-0 !* ANY
+}
+
+# 35. Unsigned 64bit integers (not allowed by json so gets truncated)
+map json &Tmp-String-0 {
+       &Tmp-uint64-0 := '$[2]'
+}
+if (&Tmp-uint64-0 != 9223372036854775807) {
+       test_fail
+}
+update request {
+       &Tmp-uint64-0 !* ANY
+}
+
+# 36. Multiple array indicies
 map json &Tmp-String-0 {
        &Tmp-Signed-0 += '$[3][0,1]'
 }
@@ -414,7 +443,7 @@ update request {
        &Tmp-Signed-0 !* ANY
 }
 
-# 34. Path containing dynamic expansion
+# 37. Path containing dynamic expansion
 update request {
        &Tmp-Integer-2 := 0
 }
@@ -428,7 +457,7 @@ update request {
        &Tmp-Integer-0 !* ANY
 }
 
-# 35. An expanded field name with bad chars
+# 38. An expanded field name with bad chars
 update request {
        &Tmp-String-0 := "\
        {\
@@ -473,7 +502,7 @@ update request {
        }"
 }
 
-# 36. Recursive descent with field match
+# 39. Recursive descent with field match
 map json &Tmp-String-0 {
        &Tmp-String-1 += '$..bool'
 }
@@ -484,7 +513,7 @@ update request {
        &Tmp-String-1 !* ANY
 }
 
-# 37. Recursive descent with element match (2nd element in each array)
+# 40. Recursive descent with element match (2nd element in each array)
 map json &Tmp-String-0 {
        &Tmp-String-1 += '$..[1]'
 }
@@ -495,7 +524,7 @@ update request {
        &Tmp-String-1 !* ANY
 }
 
-# 38. Recursive descent with field then element match
+# 41. Recursive descent with field then element match
 map json &Tmp-String-0 {
        &Tmp-String-1 += '$..my_cats[2]'
 }
@@ -506,53 +535,4 @@ update request {
        &Tmp-String-1 !* ANY
 }
 
-#
-#  @todo - What's going on here?  The input json has an array as
-#  element 0, whicj is most definitely not a 64-bit integer.
-#
-if (0) {
-# 39. Unsigned 64bit integers
-map json &Tmp-String-0 {
-       &Tmp-Integer64-0 := '$[0]'
-}
-if (&Tmp-Integer64-0 != 9223372036854775807) {
-       test_fail
-}
-update request {
-       &Tmp-Integer64-0 !* ANY
-}
-
-# 40. Signed 64bit integers (not supported)
-redundant {
-       group {
-               map json &Tmp-String-0 {
-                       &Tmp-Integer64-0 := '$[1]'
-               }
-       }
-       ok
-}
-if (fail || &Tmp-Integer64-0) {
-       test_fail
-}
-update request {
-       &Tmp-Integer64-0 !* ANY
-}
-
-# 41. Signed 64bit integers (not supported)
-redundant {
-       group {
-               map json &Tmp-String-0 {
-                       &Tmp-Integer64-0 := '$[1]'
-               }
-       }
-       ok
-}
-if (fail || &Tmp-Integer64-0) {
-       test_fail
-}
-update request {
-       &Tmp-Integer64-0 !* ANY
-}
-}
-
 test_pass
index 067e9e4b55f6ac4e1c3f2466084c184063195f20..abd7ab8ef1613d1a90dfcf6d51289aaaae1671b2 100644 (file)
@@ -420,16 +420,16 @@ match <ipaddr>&Filter-Id == &Framed-IP-Address
 condition <ipaddr>127.0.0.1 == &Filter-Id
 match <ipaddr>&Filter-Id == 127.0.0.1
 
-condition &Tmp-Integer64-0 == &request.Foo-Stuff-Bar
-match &Tmp-Integer64-0 == &Foo-Stuff-Bar
+condition &Tmp-uint64-0 == &request.Foo-Stuff-Bar
+match &Tmp-uint64-0 == &Foo-Stuff-Bar
 
-condition &Tmp-Integer64-0 == &reply.Foo-Stuff-Bar
-match &Tmp-Integer64-0 == &reply.Foo-Stuff-Bar
+condition &Tmp-uint64-0 == &reply.Foo-Stuff-Bar
+match &Tmp-uint64-0 == &reply.Foo-Stuff-Bar
 
 #
 #  Casting attributes of different size
 #
-condition <ipaddr>&Tmp-Integer64-0 == &Framed-IP-Address
+condition <ipaddr>&Tmp-uint64-0 == &Framed-IP-Address
 match ERROR offset 8: Cannot cast type 'uint64' to 'ipaddr'
 
 #
@@ -441,8 +441,8 @@ condition <ipaddr>&PMIP6-Home-IPv4-HoA == &Framed-IP-Address
 match <ipaddr>&PMIP6-Home-IPv4-HoA == &Framed-IP-Address
 
 # but these are allowed
-condition <ether>&Tmp-Integer64-0 == "%{module: foo}"
-match <ether>&Tmp-Integer64-0 == "%{module: foo}"
+condition <ether>&Tmp-uint64-0 == "%{module: foo}"
+match <ether>&Tmp-uint64-0 == "%{module: foo}"
 
 condition <ipaddr>&Filter-Id == &Framed-IP-Address
 match <ipaddr>&Filter-Id == &Framed-IP-Address