From: Alan T. DeKok Date: Fri, 10 Sep 2021 18:18:10 +0000 (-0400) Subject: add tests for time_delta X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb142d94796c3445aef70a1d40a09098cd25a53e;p=thirdparty%2Ffreeradius-server.git add tests for time_delta --- diff --git a/src/tests/unit/dictionary b/src/tests/unit/dictionary index 3fd496d658c..917f0049e7c 100644 --- a/src/tests/unit/dictionary +++ b/src/tests/unit/dictionary @@ -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 index 00000000000..5aa361397dc --- /dev/null +++ b/src/tests/unit/protocols/radius/time_delta.txt @@ -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 diff --git a/src/tests/unit/protocols/radius/unit.txt b/src/tests/unit/protocols/radius/unit.txt index ecdaffbf8b1..75293cf0661 100644 --- a/src/tests/unit/protocols/radius/unit.txt +++ b/src/tests/unit/protocols/radius/unit.txt @@ -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