face: decode CachePolicy without requiring allowLocalFields

refs #3966

Change-Id: I9a0f3c72682a6bc66f8852f115789a450a168223
diff --git a/daemon/face/generic-link-service.cpp b/daemon/face/generic-link-service.cpp
index 20c1cb8..25d52bd 100644
--- a/daemon/face/generic-link-service.cpp
+++ b/daemon/face/generic-link-service.cpp
@@ -305,14 +305,10 @@
   }
 
   if (firstPkt.has<lp::CachePolicyField>()) {
-    if (m_options.allowLocalFields) {
-      // In case of an invalid CachePolicyType, get<lp::CachePolicyField> will throw,
-      // so it's unnecessary to check here.
-      data->setTag(make_shared<lp::CachePolicyTag>(firstPkt.get<lp::CachePolicyField>()));
-    }
-    else {
-      NFD_LOG_FACE_WARN("received CachePolicy, but local fields disabled: IGNORE");
-    }
+    // CachePolicy is unprivileged and does not require allowLocalFields option.
+    // In case of an invalid CachePolicyType, get<lp::CachePolicyField> will throw,
+    // so it's unnecessary to check here.
+    data->setTag(make_shared<lp::CachePolicyTag>(firstPkt.get<lp::CachePolicyField>()));
   }
 
   if (firstPkt.has<lp::IncomingFaceIdField>()) {
diff --git a/tests/daemon/face/generic-link-service.t.cpp b/tests/daemon/face/generic-link-service.t.cpp
index d252078..bcff9de 100644
--- a/tests/daemon/face/generic-link-service.t.cpp
+++ b/tests/daemon/face/generic-link-service.t.cpp
@@ -537,12 +537,13 @@
   BOOST_CHECK(receivedNacks.empty());
 }
 
-BOOST_AUTO_TEST_CASE(ReceiveCacheControl)
+BOOST_AUTO_TEST_CASE(ReceiveCachePolicy)
 {
-  // Initialize with Options that enables local fields
+  // Initialize with Options that disables local fields
   GenericLinkService::Options options;
-  options.allowLocalFields = true;
+  options.allowLocalFields = false;
   initialize(options);
+  // CachePolicy is unprivileged and does not require allowLocalFields option.
 
   shared_ptr<Data> data = makeData("/12345678");
   lp::Packet packet(data->wireEncode());
@@ -556,27 +557,7 @@
   BOOST_CHECK_EQUAL(tag->get().getPolicy(), lp::CachePolicyType::NO_CACHE);
 }
 
-BOOST_AUTO_TEST_CASE(ReceiveCacheControlDisabled)
-{
-  // Initialize with Options that disables local fields
-  GenericLinkService::Options options;
-  options.allowLocalFields = false;
-  initialize(options);
-
-  shared_ptr<Data> data = makeData("/12345678");
-  lp::Packet packet(data->wireEncode());
-  lp::CachePolicy policy;
-  policy.setPolicy(lp::CachePolicyType::NO_CACHE);
-  packet.set<lp::CachePolicyField>(policy);
-
-  transport->receivePacket(packet.wireEncode());
-
-  BOOST_CHECK_EQUAL(service->getCounters().nInNetInvalid, 0); // not an error
-  BOOST_REQUIRE_EQUAL(receivedData.size(), 1);
-  BOOST_CHECK(receivedData.back().getTag<lp::CachePolicyTag>() == nullptr);
-}
-
-BOOST_AUTO_TEST_CASE(ReceiveCacheControlDropInterest)
+BOOST_AUTO_TEST_CASE(ReceiveCachePolicyDropInterest)
 {
   // Initialize with Options that enables local fields
   GenericLinkService::Options options;
@@ -595,7 +576,7 @@
   BOOST_CHECK(receivedInterests.empty());
 }
 
-BOOST_AUTO_TEST_CASE(ReceiveCacheControlDropNack)
+BOOST_AUTO_TEST_CASE(ReceiveCachePolicyDropNack)
 {
   // Initialize with Options that enables local fields
   GenericLinkService::Options options;