Add tests for combo-ip and fix decoding

This commit is contained in:
Istvan Ruzman
2020-09-05 16:14:48 +02:00
parent b2615b5ec3
commit 9dd8a3cb94
2 changed files with 13 additions and 1 deletions

View File

@@ -207,7 +207,7 @@ def decode_ipv6_prefix(addr: bytes) -> IPv6Network:
def decode_combo_ip(addr: bytes) -> Union[IPv4Address, IPv6Address]: def decode_combo_ip(addr: bytes) -> Union[IPv4Address, IPv6Address]:
"""Decode a RADIUS value of type combo-ip""" """Decode a RADIUS value of type combo-ip"""
return ip_address(addr).packed return ip_address(addr)
def decode_ascend_binary(string: bytes): def decode_ascend_binary(string: bytes):

View File

@@ -66,6 +66,11 @@ TEST_ATTRIBUTES = [
), ),
(b"\x0c\x04\x20\x03", IPv6Address("2003::0")), (b"\x0c\x04\x20\x03", IPv6Address("2003::0")),
(b"\x0d\x06\x00\x40\x20\x03", IPv6Network("2003::0/64")), (b"\x0d\x06\x00\x40\x20\x03", IPv6Network("2003::0/64")),
(b"\x0e\x06\xc0\xa8\x01\x08", IPv4Address("192.168.1.8")),
(
b"\x0e\x12\x20\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01",
IPv6Address("2003::1"),
),
] ]
TAGGED_ATTRIBUTES = [ TAGGED_ATTRIBUTES = [
@@ -113,6 +118,13 @@ TAGGED_ATTRIBUTES = [
), ),
(b"\x70\x05\x01\x20\x03", IPv6Address("2003::0")), (b"\x70\x05\x01\x20\x03", IPv6Address("2003::0")),
(b"\x71\x07\x01\x00\x40\x20\x03", IPv6Network("2003::0/64")), (b"\x71\x07\x01\x00\x40\x20\x03", IPv6Network("2003::0/64")),
# combo-ip (v4)
(b"\x72\x07\x01\xc0\xa8\x01\x08", IPv4Address("192.168.1.8")),
# combo-ip (v6)
(
b"\x72\x13\x01\x20\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01",
IPv6Address("2003::1"),
),
] ]
VENDOR_FORMAT_COMBINATIONS = [ VENDOR_FORMAT_COMBINATIONS = [