]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add first DHCPv6 keyword test
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 20 Jan 2021 21:46:34 +0000 (21:46 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 20 Jan 2021 21:46:34 +0000 (21:46 +0000)
src/bin/unit_test_module.c
src/tests/keywords/dhcpv6.conf
src/tests/keywords/map-xlat-struct [new file with mode: 0644]
src/tests/keywords/map-xlat-struct.attrs [new file with mode: 0644]

index 1241cc0c56391d8bfccf2fc9bb2e8369f667f407..06abd8a2a5364f607f02eb393ea140f69b06670f 100644 (file)
@@ -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;
 
 
index 07a12bc97c7968acfa0899a257e13993005d5391..96759a146697e5f64d297f1bd5ebdb1cc02d0f0b 100644 (file)
@@ -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 (file)
index 0000000..fb0fbe0
--- /dev/null
@@ -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 (file)
index 0000000..892706c
--- /dev/null
@@ -0,0 +1,5 @@
+Packet-Type = Solicit
+
+
+Packet-Type == Advertise
+Result-Status == "success"