You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/09/29 19:30:52 UTC

[GitHub] [nifi] exceptionfactory opened a new pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

exceptionfactory opened a new pull request #5424:
URL: https://github.com/apache/nifi/pull/5424


   #### Description of PR
   
   NIFI-9254 Updates the default Sensitive Properties Algorithm and Sensitive Properties Key values for NiFi Stateless to more secure settings.  Following the default configuration of the NiFi framework, `NIFI_PBKDF2_AES_GCM_256` is the new standard Sensitive Properties Algorithm, replacing the deprecated `PBEWITHMD5AND256BITAES-CBC-OPENSSL` setting.
   
   Changes also include replacing a hard-coded default Sensitive Properties Key with a random UUID.
   
   Additional changes include a new unit test for parsing Stateless properties and confirming random Sensitive Properties Key generation.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [X] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [X] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [X] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [X] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [X] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [X] Have you written or updated unit tests to verify your changes?
   - [X] Have you verified that the full build is successful on JDK 8?
   - [X] Have you verified that the full build is successful on JDK 11?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? 
   - [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
   


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markobean commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
markobean commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720261874



##########
File path: nifi-stateless/nifi-stateless-api/src/test/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParserTest.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.stateless.config;
+
+import org.apache.nifi.stateless.engine.StatelessEngineConfiguration;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class PropertiesFileEngineConfigurationParserTest {
+    private PropertiesFileEngineConfigurationParser parser;
+
+    private static Path narDirectory;
+
+    private static Path workingDirectory;
+
+    @BeforeAll
+    public static void setDirectories() throws IOException {
+        narDirectory = Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+        workingDirectory = Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+    }
+
+    @AfterAll
+    public static void deleteDirectories() throws IOException {
+        Files.deleteIfExists(narDirectory);
+        Files.deleteIfExists(workingDirectory);
+    }
+
+    @BeforeEach
+    public void setParser() {
+        parser = new PropertiesFileEngineConfigurationParser();
+    }
+
+    @Test
+    public void testParseEngineConfigurationRequiredProperties() throws IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+        assertEquals(narDirectory.toFile(), configuration.getNarDirectory());
+        assertEquals(workingDirectory.toFile(), configuration.getWorkingDirectory());
+    }
+
+    @Test
+    public void testParseEngineConfigurationRandomSensitivePropsKey() throws IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+
+        final String sensitivePropsKey = configuration.getSensitivePropsKey();
+        assertNotNull(sensitivePropsKey);
+        assertFalse(sensitivePropsKey.isEmpty());
+
+        final StatelessEngineConfiguration reloadedConfiguration = parser.parseEngineConfiguration(propertiesFile);
+        assertEquals(sensitivePropsKey, reloadedConfiguration.getSensitivePropsKey());
+    }
+
+    private Properties getRequiredProperties() {
+        final Properties properties = new Properties();
+
+        properties.setProperty("nifi.stateless.nar.directory", narDirectory.toString());

Review comment:
       Are these the only properties required of stateless?
   (Is there a separate admin guide specifically for stateless?)




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720341021



##########
File path: nifi-stateless/nifi-stateless-api/src/main/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParser.java
##########
@@ -218,4 +223,24 @@ private String getRequired(final Properties properties, final String key) throws
         return propertyValue.trim();
     }
 
+    private String getSensitivePropsKey(final File propertiesFile, final Properties properties) {

Review comment:
       Yes, we definitely want to avoid depending on `nifi-security-utils` given the other transitive dependencies included. It is something to keep in mind for the future.




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720300509



##########
File path: nifi-stateless/nifi-stateless-bundle/nifi-stateless-engine/src/main/java/org/apache/nifi/stateless/flow/StandardStatelessDataflowFactory.java
##########
@@ -83,14 +81,12 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
 
 public class StandardStatelessDataflowFactory implements StatelessDataflowFactory<VersionedFlowSnapshot> {
     private static final Logger logger = LoggerFactory.getLogger(StandardStatelessDataflowFactory.class);
-    private static final EncryptionMethod ENCRYPTION_METHOD = EncryptionMethod.MD5_256AES;
+    private static final String PROPERTY_ENCRYPTION_METHOD = "NIFI_PBKDF2_AES_GCM_256";

Review comment:
       Thanks @markobean, that makes sense, I will make the change.




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720338247



##########
File path: nifi-stateless/nifi-stateless-bundle/nifi-stateless-engine/src/main/java/org/apache/nifi/stateless/flow/StandardStatelessDataflowFactory.java
##########
@@ -167,7 +163,9 @@ private synchronized PropertyEncryptor getEncryptor() {
                         return created;
                     }
 
-                    created = getPropertyEncryptor(engineConfiguration.getSensitivePropsKey());
+                    created = new PropertyEncryptorBuilder(engineConfiguration.getSensitivePropsKey())

Review comment:
       That's a good question.
   
   I raised a similar question on the initial implementation PR, and at the time, the goal was to keep Stateless as simple as possible. Given that the previous default value in `nifi.properties` remained unchanged for many releases, making this configurable does not seem to provide a great deal of value.
   
   In the future, it may also make sense to deprecate and remove the ability to configure this in `nifi.properties`, and instead prefer a sensible default value. This could be addressed in a separate issue if there are other reasons to make it configurable.




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] markobean commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
markobean commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720284171



##########
File path: nifi-stateless/nifi-stateless-bundle/nifi-stateless-engine/src/main/java/org/apache/nifi/stateless/flow/StandardStatelessDataflowFactory.java
##########
@@ -83,14 +81,12 @@
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
 
 public class StandardStatelessDataflowFactory implements StatelessDataflowFactory<VersionedFlowSnapshot> {
     private static final Logger logger = LoggerFactory.getLogger(StandardStatelessDataflowFactory.class);
-    private static final EncryptionMethod ENCRYPTION_METHOD = EncryptionMethod.MD5_256AES;
+    private static final String PROPERTY_ENCRYPTION_METHOD = "NIFI_PBKDF2_AES_GCM_256";

Review comment:
       Suggest referencing the enum directly rather than a String PropertyEncryptionMethod.NIFI_PBKDF2_AES_GCM_256.toString()
   This requires making the enum public. Do you see a problem with that?




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720335046



##########
File path: nifi-stateless/nifi-stateless-api/src/main/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParser.java
##########
@@ -218,4 +223,24 @@ private String getRequired(final Properties properties, final String key) throws
         return propertyValue.trim();
     }
 
+    private String getSensitivePropsKey(final File propertiesFile, final Properties properties) {

Review comment:
       I considered that, but also wanted to avoid complicating the dependency tree.  The `nifi-stateless-api` has no dependencies other than `nifi-api`, and should definitely avoid depending on `nifi-properties` or `nifi-properties-loader`. A new module is one option, but it seems a bit much for a single class and method. What do you think?




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] gresockj commented on pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
gresockj commented on pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#issuecomment-932508832


   I'm going to go ahead and merge this, nice work, @exceptionfactory!


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720319132



##########
File path: nifi-stateless/nifi-stateless-api/src/test/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParserTest.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.stateless.config;
+
+import org.apache.nifi.stateless.engine.StatelessEngineConfiguration;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class PropertiesFileEngineConfigurationParserTest {
+    private PropertiesFileEngineConfigurationParser parser;
+
+    private static Path narDirectory;
+
+    private static Path workingDirectory;
+
+    @BeforeAll
+    public static void setDirectories() throws IOException {
+        narDirectory = Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+        workingDirectory = Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+    }
+
+    @AfterAll
+    public static void deleteDirectories() throws IOException {
+        Files.deleteIfExists(narDirectory);
+        Files.deleteIfExists(workingDirectory);
+    }
+
+    @BeforeEach
+    public void setParser() {
+        parser = new PropertiesFileEngineConfigurationParser();
+    }
+
+    @Test
+    public void testParseEngineConfigurationRequiredProperties() throws IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+        assertEquals(narDirectory.toFile(), configuration.getNarDirectory());
+        assertEquals(workingDirectory.toFile(), configuration.getWorkingDirectory());
+    }
+
+    @Test
+    public void testParseEngineConfigurationRandomSensitivePropsKey() throws IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+
+        final String sensitivePropsKey = configuration.getSensitivePropsKey();
+        assertNotNull(sensitivePropsKey);
+        assertFalse(sensitivePropsKey.isEmpty());
+
+        final StatelessEngineConfiguration reloadedConfiguration = parser.parseEngineConfiguration(propertiesFile);
+        assertEquals(sensitivePropsKey, reloadedConfiguration.getSensitivePropsKey());
+    }
+
+    private Properties getRequiredProperties() {
+        final Properties properties = new Properties();
+
+        properties.setProperty("nifi.stateless.nar.directory", narDirectory.toString());

Review comment:
       @markobean The [README.md](https://github.com/apache/nifi/blob/main/nifi-stateless/nifi-stateless-assembly/README.md) for Stateless provides current documentation on properties. Since it is still a work-in-progress, the details should be promoted to standard documentation in the future.




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] gresockj commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
gresockj commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720329803



##########
File path: nifi-stateless/nifi-stateless-bundle/nifi-stateless-engine/src/main/java/org/apache/nifi/stateless/flow/StandardStatelessDataflowFactory.java
##########
@@ -167,7 +163,9 @@ private synchronized PropertyEncryptor getEncryptor() {
                         return created;
                     }
 
-                    created = getPropertyEncryptor(engineConfiguration.getSensitivePropsKey());
+                    created = new PropertyEncryptorBuilder(engineConfiguration.getSensitivePropsKey())

Review comment:
       What do you think about making the algorithm provided by the stateless properties instead of hard coding it here?  I suppose this could always be added later if we wanted to be more consistent with NiFi, and perhaps the use case is already so small for sensitive props key that hard-coding is acceptable here.  However, I wanted to pose the question here.

##########
File path: nifi-stateless/nifi-stateless-api/src/main/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParser.java
##########
@@ -218,4 +223,24 @@ private String getRequired(final Properties properties, final String key) throws
         return propertyValue.trim();
     }
 
+    private String getSensitivePropsKey(final File propertiesFile, final Properties properties) {

Review comment:
       What do you think about pulling some of this logic into a common utility to be used by both `NiFiPropertiesLoader` and this class?




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] asfgit closed pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #5424:
URL: https://github.com/apache/nifi/pull/5424


   


-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] gresockj commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
gresockj commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720338479



##########
File path: nifi-stateless/nifi-stateless-api/src/main/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParser.java
##########
@@ -218,4 +223,24 @@ private String getRequired(final Properties properties, final String key) throws
         return propertyValue.trim();
     }
 
+    private String getSensitivePropsKey(final File propertiesFile, final Properties properties) {

Review comment:
       I was thinking something along the lines of `nifi-commons/nifi-security-utils`, but I see now that it has a dependency on `nifi-api`.  I agree that a new module would be a bit heavy-handed in this case, so perhaps a small amount of duplication here is acceptable.




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [nifi] exceptionfactory commented on a change in pull request #5424: NIFI-9254 Updated default Stateless Sensitive Property configuration

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720270104



##########
File path: nifi-stateless/nifi-stateless-api/src/test/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParserTest.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.stateless.config;
+
+import org.apache.nifi.stateless.engine.StatelessEngineConfiguration;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class PropertiesFileEngineConfigurationParserTest {
+    private PropertiesFileEngineConfigurationParser parser;
+
+    private static Path narDirectory;
+
+    private static Path workingDirectory;
+
+    @BeforeAll
+    public static void setDirectories() throws IOException {
+        narDirectory = Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+        workingDirectory = Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+    }
+
+    @AfterAll
+    public static void deleteDirectories() throws IOException {
+        Files.deleteIfExists(narDirectory);
+        Files.deleteIfExists(workingDirectory);
+    }
+
+    @BeforeEach
+    public void setParser() {
+        parser = new PropertiesFileEngineConfigurationParser();
+    }
+
+    @Test
+    public void testParseEngineConfigurationRequiredProperties() throws IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+        assertEquals(narDirectory.toFile(), configuration.getNarDirectory());
+        assertEquals(workingDirectory.toFile(), configuration.getWorkingDirectory());
+    }
+
+    @Test
+    public void testParseEngineConfigurationRandomSensitivePropsKey() throws IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+
+        final String sensitivePropsKey = configuration.getSensitivePropsKey();
+        assertNotNull(sensitivePropsKey);
+        assertFalse(sensitivePropsKey.isEmpty());
+
+        final StatelessEngineConfiguration reloadedConfiguration = parser.parseEngineConfiguration(propertiesFile);
+        assertEquals(sensitivePropsKey, reloadedConfiguration.getSensitivePropsKey());
+    }
+
+    private Properties getRequiredProperties() {
+        final Properties properties = new Properties();
+
+        properties.setProperty("nifi.stateless.nar.directory", narDirectory.toString());

Review comment:
       These are the only properties currently required for the stateless parser to return a configuration. Several other properties fall back to default values, so as long as these two properties are present, and the directories exist, the parser returns a working configuration.
   
   I am not aware additional documentation for Stateless properties, so that would be great to address in a separate issue.




-- 
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: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org