]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add tests for time_delta
authorAlan T. DeKok <aland@freeradius.org>
Fri, 10 Sep 2021 18:18:10 +0000 (14:18 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 10 Sep 2021 18:18:10 +0000 (14:18 -0400)
src/tests/unit/dictionary
src/tests/unit/protocols/radius/time_delta.txt [new file with mode: 0644]
src/tests/unit/protocols/radius/unit.txt

index 3fd496d658c3f843bfb17e3539fe503963777af6..917f0049e7cdeb8130a991147e913554148e4207 100644 (file)
@@ -29,6 +29,11 @@ ATTRIBUTE    Milliseconds            254.1           date milliseconds
 ATTRIBUTE      Delta-MSec              254.2           time_delta milliseconds
 ATTRIBUTE      Delta-Sec               254.3           time_delta seconds
 
+ATTRIBUTE      Delta-MSec-uint16       254.4           time_delta milliseconds,uint16
+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
+
 #
 #  Copied here for simplicity
 #
diff --git a/src/tests/unit/protocols/radius/time_delta.txt b/src/tests/unit/protocols/radius/time_delta.txt
new file mode 100644 (file)
index 0000000..5aa3613
--- /dev/null
@@ -0,0 +1,52 @@
+#
+#  time deltas, which don't require setting TZ=UTC
+#
+proto radius
+proto-dictionary radius
+
+#
+#  Time delta in milliseconds.
+#
+attribute Unit-TLV.Delta-MSec = 5
+match Unit-TLV.Delta-MSec = 5
+
+encode-pair -
+match fe 08 02 06 00 00 00 05
+
+decode-pair -
+match Unit-TLV = { Delta-MSec = 5 }
+
+#
+#  @todo - not yet converted to make nested TLVs!
+#
+attribute Unit-TLV.Delta-Sec = 10
+match Unit-TLV.Delta-Sec = 10
+
+encode-pair -
+match fe 08 03 06 00 00 00 0a
+
+decode-pair -
+match Unit-TLV = { Delta-Sec = 10 }
+
+#
+#  Allow encoding as nested VPs
+#
+encode-pair Unit-TLV.Milliseconds = 1
+match fe 08 01 06 00 00 00 01
+
+encode-pair Unit-TLV = { Milliseconds = 1 }
+match fe 08 01 06 00 00 00 01
+
+#
+#  Various data types and time resolutions
+#
+encode-pair Unit-TLV.Delta-MSec-uint16 = 65ms
+match fe 06 04 04 00 41
+
+# The attribute is milliseconds, so we print it as
+# milliseconds by default.
+decode-pair -
+match Unit-TLV = { Delta-MSec-uint16 = 65 }
+
+count
+match 22
index ecdaffbf8b16b22b1f1d2d14f9911b670274b72b..75293cf066157d6818994bccffa1c8980cedfd62 100644 (file)
@@ -57,6 +57,9 @@ encode-pair Event-Timestamp := 864000
 match 37 06 00 0d 2f 00
 
 # Same as from "data_types.txt"
+#
+# Requires TC=UTC!
+#
 decode-pair -
 match Event-Timestamp = "Jan 11 1970 00:00:00 UTC"
 
@@ -67,38 +70,5 @@ match 37 06 00 0d 2f 00
 attribute Unit-TLV.Milliseconds = "2019-08-21T07:40:31.123-04:00"
 match Unit-TLV.Milliseconds = "2019-08-21T03:40:31.123Z"
 
-#
-#  Time delta in milliseconds.
-#
-attribute Unit-TLV.Delta-MSec = 5
-match Unit-TLV.Delta-MSec = 5
-
-encode-pair -
-match fe 08 02 06 00 00 00 05
-
-decode-pair -
-match Unit-TLV = { Delta-MSec = 5 }
-
-#
-#  @todo - not yet converted to make nested TLVs!
-#
-attribute Unit-TLV.Delta-Sec = 10
-match Unit-TLV.Delta-Sec = 10
-
-encode-pair -
-match fe 08 03 06 00 00 00 0a
-
-decode-pair -
-match Unit-TLV = { Delta-Sec = 10 }
-
-#
-#  Allow encoding as nested VPs
-#
-encode-pair Unit-TLV.Milliseconds = 1
-match fe 08 01 06 00 00 00 01
-
-encode-pair Unit-TLV = { Milliseconds = 1 }
-match fe 08 01 06 00 00 00 01
-
 count
 match 48