From cea271d0ee61dcf54fe6940cd58cb327c16c7d49 Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Fri, 11 Dec 2015 16:13:18 +0100 Subject: [4206b] Added unit tests for malfromed client id in getLabel. --- src/lib/dhcp/tests/pkt4_unittest.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/lib/dhcp/tests/pkt4_unittest.cc') diff --git a/src/lib/dhcp/tests/pkt4_unittest.cc b/src/lib/dhcp/tests/pkt4_unittest.cc index 36f2b353f6..4d0382d04e 100644 --- a/src/lib/dhcp/tests/pkt4_unittest.cc +++ b/src/lib/dhcp/tests/pkt4_unittest.cc @@ -1024,6 +1024,19 @@ TEST_F(Pkt4Test, getLabel) { } +// Test that empty client identifier option doesn't cause an exception from +// Pkt4::getLabel. +TEST_F(Pkt4Test, getLabelEmptyClientId) { + Pkt4 pkt(DHCPOFFER, 1234); + + // Create empty client identifier option. + OptionPtr empty_opt(new Option(Option::V4, DHO_DHCP_CLIENT_IDENTIFIER)); + pkt.addOption(empty_opt); + + EXPECT_EQ("[hwtype=1 ], cid=[no info], tid=0x4d2" + " (malformed client-id)", pkt.getLabel()); +} + // Tests that the variant of makeLabel which doesn't include transaction // id produces expected output. TEST_F(Pkt4Test, makeLabelWithoutTransactionId) { -- cgit v1.2.3