From: Tomek Mrugalski Date: Fri, 19 Jun 2015 13:54:30 +0000 (+0200) Subject: [3795] One extra unit-test implemented for pkt6-receive-drop X-Git-Tag: trac3910_base~2^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4ecbba0c13b1aa9f2e58231cbe53fb24c4d25ef;p=thirdparty%2Fkea.git [3795] One extra unit-test implemented for pkt6-receive-drop --- diff --git a/src/bin/dhcp6/tests/sarr_unittest.cc b/src/bin/dhcp6/tests/sarr_unittest.cc index f7a75b0218..247484478f 100644 --- a/src/bin/dhcp6/tests/sarr_unittest.cc +++ b/src/bin/dhcp6/tests/sarr_unittest.cc @@ -373,7 +373,8 @@ TEST_F(SARRTest, pkt6ReceiveDropStat1) { } // This test verifies that pkt6-receive-drop is increased properly when the -// client's packet is rejected due to sending to unicast. +// client's packet is rejected due to having too many client-id options +// (exactly one is expected). TEST_F(SARRTest, pkt6ReceiveDropStat2) { // Let's use one of the existing configurations and tell the client to @@ -396,5 +397,34 @@ TEST_F(SARRTest, pkt6ReceiveDropStat2) { EXPECT_EQ(1, pkt6_recv_drop->getInteger().first); } +// This test verifies that pkt6-receive-drop is increased properly when the +// client's packet is rejected due to having too many +TEST_F(SARRTest, pkt6ReceiveDropStat3) { + + // Let's use one of the existing configurations and tell the client to + // ask for an address. + Dhcp6Client client; + configure(CONFIGS[1], *client.getServer()); + client.setInterface("eth1"); + client.useNA(); + + client.setDestAddress(asiolink::IOAddress("2001:db8::1")); // Pretend it's unicast + + // Let's send our client-id as server-id. That will result in the + // packet containing the client-id twice. That should cause RFCViolation + // exception. + client.useServerId(client.getClientId()); + client.doSolicit(); + + // Ok, let's check the statistics. None should be present. + using namespace isc::stats; + StatsMgr& mgr = StatsMgr::instance(); + + ObservationPtr pkt6_recv_drop = mgr.getObservation("pkt6-receive-drop"); + ASSERT_TRUE(pkt6_recv_drop); + + EXPECT_EQ(1, pkt6_recv_drop->getInteger().first); +} + } // end of anonymous namespace