From: Jorge Pereira Date: Tue, 14 Sep 2021 18:12:58 +0000 (-0300) Subject: Add extra tests for time_delta (#4228) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=707a467f62e4f6ee0a7da5a10a8462de6b2c9c43;p=thirdparty%2Ffreeradius-server.git Add extra tests for time_delta (#4228) --- diff --git a/src/tests/unit/dictionary b/src/tests/unit/dictionary index 917f0049e7c..2a50bd2065a 100644 --- a/src/tests/unit/dictionary +++ b/src/tests/unit/dictionary @@ -34,6 +34,11 @@ ATTRIBUTE Delta-Sec-uint16 254.5 time_delta seconds,uint16 ATTRIBUTE Delta-MSec-int16 254.6 time_delta milliseconds,int16 ATTRIBUTE Delta-Sec-int16 254.7 time_delta seconds,int16 +ATTRIBUTE Delta-MSec-uint32 254.8 time_delta milliseconds,uint32 +ATTRIBUTE Delta-Sec-uint32 254.9 time_delta seconds,uint32 +ATTRIBUTE Delta-MSec-int32 254.10 time_delta milliseconds,int32 +ATTRIBUTE Delta-Sec-int32 254.11 time_delta seconds,int32 + # # Copied here for simplicity # diff --git a/src/tests/unit/protocols/radius/time_delta.txt b/src/tests/unit/protocols/radius/time_delta.txt index a83b1d94597..19d97df88ca 100644 --- a/src/tests/unit/protocols/radius/time_delta.txt +++ b/src/tests/unit/protocols/radius/time_delta.txt @@ -57,5 +57,49 @@ match Unit-TLV = { Delta-MSec-int16 = -32768 } attribute Unit-TLV.Delta-MSec-int16 = -32768 match Unit-TLV.Delta-MSec-int16 = -32768 +# +# Min/Max values & overflows +# + +# Internal format is int64_t +attribute Unit-TLV.Delta-MSec-uint16 = 9223372036853 +match Unit-TLV.Delta-MSec-uint16 = 9223372036853 + +attribute Unit-TLV.Delta-MSec-uint32 = 9223372036853 +match Unit-TLV.Delta-MSec-uint32 = 9223372036853 + +# therefore, the encode should limit to the data type. +encode-pair Unit-TLV.Delta-MSec-uint16 = 9223372036853 +match fe 06 04 04 ff ff + +encode-pair Unit-TLV.Delta-MSec-uint32 = 9223372036853 +match fe 08 08 06 ff ff ff ff + +# lets see encode/decode based on the data type for unsigned +encode-pair Unit-TLV.Delta-MSec-uint16 = 65535 +match fe 06 04 04 ff ff + +decode-pair - +match Unit-TLV = { Delta-MSec-uint16 = 65535 } + +encode-pair Unit-TLV.Delta-MSec-uint32 = 4294967295 +match fe 08 08 06 ff ff ff ff + +decode-pair - +match Unit-TLV = { Delta-MSec-uint32 = 4294967295 } + +# ... and signed +encode-pair Unit-TLV.Delta-MSec-int16 = 32767 +match fe 06 06 04 7f ff + +decode-pair - +match Unit-TLV = { Delta-MSec-int16 = 32767 } + +encode-pair Unit-TLV.Delta-MSec-int32 = 2147483647 +match fe 08 0a 06 7f ff ff ff + +decode-pair - +match Unit-TLV = { Delta-MSec-int32 = 2147483647 } + count -match 28 +match 52