mgmt: respond with 414 if StrategyChoice prefix is too long
refs #4262
Change-Id: Ief6dec02d7fbf372382a167e04d82e48777fa30b
diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
index e0933e4..b4718a9 100644
--- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp
+++ b/tests/daemon/mgmt/strategy-choice-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,
@@ -120,6 +120,28 @@
BOOST_CHECK_EQUAL(hasEntry("/A"), false);
}
+BOOST_AUTO_TEST_CASE(SetNameTooLong)
+{
+ Name prefix;
+ while (prefix.size() <= FIB_MAX_DEPTH) {
+ prefix.append("A");
+ }
+ ControlParameters reqParams;
+ reqParams.setName(prefix)
+ .setStrategy(strategyNameP);
+ auto req = makeControlCommandRequest("/localhost/nfd/strategy-choice/set", reqParams);
+ receiveInterest(req);
+
+ ControlResponse expectedResp;
+ expectedResp.setCode(414)
+ .setText("Prefix has too many components (limit is " +
+ to_string(NameTree::getMaxDepth()) + ")");
+ BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expectedResp),
+ CheckResponseResult::OK);
+
+ BOOST_CHECK_EQUAL(hasEntry(prefix), false);
+}
+
BOOST_AUTO_TEST_CASE(UnsetSuccess)
{
auto insertRes = sc.insert("/A", strategyNameP);