]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add extra tests for time_delta (#4228)
authorJorge Pereira <jpereira@users.noreply.github.com>
Tue, 14 Sep 2021 18:12:58 +0000 (15:12 -0300)
committerGitHub <noreply@github.com>
Tue, 14 Sep 2021 18:12:58 +0000 (14:12 -0400)
src/tests/unit/dictionary
src/tests/unit/protocols/radius/time_delta.txt

index 917f0049e7cdeb8130a991147e913554148e4207..2a50bd2065a07ed91dabf10f5060c85ce373e691 100644 (file)
@@ -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
 #
index a83b1d945970ea5fb1d4bf05111c58ec913a469a..19d97df88ca13bf41fb9a9443c0a4a9de3fcc88b 100644 (file)
@@ -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