From: Arran Cudbard-Bell Date: Tue, 7 Dec 2021 03:23:02 +0000 (-0500) Subject: Fix JSON 64bit integer tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6569e6766359f7c9b47cf924fe20b978857d1bb6;p=thirdparty%2Ffreeradius-server.git Fix JSON 64bit integer tests --- diff --git a/raddb/policy.d/time b/raddb/policy.d/time index 308d8fa7184..709f267cda8 100644 --- a/raddb/policy.d/time +++ b/raddb/policy.d/time @@ -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}}" } } diff --git a/share/dictionary/freeradius/dictionary.freeradius.internal b/share/dictionary/freeradius/dictionary.freeradius.internal index 3f85dd9badb..6b4b8dcbb9e 100644 --- a/share/dictionary/freeradius/dictionary.freeradius.internal +++ b/share/dictionary/freeradius/dictionary.freeradius.internal @@ -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 diff --git a/src/tests/keywords/xlat-double-alternation b/src/tests/keywords/xlat-double-alternation index dc8dfd31a1c..98606906722 100644 --- a/src/tests/keywords/xlat-double-alternation +++ b/src/tests/keywords/xlat-double-alternation @@ -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 } diff --git a/src/tests/keywords/xlat-integer b/src/tests/keywords/xlat-integer index 489c54075ba..1194ed2b252 100644 --- a/src/tests/keywords/xlat-integer +++ b/src/tests/keywords/xlat-integer @@ -31,9 +31,9 @@ if ((&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 ((&Tmp-String-1 != &Tmp-Integer64-0) || (&Tmp-Integer64-0 != 98709870)) { +if ((&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 (&Tmp-Integer64-2 != &Tmp-Cast-Ether) { +if (&Tmp-uint64-2 != &Tmp-Cast-Ether) { test_fail } diff --git a/src/tests/modules/json/eval.unlang b/src/tests/modules/json/eval.unlang index fc9f62d7010..faedb8c1f07 100644 --- a/src/tests/modules/json/eval.unlang +++ b/src/tests/modules/json/eval.unlang @@ -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 diff --git a/src/tests/unit/condition/base.txt b/src/tests/unit/condition/base.txt index 067e9e4b55f..abd7ab8ef16 100644 --- a/src/tests/unit/condition/base.txt +++ b/src/tests/unit/condition/base.txt @@ -420,16 +420,16 @@ match &Filter-Id == &Framed-IP-Address condition 127.0.0.1 == &Filter-Id match &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 &Tmp-Integer64-0 == &Framed-IP-Address +condition &Tmp-uint64-0 == &Framed-IP-Address match ERROR offset 8: Cannot cast type 'uint64' to 'ipaddr' # @@ -441,8 +441,8 @@ condition &PMIP6-Home-IPv4-HoA == &Framed-IP-Address match &PMIP6-Home-IPv4-HoA == &Framed-IP-Address # but these are allowed -condition &Tmp-Integer64-0 == "%{module: foo}" -match &Tmp-Integer64-0 == "%{module: foo}" +condition &Tmp-uint64-0 == "%{module: foo}" +match &Tmp-uint64-0 == "%{module: foo}" condition &Filter-Id == &Framed-IP-Address match &Filter-Id == &Framed-IP-Address