management: Controller validates StatusDataset response

refs #3653

Change-Id: Id54026d7277fecf52b6443bf42d01b5e6d7e35a3
diff --git a/tests/unit-tests/management/nfd-controller-fixture.hpp b/tests/unit-tests/management/nfd-controller-fixture.hpp
index 9894468..492cbc2 100644
--- a/tests/unit-tests/management/nfd-controller-fixture.hpp
+++ b/tests/unit-tests/management/nfd-controller-fixture.hpp
@@ -22,6 +22,9 @@
 #ifndef NDN_TESTS_MANAGEMENT_NFD_CONTROLLER_FIXTURE_HPP
 #define NDN_TESTS_MANAGEMENT_NFD_CONTROLLER_FIXTURE_HPP
 
+#include "management/nfd-controller.hpp"
+#include "../../dummy-validator.hpp"
+
 #include "boost-test.hpp"
 #include "util/dummy-client-face.hpp"
 #include "../identity-management-time-fixture.hpp"
@@ -37,7 +40,7 @@
 protected:
   ControllerFixture()
     : face(io, m_keyChain)
-    , controller(face, m_keyChain)
+    , controller(face, m_keyChain, m_validator)
     , failCallback(bind(&ControllerFixture::fail, this, _1, _2))
   {
     Name identityName("/localhost/ControllerFixture");
@@ -49,6 +52,17 @@
     }
   }
 
+  /** \brief controls whether Controller's validator should accept or reject validation requests
+   *
+   *  Initially, the validator accepts all requests.
+   *  Setting \p false causes validator to reject all requests.
+   */
+  void
+  setValidationResult(bool shouldAccept)
+  {
+    m_validator.setResult(shouldAccept);
+  }
+
 private:
   void
   fail(uint32_t code, const std::string& reason)
@@ -61,6 +75,9 @@
   Controller controller;
   Controller::CommandFailCallback failCallback;
   std::vector<uint32_t> failCodes;
+
+private:
+  DummyValidator m_validator;
 };
 
 } // namespace tests
diff --git a/tests/unit-tests/management/nfd-status-dataset.t.cpp b/tests/unit-tests/management/nfd-status-dataset.t.cpp
index e27d4a3..bc4b495 100644
--- a/tests/unit-tests/management/nfd-status-dataset.t.cpp
+++ b/tests/unit-tests/management/nfd-status-dataset.t.cpp
@@ -135,6 +135,24 @@
   BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
 }
 
+BOOST_AUTO_TEST_CASE(ValidationFailure)
+{
+  this->setValidationResult(false);
+
+  controller.fetch<FaceDataset>(
+    [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
+    failCallback);
+  this->advanceClocks(time::milliseconds(500));
+
+  FaceStatus payload;
+  payload.setFaceId(5744);
+  this->sendDataset("/localhost/nfd/faces/list", payload);
+  this->advanceClocks(time::milliseconds(500));
+
+  BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
+  BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION);
+}
+
 BOOST_AUTO_TEST_CASE(Nack)
 {
   controller.fetch<FaceDataset>(