From: Nick Porter Date: Thu, 16 Oct 2025 12:53:04 +0000 (+0100) Subject: Add test of %dhcpv4.decode / %dhcpv4.encode using root ctx X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31b05ac07822d5d21229e943f5f45f4b1592409c;p=thirdparty%2Ffreeradius-server.git Add test of %dhcpv4.decode / %dhcpv4.encode using root ctx --- diff --git a/src/tests/keywords/xlat-dhcpv4 b/src/tests/keywords/xlat-dhcpv4 index 0996f91f95..80306305fe 100644 --- a/src/tests/keywords/xlat-dhcpv4 +++ b/src/tests/keywords/xlat-dhcpv4 @@ -50,4 +50,33 @@ if (test_octets != 0x7d1900002458140101010204c0a80101050968656c6c6f2e62696e) { test_fail } +# +# Check decoding and encoding with a root context +# +if (%dhcpv4.decode(Vendor-Specific-Options, Decoded-Option-43.Broadband-Forum) != 2) { + test_fail +} + +if (Decoded-Option-43.Broadband-Forum.ACS-URL != 'https://1.2.3.4:7547/') { + test_fail +} +if (Decoded-Option-43.Broadband-Forum.Provisioning-Code != 'test') { + test_fail +} + +reply.Decoded-Option-43.Broadband-Forum = { + ACS-URL = 'https://example.com/', + CWMP-Retry-Minimum-Interval = '10 seconds' +} + +debug_reply + +test_octets := %dhcpv4.encode(reply.Decoded-Option-43.Broadband-Forum, Decoded-Option-43.Broadband-Forum) + +if (test_octets != 0x011468747470733a2f2F6578616d706C652e636f6D2f030a3130207365636F6e6473) { + test_fail +} + +reply -= Decoded-Option-43 + success diff --git a/src/tests/keywords/xlat-dhcpv4.attrs b/src/tests/keywords/xlat-dhcpv4.attrs index 80bf169caa..765e509137 100644 --- a/src/tests/keywords/xlat-dhcpv4.attrs +++ b/src/tests/keywords/xlat-dhcpv4.attrs @@ -1,4 +1,5 @@ Packet-Type = Discover +Vendor-Specific-Options = 0x011568747470733a2f2f312e322e332e343a373534372f020474657374 Result-Status == success Packet-Type == Offer