lordgamez commented on code in PR #1895:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1895#discussion_r1981324144
##########
extensions/standard-processors/tests/unit/YamlConfigurationTests.cpp:
##########
@@ -2033,4 +2009,224 @@ Parameter Context Name: c-context
CHECK(value == "5");
}
+TEST_CASE("Parameter providers can be used for parameter values",
"[YamlConfiguration]") {
+ ConfigurationTestController test_controller;
+ core::YamlConfiguration yaml_config(test_controller.getContext());
+
+ static const std::string TEST_CONFIG_YAML =
+ R"(
+MiNiFi Config Version: 3
+Flow Controller:
+ name: flow
+Parameter Providers:
+ - id: 721e10b7-8e00-3188-9a27-476cca376978
+ name: DummyParameterProvider
+ type: DummyParameterProvider
+ Properties:
+ Dummy1 Value: value1
+ Dummy2 Value: value2
+ Dummy3 Value: value3
+Processors:
+- id: b0c04f28-0158-1000-0000-000000000000
+ name: DummyProcessor
+ class: org.apache.nifi.processors.DummyProcessor
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ auto-terminated relationships list: [success]
+ Properties:
+ Simple Property: "#{dummy1}"
+ My Dynamic Property Sequence:
+ - value: "#{dummy2}"
+ - value: "#{dummy3}"
+Parameter Context Name: dummycontext
+ )";
+
+ std::unique_ptr<core::ProcessGroup> flow =
yaml_config.getRootFromPayload(TEST_CONFIG_YAML);
+ REQUIRE(flow);
+
+ auto* proc = flow->findProcessorByName("DummyProcessor");
+ REQUIRE(proc);
+ REQUIRE(proc->getProperty("Simple Property") == "value1");
+ core::Property property("My Dynamic Property Sequence", "");
+ proc->getDynamicProperty("My Dynamic Property Sequence", property);
+ auto values = property.getValues();
+ REQUIRE(values.size() == 2);
+ CHECK(values[0] == "value2");
+ CHECK(values[1] == "value3");
+}
+
+TEST_CASE("Parameter providers can be configured to select which parameters to
be sensitive", "[YamlConfiguration]") {
+ ConfigurationTestController test_controller;
+ auto context = test_controller.getContext();
+ auto encrypted_sensitive_property_value =
minifi::utils::crypto::property_encryption::encrypt("#{dummy1}",
*context.sensitive_values_encryptor);
+ core::YamlConfiguration yaml_config(context);
+
+ static const std::string TEST_CONFIG_YAML =
+ fmt::format(R"(
+MiNiFi Config Version: 3
+Flow Controller:
+ name: flowconfig
+Parameter Providers:
+ - id: 721e10b7-8e00-3188-9a27-476cca376978
+ name: DummyParameterProvider
+ type: DummyParameterProvider
+ Properties:
+ Sensitive Parameter Scope: selected
+ Sensitive Parameter List: dummy1
+ Dummy1 Value: value1
+ Dummy3 Value: value3
+Processors:
+- id: b0c04f28-0158-1000-0000-000000000000
+ name: DummyProcessor
+ class: org.apache.nifi.processors.DummyProcessor
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ auto-terminated relationships list: [success]
+ Properties:
+ Simple Property: "#{{dummy3}}"
+ Sensitive Property: {}
+Parameter Context Name: dummycontext
+ )", encrypted_sensitive_property_value);
+
+ std::unique_ptr<core::ProcessGroup> flow =
yaml_config.getRootFromPayload(TEST_CONFIG_YAML);
+ REQUIRE(flow);
+
+ auto* proc = flow->findProcessorByName("DummyProcessor");
+ REQUIRE(proc);
+ REQUIRE(proc->getProperty("Sensitive Property") == "value1");
+ REQUIRE(proc->getProperty("Simple Property") == "value3");
+}
+
+TEST_CASE("Parameter providers can be configured to make all parameters
sensitive", "[YamlConfiguration]") {
+ ConfigurationTestController test_controller;
+ auto context = test_controller.getContext();
+ auto encrypted_sensitive_property_value =
minifi::utils::crypto::property_encryption::encrypt("#{dummy1}",
*context.sensitive_values_encryptor);
+ core::YamlConfiguration yaml_config(context);
+
+ static const std::string TEST_CONFIG_YAML =
+ fmt::format(R"(
+MiNiFi Config Version: 3
+Flow Controller:
+ name: flowconfig
+Parameter Providers:
+ - id: 721e10b7-8e00-3188-9a27-476cca376978
+ name: DummyParameterProvider
+ type: DummyParameterProvider
+ Properties:
+ Sensitive Parameter Scope: all
+ Dummy1 Value: value1
+Processors:
+- id: b0c04f28-0158-1000-0000-000000000000
+ name: DummyProcessor
+ class: org.apache.nifi.processors.DummyProcessor
+ max concurrent tasks: 1
+ scheduling strategy: TIMER_DRIVEN
+ scheduling period: 1 sec
+ auto-terminated relationships list: [success]
+ Properties:
+ Sensitive Property: {}
Review Comment:
The parameter provider generated parameter contexts behave the same way user
defined parameter contexts do, all sensitive parameters and parameter
references are encrypted similarly to sensitive properties.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]