mgmt: limit prefix length in fib/add-nexthop
This commit also makes FibManager logging more consistent.
refs #4262
Change-Id: I8e1d58eacfdf0a87d6f94182c78a157421de6f6f
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index 7c86e28..428b15b 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -171,6 +171,24 @@
BOOST_CHECK_EQUAL(checkNextHop("/hello", nullopt, nullopt, 101), CheckNextHopResult::NO_FIB_ENTRY);
}
+BOOST_AUTO_TEST_CASE(NameTooLong)
+{
+ Name prefix;
+ while (prefix.size() <= FIB_MAX_DEPTH) {
+ prefix.append("A");
+ }
+
+ auto req = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop",
+ makeParameters(prefix, addFace()));
+ receiveInterest(req);
+
+ ControlResponse expected(414, "FIB entry prefix cannot exceed " +
+ ndn::to_string(Fib::getMaxDepth()) + " components");
+ BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expected), CheckResponseResult::OK);
+
+ BOOST_CHECK_EQUAL(checkNextHop(prefix), CheckNextHopResult::NO_FIB_ENTRY);
+}
+
BOOST_AUTO_TEST_CASE(ImplicitFaceId)
{
auto face1 = addFace();