You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by al...@apache.org on 2018/07/02 14:11:34 UTC

nifi-minifi-cpp git commit: MINIFICPP-543: Implement C2 based update policy enforcement

Repository: nifi-minifi-cpp
Updated Branches:
  refs/heads/master e9982cc50 -> fad26e57c


MINIFICPP-543: Implement C2 based update policy enforcement

MINIFICPP-543: Remove state ignore from gitignore and change how bootstrap commits state to avoid issues with state src dir

This closes #365.

Signed-off-by: Aldrin Piri <al...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/commit/fad26e57
Tree: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/tree/fad26e57
Diff: http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/diff/fad26e57

Branch: refs/heads/master
Commit: fad26e57c0a4a81ca0703032deb085b7d4df7219
Parents: e9982cc
Author: Marc Parisi <ph...@apache.org>
Authored: Mon Jun 25 16:04:00 2018 -0400
Committer: Aldrin Piri <al...@apache.org>
Committed: Mon Jul 2 10:10:55 2018 -0400

----------------------------------------------------------------------
 .gitignore                                      |   2 +-
 C2.md                                           |  22 +++
 bootstrap.sh                                    |   2 +-
 bstrp_functions.sh                              |   8 +-
 libminifi/include/c2/C2Agent.h                  |  10 +-
 .../controllers/UpdatePolicyControllerService.h | 101 +++++++++++++
 libminifi/include/core/state/UpdatePolicy.h     | 144 +++++++++++++++++++
 libminifi/src/c2/C2Agent.cpp                    |  31 +++-
 .../UpdatePolicyControllerService.cpp           | 106 ++++++++++++++
 libminifi/test/unit/UpdatePolicyTests.cpp       |  78 ++++++++++
 main/CMakeLists.txt                             |   2 +-
 11 files changed, 493 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 9968c0a..1bbca52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,7 +42,7 @@ cmake-build-debug
 
 # Generated files
 build
-state
+bt_state
 bin
 target
 thirdparty/**/*.o

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/C2.md
----------------------------------------------------------------------
diff --git a/C2.md b/C2.md
index 307cd59..d6ebf1c 100644
--- a/C2.md
+++ b/C2.md
@@ -286,3 +286,25 @@ will forward responses and updates to the heartbeating agents.
 	  queue prioritizer class: org.apache.nifi.prioritizer.FirstInFirstOutPrioritizer
 	Remote Process Groups: []
 	NiFi Properties Overrides: {}
+
+### Update Policies
+
+Updates to MiNiFi C++ properties can be controlled through an UpdatePolicyControllerService named
+C2UpdatePolicy. The service supports several configuration options. They are defined in the following example:   
+
+	
+	Controller Services:
+	- id: 94491a38-015a-1000-0000-000000000001
+	  name: C2UpdatePolicy
+	  class: UpdatePolicyControllerService
+	  Properties:
+	    # true enables all properties to be updated. 
+	    Allow All Properties: true
+	    # allowed properties are those which can be updated
+	    Allowed Properties: 
+	             Property_1:true
+	             Property_2:true
+	    Disallowed Properties:
+	    		 Property_3:true
+	             Property_4:true
+	
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/bootstrap.sh
----------------------------------------------------------------------
diff --git a/bootstrap.sh b/bootstrap.sh
index ccfc98a..97e8b5f 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -57,7 +57,7 @@ while :; do
       EnableAllFeatures
       ;;
      -c|--clear)
-      rm ${script_directory}/state > /dev/null 2>&1
+      rm ${script_directory}/bt_state > /dev/null 2>&1
       ;;
     -d|--deploy)
       NO_PROMPT="true"

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/bstrp_functions.sh
----------------------------------------------------------------------
diff --git a/bstrp_functions.sh b/bstrp_functions.sh
index beb4442..351aeec 100755
--- a/bstrp_functions.sh
+++ b/bstrp_functions.sh
@@ -72,8 +72,8 @@ pause(){
 
 
 load_state(){
-if [ -f ${script_directory}/state ]; then
- . ${script_directory}/state
+if [ -f ${script_directory}/bt_state ]; then
+ . ${script_directory}/bs_state
  for option in "${OPTIONS[@]}" ; do
       option_value="${!option}"
        if [ "${option_value}" = "${FALSE}" ]; then
@@ -85,11 +85,11 @@ fi
 
 echo_state_variable(){
 VARIABLE_VALUE=${!1}
-echo "$1=\"${VARIABLE_VALUE}\"" >> ${script_directory}/state
+echo "$1=\"${VARIABLE_VALUE}\"" >> ${script_directory}/bt_state
 }
 
 save_state(){
-   echo "VERSION=1" > ${script_directory}/state
+   echo "VERSION=1" > ${script_directory}/bt_state
    echo_state_variable BUILD_IDENTIFIER
    echo_state_variable BUILD_DIR
    for option in "${OPTIONS[@]}" ; do

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/libminifi/include/c2/C2Agent.h
----------------------------------------------------------------------
diff --git a/libminifi/include/c2/C2Agent.h b/libminifi/include/c2/C2Agent.h
index aa67035..65f07b0 100644
--- a/libminifi/include/c2/C2Agent.h
+++ b/libminifi/include/c2/C2Agent.h
@@ -27,6 +27,7 @@
 
 #include "../core/state/nodes/MetricsBase.h"
 #include "core/state/UpdateController.h"
+#include "controllers/UpdatePolicyControllerService.h"
 #include "core/state/Value.h"
 #include "C2Payload.h"
 #include "C2Protocol.h"
@@ -38,6 +39,7 @@ namespace nifi {
 namespace minifi {
 namespace c2 {
 
+#define C2_AGENT_UPDATE_NAME "C2UpdatePolicy"
 /**
  * Purpose and Justification: C2 agent will be the mechanism that will abstract the protocol to do the work.
  *
@@ -195,12 +197,16 @@ class C2Agent : public state::UpdateController, public state::response::Response
   // functions that will be used for the udpate controller.
   std::vector<std::function<state::Update()>> functions_;
 
-  // controller service provider refernece.
+  std::shared_ptr<controllers::UpdatePolicyControllerService> update_service_;
+
+  // controller service provider reference.
   std::shared_ptr<core::controller::ControllerServiceProvider> controller_;
 
+  // shared pointer to the configuration of this agent
   std::shared_ptr<Configure> configuration_;
 
-  std::shared_ptr<Configure> running_configuration;
+  // shared pointer to the running c2 configuration.
+  std::shared_ptr<Configure> running_c2_configuration;
 
   std::mutex heartbeat_mutex;
 

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/libminifi/include/controllers/UpdatePolicyControllerService.h
----------------------------------------------------------------------
diff --git a/libminifi/include/controllers/UpdatePolicyControllerService.h b/libminifi/include/controllers/UpdatePolicyControllerService.h
new file mode 100644
index 0000000..9ca0cf2
--- /dev/null
+++ b/libminifi/include/controllers/UpdatePolicyControllerService.h
@@ -0,0 +1,101 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIBMINIFI_INCLUDE_CONTROLLERS_UPDATEPOLICYCONTROLLERSERVICE_H_
+#define LIBMINIFI_INCLUDE_CONTROLLERS_UPDATEPOLICYCONTROLLERSERVICE_H_
+
+#include <iostream>
+#include <memory>
+#include <limits>
+#include "core/Resource.h"
+#include "utils/StringUtils.h"
+#include "io/validation.h"
+#include "core/controller/ControllerService.h"
+#include "core/logging/LoggerConfiguration.h"
+#include "core/state/UpdatePolicy.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace controllers {
+
+/**
+ * Purpose: UpdatePolicyControllerService allows a flow specific policy on allowing or disallowing updates.
+ * Since the flow dictates the purpose of a device it will also be used to dictate updates to specific components.
+ */
+class UpdatePolicyControllerService : public core::controller::ControllerService, public std::enable_shared_from_this<UpdatePolicyControllerService> {
+ public:
+  explicit UpdatePolicyControllerService(const std::string &name, const std::string &id)
+      : ControllerService(name, id),
+        persist_updates_(false),
+        policy_(new state::UpdatePolicy(false)),
+        logger_(logging::LoggerFactory<UpdatePolicyControllerService>::getLogger()) {
+  }
+
+  explicit UpdatePolicyControllerService(const std::string &name, uuid_t uuid = 0)
+      : ControllerService(name, uuid),
+        persist_updates_(false),
+        policy_(new state::UpdatePolicy(false)),
+        logger_(logging::LoggerFactory<UpdatePolicyControllerService>::getLogger()) {
+  }
+
+  explicit UpdatePolicyControllerService(const std::string &name, const std::shared_ptr<Configure> &configuration)
+      : UpdatePolicyControllerService(name, nullptr) {
+    setConfiguration(configuration);
+    initialize();
+  }
+
+  static core::Property AllowAllProperties;
+  static core::Property PersistUpdates;
+  static core::Property AllowedProperties;
+  static core::Property DisallowedProperties;
+
+  void initialize();
+
+  void yield();
+
+  bool isRunning();
+
+  bool isWorkAvailable();
+
+  void onEnable();
+
+  bool canUpdate(const std::string &property) const {
+    return policy_->canUpdate(property);
+  }
+
+  bool persistUpdates() const {
+    return persist_updates_;
+  }
+
+ private:
+
+  bool persist_updates_;
+  std::unique_ptr<state::UpdatePolicy> policy_;
+  std::shared_ptr<logging::Logger> logger_;
+};
+
+REGISTER_RESOURCE(UpdatePolicyControllerService);
+
+} /* namespace controllers */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
+
+#endif /* LIBMINIFI_INCLUDE_CONTROLLERS_UPDATEPOLICYCONTROLLERSERVICE_H_ */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/libminifi/include/core/state/UpdatePolicy.h
----------------------------------------------------------------------
diff --git a/libminifi/include/core/state/UpdatePolicy.h b/libminifi/include/core/state/UpdatePolicy.h
new file mode 100644
index 0000000..3f2ef2f
--- /dev/null
+++ b/libminifi/include/core/state/UpdatePolicy.h
@@ -0,0 +1,144 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_
+#define LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_
+
+#include <unordered_map>
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace state {
+
+enum UPDATE_POLICY {
+  PERM_ALLOWED,
+  PERM_DISALLOWED,
+  IMPLICIT_DISALLOWED,
+  TEMP_ALLOWED
+};
+
+class UpdatePolicyBuilder;
+/**
+ * Purpose: Defines an immutable policy map.
+ * Defines what can and cannot be updated during runtime.
+ */
+class UpdatePolicy {
+ public:
+
+  explicit UpdatePolicy(bool enable_all)
+      : enable_all_(enable_all) {
+  }
+
+  bool canUpdate(const std::string &property) const {
+    auto p = properties_.find(property);
+    if (p != std::end(properties_)) {
+      switch (p->second) {
+        case PERM_ALLOWED:
+        case TEMP_ALLOWED:
+          return true;
+        default:
+          return false;
+      }
+    }
+
+    return enable_all_;
+  }
+
+  UpdatePolicy &operator=(const UpdatePolicy &&other) {
+    enable_all_ = std::move(other.enable_all_);
+    properties_ = std::move(other.properties_);
+    return *this;
+  }
+
+ protected:
+
+  explicit UpdatePolicy(const UpdatePolicy &other)
+      : enable_all_(other.enable_all_), properties_(other.properties_) {
+  }
+
+  explicit UpdatePolicy(const UpdatePolicy &&other)
+      : enable_all_(std::move(other.enable_all_)),
+        properties_(std::move(other.properties_)) {
+  }
+
+  UpdatePolicy() = delete;
+
+  friend class UpdatePolicyBuilder;
+
+  void setEnableAll(bool enable_all) {
+    enable_all_ = enable_all;
+  }
+
+  void setProperty(const std::string &property, UPDATE_POLICY policy) {
+    properties_.emplace(property, policy);
+  }
+
+  bool enable_all_;
+
+  std::unordered_map<std::string, UPDATE_POLICY> properties_;
+
+};
+
+/**
+ * Purpose: Defines a builder for UpdatePolicy definitions. Since policies are made
+ * to be immutable defining an object as const isn't sufficient as const can be casted
+ * away. The builder helps add a layer to avoiding this by design.
+ */
+class UpdatePolicyBuilder {
+ public:
+  static std::unique_ptr<UpdatePolicyBuilder> newBuilder(bool enable_all = false) {
+    std::unique_ptr<UpdatePolicyBuilder> policy = std::unique_ptr<UpdatePolicyBuilder>( new UpdatePolicyBuilder(enable_all));
+    return policy;
+  }
+
+  void allowPropertyUpdate(const std::string &property) {
+    current_policy_->setProperty(property, PERM_ALLOWED);
+  }
+
+  void disallowPropertyUpdate(const std::string &property) {
+    current_policy_->setProperty(property, PERM_DISALLOWED);
+  }
+
+  std::unique_ptr<UpdatePolicy> build() {
+    std::unique_ptr<UpdatePolicy> new_policy = std::unique_ptr<UpdatePolicy>(new UpdatePolicy(*(current_policy_.get())));
+    return new_policy;
+  }
+
+
+ protected:
+
+  explicit UpdatePolicyBuilder(const UpdatePolicyBuilder &other)
+      : current_policy_(other.current_policy_) {
+  }
+
+
+  explicit UpdatePolicyBuilder(bool enable_all) {
+    current_policy_ = std::make_shared<UpdatePolicy>(enable_all);
+  }
+
+  std::shared_ptr<UpdatePolicy> current_policy_;
+};
+
+} /* namespace state */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */
+
+#endif /* LIBMINIFI_INCLUDE_CORE_STATE_UPDATEPOLICY_H_ */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/libminifi/src/c2/C2Agent.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/c2/C2Agent.cpp b/libminifi/src/c2/C2Agent.cpp
index b6d2825..203b66d 100644
--- a/libminifi/src/c2/C2Agent.cpp
+++ b/libminifi/src/c2/C2Agent.cpp
@@ -40,16 +40,21 @@ C2Agent::C2Agent(const std::shared_ptr<core::controller::ControllerServiceProvid
                  const std::shared_ptr<Configure> &configuration)
     : controller_(controller),
       update_sink_(updateSink),
+      update_service_(nullptr),
       configuration_(configuration),
       heart_beat_period_(3000),
       max_c2_responses(5),
       logger_(logging::LoggerFactory<C2Agent>::getLogger()) {
   allow_updates_ = true;
 
-  running_configuration = std::make_shared<Configure>();
+  running_c2_configuration = std::make_shared<Configure>();
 
   last_run_ = std::chrono::steady_clock::now();
 
+  if (nullptr != controller_) {
+    update_service_ = std::static_pointer_cast<controllers::UpdatePolicyControllerService>(controller_->getControllerService(C2_AGENT_UPDATE_NAME));
+  }
+
   configure(configuration, false);
 
   c2_producer_ = [&]() {
@@ -582,18 +587,36 @@ void C2Agent::handle_update(const C2ContentResponse &resp) {
         }
       }
     }
+  } else if (resp.name == "properties") {
+    bool update_occurred = false;
+    for (auto entry : resp.operation_arguments) {
+      if (nullptr != update_service_) {
+        if (update_service_->canUpdate(entry.first)) {
+          configuration_->set(entry.first, entry.second.to_string());
+          update_occurred = true;
+        }
+      }
+    }
+    if (nullptr != update_service_ && update_occurred) {
+      // enable updates to persist the configuration.
+    }
   } else if (resp.name == "c2") {
     // prior configuration options were already in place. thus
     // we clear the map so that we don't go through replacing
     // unnecessary objects.
-    running_configuration->clear();
+    running_c2_configuration->clear();
 
     for (auto entry : resp.operation_arguments) {
-      running_configuration->set(entry.first, entry.second.to_string());
+      bool can_update = true;
+      if (nullptr != update_service_) {
+        can_update = update_service_->canUpdate(entry.first);
+      }
+      if (can_update)
+        running_c2_configuration->set(entry.first, entry.second.to_string());
     }
 
     if (resp.operation_arguments.size() > 0)
-      configure(running_configuration);
+      configure(running_c2_configuration);
     C2Payload response(Operation::ACKNOWLEDGE, resp.ident, false, true);
     enqueue_c2_response(std::move(response));
   } else if (resp.name == "agent") {

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/libminifi/src/controllers/UpdatePolicyControllerService.cpp
----------------------------------------------------------------------
diff --git a/libminifi/src/controllers/UpdatePolicyControllerService.cpp b/libminifi/src/controllers/UpdatePolicyControllerService.cpp
new file mode 100644
index 0000000..08faad2
--- /dev/null
+++ b/libminifi/src/controllers/UpdatePolicyControllerService.cpp
@@ -0,0 +1,106 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "controllers/UpdatePolicyControllerService.h"
+#include <cstdio>
+#include <utility>
+#include <limits>
+#include <string>
+#include <vector>
+#include <sys/ioctl.h>
+#include <ifaddrs.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <set>
+#include "utils/StringUtils.h"
+#if ( defined(__APPLE__) || defined(__MACH__) || defined(BSD))
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#endif
+#include "core/state/UpdatePolicy.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace controllers {
+
+core::Property UpdatePolicyControllerService::AllowAllProperties("Allow All Properties", "Allows all properties, which are also not disallowed, to be updated", "false");
+core::Property UpdatePolicyControllerService::AllowedProperties("Allowed Properties", "Properties for which we will allow updates");
+core::Property UpdatePolicyControllerService::DisallowedProperties("Disallowed Properties", "Properties for which we will not allow updates");
+core::Property UpdatePolicyControllerService::PersistUpdates("Persist Updates", "Property that dictates whether updates should persist after a restart");
+
+void UpdatePolicyControllerService::initialize() {
+  std::set<core::Property> supportedProperties;
+  supportedProperties.insert(AllowAllProperties);
+  supportedProperties.insert(AllowedProperties);
+  supportedProperties.insert(DisallowedProperties);
+  supportedProperties.insert(PersistUpdates);
+  setSupportedProperties(supportedProperties);
+}
+
+void UpdatePolicyControllerService::yield() {
+}
+
+bool UpdatePolicyControllerService::isRunning() {
+  return getState() == core::controller::ControllerServiceState::ENABLED;
+}
+
+bool UpdatePolicyControllerService::isWorkAvailable() {
+  return false;
+}
+
+void UpdatePolicyControllerService::onEnable() {
+  std::string enableStr, persistStr;
+
+  bool enable_all = false;
+  if (getProperty(AllowAllProperties.getName(), enableStr)) {
+    enable_all = utils::StringUtils::StringToBool(enableStr, enable_all);
+  }
+
+  if (getProperty(PersistUpdates.getName(), persistStr)) {
+    persist_updates_ = utils::StringUtils::StringToBool(persistStr, persist_updates_);
+  }
+
+  auto builder = state::UpdatePolicyBuilder::newBuilder(enable_all);
+
+  core::Property all_prop("Allowed Properties", "Properties for which we will allow updates");
+  core::Property dall_prop("Disallowed Properties", "Properties for which we will not allow updates");
+
+  if (getProperty(AllowedProperties.getName(), all_prop)) {
+    for (const auto &str : all_prop.getValues()) {
+      builder->allowPropertyUpdate(str);
+    }
+  }
+
+  if (getProperty(DisallowedProperties.getName(), dall_prop)) {
+    for (const auto &str : dall_prop.getValues()) {
+      builder->disallowPropertyUpdate(str);
+    }
+  }
+  policy_ = builder->build();
+}
+} /* namespace controllers */
+} /* namespace minifi */
+} /* namespace nifi */
+} /* namespace apache */
+} /* namespace org */

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/libminifi/test/unit/UpdatePolicyTests.cpp
----------------------------------------------------------------------
diff --git a/libminifi/test/unit/UpdatePolicyTests.cpp b/libminifi/test/unit/UpdatePolicyTests.cpp
new file mode 100644
index 0000000..851e3db
--- /dev/null
+++ b/libminifi/test/unit/UpdatePolicyTests.cpp
@@ -0,0 +1,78 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <uuid/uuid.h>
+#include <vector>
+#include <memory>
+#include <utility>
+#include <string>
+#include "../TestBase.h"
+#include "io/ClientSocket.h"
+#include "core/Processor.h"
+#include "../../controller/Controller.h"
+#include "core/controller/ControllerService.h"
+#include "c2/ControllerSocketProtocol.h"
+#include "controllers/UpdatePolicyControllerService.h"
+
+TEST_CASE("TestEmptyPolicy", "[test1]") {
+  auto controller = std::make_shared<minifi::controllers::UpdatePolicyControllerService>("TestService");
+  std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
+  controller->initialize();
+  controller->onEnable();
+  REQUIRE(false == controller->canUpdate("anyproperty"));
+}
+
+TEST_CASE("TestAllowAll", "[test1]") {
+  auto controller = std::make_shared<minifi::controllers::UpdatePolicyControllerService>("TestService");
+  std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
+  controller->initialize();
+  controller->setProperty(minifi::controllers::UpdatePolicyControllerService::AllowAllProperties, "true");
+  controller->onEnable();
+  REQUIRE(true == controller->canUpdate("anyproperty"));
+}
+
+TEST_CASE("TestAllowAllFails", "[test1]") {
+  auto controller = std::make_shared<minifi::controllers::UpdatePolicyControllerService>("TestService");
+  std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
+  controller->initialize();
+  controller->setProperty(minifi::controllers::UpdatePolicyControllerService::AllowAllProperties, "false");
+  controller->onEnable();
+  REQUIRE(false == controller->canUpdate("anyproperty"));
+}
+
+TEST_CASE("TestEnableProperty", "[test1]") {
+  auto controller = std::make_shared<minifi::controllers::UpdatePolicyControllerService>("TestService");
+  std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
+  controller->initialize();
+  controller->setProperty(minifi::controllers::UpdatePolicyControllerService::AllowAllProperties, "false");
+  controller->setProperty(minifi::controllers::UpdatePolicyControllerService::AllowedProperties, "anyproperty");
+  controller->onEnable();
+  REQUIRE(true == controller->canUpdate("anyproperty"));
+}
+
+TEST_CASE("TestDisableProperty", "[test1]") {
+  auto controller = std::make_shared<minifi::controllers::UpdatePolicyControllerService>("TestService");
+  std::shared_ptr<minifi::Configure> configuration = std::make_shared<minifi::Configure>();
+  controller->initialize();
+  controller->setProperty(minifi::controllers::UpdatePolicyControllerService::AllowAllProperties, "true");
+  controller->setProperty(minifi::controllers::UpdatePolicyControllerService::DisallowedProperties, "anyproperty");
+  controller->updateProperty(minifi::controllers::UpdatePolicyControllerService::DisallowedProperties.getName(), "anyproperty2");
+  controller->onEnable();
+  REQUIRE(false == controller->canUpdate("anyproperty"));
+  REQUIRE(false == controller->canUpdate("anyproperty2"));
+  REQUIRE(true == controller->canUpdate("anyproperty3"));
+}

http://git-wip-us.apache.org/repos/asf/nifi-minifi-cpp/blob/fad26e57/main/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index 36d01e8..6905382 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -71,7 +71,7 @@ target_link_libraries(minifiexe yaml-cpp ${UUID_LIBRARIES} ${OPENSSL_LIBRARIES})
 if (APPLE)
 	get_property(extensions GLOBAL PROPERTY EXTENSION-OPTIONS)
 	foreach(EXTENSION ${extensions})
-		message("Linking against ${EXTENSION}")
+		message("Linking MiNiFiMain against ${EXTENSION}")
 		target_link_libraries (minifiexe -Wl,-all_load ${EXTENSION})
 	endforeach()    
 else ()