mtien-apache commented on a change in pull request #4801:
URL: https://github.com/apache/nifi/pull/4801#discussion_r569029365



##########
File path: 
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenHTTP.java
##########
@@ -147,29 +126,84 @@
     private int availablePort;
 
     @BeforeClass
-    public static void setUpSuite() throws TlsException {
-        serverKeyStoreSslContext = 
SslContextFactory.createSslContext(SERVER_CONFIGURATION);
-        final TrustManager[] defaultTrustManagers = 
SslContextFactory.getTrustManagers(SERVER_NO_TRUSTSTORE_CONFIGURATION);
-        serverKeyStoreNoTrustStoreSslContext = 
SslContextFactory.createSslContext(SERVER_NO_TRUSTSTORE_CONFIGURATION, 
defaultTrustManagers);
+    public static void setUpSuite() throws GeneralSecurityException, 
IOException {
+        // generate new keystore and truststore
+        tlsConfiguration = 
KeyStoreUtils.createTlsConfigAndNewKeystoreTruststore();
+
+        serverConfiguration = new StandardTlsConfiguration(
+                tlsConfiguration.getKeystorePath(),
+                tlsConfiguration.getKeystorePassword(),
+                tlsConfiguration.getKeyPassword(),
+                tlsConfiguration.getKeystoreType(),
+                tlsConfiguration.getTruststorePath(),
+                tlsConfiguration.getTruststorePassword(),
+                tlsConfiguration.getTruststoreType(),
+                TLS_1_2
+        );
+        serverTls_1_3_Configuration = new StandardTlsConfiguration(
+                tlsConfiguration.getKeystorePath(),
+                tlsConfiguration.getKeystorePassword(),
+                tlsConfiguration.getKeyPassword(),
+                tlsConfiguration.getKeystoreType(),
+                tlsConfiguration.getTruststorePath(),
+                tlsConfiguration.getTruststorePassword(),
+                tlsConfiguration.getTruststoreType(),
+                TLS_1_3
+        );
+        serverNoTruststoreConfiguration = new StandardTlsConfiguration(
+                tlsConfiguration.getKeystorePath(),
+                tlsConfiguration.getKeystorePassword(),
+                tlsConfiguration.getKeyPassword(),
+                tlsConfiguration.getKeystoreType(),
+                null,
+                null,
+                null,
+                TLS_1_2
+        );
+
+        serverKeyStoreSslContext = 
SslContextFactory.createSslContext(serverConfiguration);
+        final TrustManager[] defaultTrustManagers = 
SslContextFactory.getTrustManagers(serverNoTruststoreConfiguration);
+        serverKeyStoreNoTrustStoreSslContext = 
SslContextFactory.createSslContext(serverNoTruststoreConfiguration, 
defaultTrustManagers);
 
         keyStoreSslContext = SslContextFactory.createSslContext(new 
StandardTlsConfiguration(
-                CLIENT_KEYSTORE,
-                KEYSTORE_PASSWORD,
-                CLIENT_KEYSTORE_TYPE,
-                TRUSTSTORE,
-                TRUSTSTORE_PASSWORD,
-                TRUSTSTORE_TYPE)
+                tlsConfiguration.getKeystorePath(),
+                tlsConfiguration.getKeystorePassword(),
+                tlsConfiguration.getKeystoreType(),
+                tlsConfiguration.getTruststorePath(),
+                tlsConfiguration.getTruststorePassword(),
+                tlsConfiguration.getTruststoreType())
         );
         trustStoreSslContext = SslContextFactory.createSslContext(new 
StandardTlsConfiguration(
                 null,
                 null,
                 null,
-                TRUSTSTORE,
-                TRUSTSTORE_PASSWORD,
-                TRUSTSTORE_TYPE)
+                tlsConfiguration.getTruststorePath(),
+                tlsConfiguration.getTruststorePassword(),
+                tlsConfiguration.getTruststoreType())
         );
     }
 
+    @AfterClass
+    public static void afterClass() throws Exception {
+        if (tlsConfiguration != null) {
+            try {
+                if 
(StringUtils.isNotBlank(tlsConfiguration.getKeystorePath())) {
+                    
java.nio.file.Files.deleteIfExists(Path.of(tlsConfiguration.getKeystorePath()));

Review comment:
       @exceptionfactory Fixed.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to