Browse Source

[3795] One extra unit-test implemented for pkt6-receive-drop

Tomek Mrugalski 10 years ago
parent
commit
b4ecbba0c1
1 changed files with 31 additions and 1 deletions
  1. 31 1
      src/bin/dhcp6/tests/sarr_unittest.cc

+ 31 - 1
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