From: Arran Cudbard-Bell Date: Wed, 20 Jan 2021 21:46:34 +0000 (+0000) Subject: Add first DHCPv6 keyword test X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b6accf8b7656df4eef2a12fd00d76b3b9b05990b;p=thirdparty%2Ffreeradius-server.git Add first DHCPv6 keyword test --- diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index 1241cc0c563..06abd8a2a53 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -999,11 +999,14 @@ int main(int argc, char *argv[]) /* * Update the list with the response type, so that it can * be matched in filters. + * + * Some state machines already include a response Packet-Type + * so we need to try and update it, else we end up with two! */ if (filter_vps) { fr_pair_t const *failed[2]; - MEM(pair_add_reply(&vp, attr_packet_type) >= 0); + MEM(pair_update_reply(&vp, attr_packet_type) >= 0); vp->vp_uint32 = request->reply->code; diff --git a/src/tests/keywords/dhcpv6.conf b/src/tests/keywords/dhcpv6.conf index 07a12bc97c7..96759a14669 100644 --- a/src/tests/keywords/dhcpv6.conf +++ b/src/tests/keywords/dhcpv6.conf @@ -66,12 +66,6 @@ policy { &Result-Status := "success" } } - - if (&parent.request.User-Name && !&parent.reply.Result-Status) { - update parent.reply { - &Result-Status := "success" - } - } } test_fail { diff --git a/src/tests/keywords/map-xlat-struct b/src/tests/keywords/map-xlat-struct new file mode 100644 index 00000000000..fb0fbe041e3 --- /dev/null +++ b/src/tests/keywords/map-xlat-struct @@ -0,0 +1,23 @@ +# +# PRE: update +# PROTOCOL: dhcpv6 +# +# Test the map xlat +# +update { + &Tmp-String-0 := "IA-PD.IAID = 11" +} + +if ("%{map:%{Tmp-String-0}}" != 1) { + test_fail +} + +if (!&IA-PD.IAID) { + test_fail +} + +if (&IA-PD.IAID != 11) { + test_fail +} + +success diff --git a/src/tests/keywords/map-xlat-struct.attrs b/src/tests/keywords/map-xlat-struct.attrs new file mode 100644 index 00000000000..892706c9a76 --- /dev/null +++ b/src/tests/keywords/map-xlat-struct.attrs @@ -0,0 +1,5 @@ +Packet-Type = Solicit + + +Packet-Type == Advertise +Result-Status == "success"