thenatog commented on a change in pull request #4250: URL: https://github.com/apache/nifi/pull/4250#discussion_r501273761
########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/leader/election/TestSecureClientZooKeeperFactory.java ########## @@ -0,0 +1,223 @@ +/* + * 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.leader.election; + +import org.apache.curator.retry.RetryOneTime; +import org.apache.curator.test.InstanceSpec; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; + +import org.apache.nifi.util.NiFiProperties; +import org.apache.nifi.properties.StandardNiFiProperties; +import org.apache.nifi.controller.cluster.ZooKeeperClientConfig; +import org.apache.nifi.controller.leader.election.CuratorLeaderElectionManager.SecureClientZooKeeperFactory; + +import org.apache.zookeeper.common.ClientX509Util; +import org.apache.zookeeper.data.Stat; +import org.apache.zookeeper.server.ServerCnxnFactory; +import org.apache.zookeeper.server.ZooKeeperServer; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.testng.Assert; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; + +public class TestSecureClientZooKeeperFactory { + + private static final String NETTY_SERVER_CNXN_FACTORY = + "org.apache.zookeeper.server.NettyServerCnxnFactory"; + + private static final String CLIENT_KEYSTORE = "src/test/resources/TestSecureClientZooKeeperFactory/client.keystore.p12"; + private static final String CLIENT_TRUSTSTORE = "src/test/resources/TestSecureClientZooKeeperFactory/client.truststore.p12"; + private static final String SERVER_KEYSTORE = "src/test/resources/TestSecureClientZooKeeperFactory/server.keystore.p12"; + private static final String SERVER_TRUSTSTORE = "src/test/resources/TestSecureClientZooKeeperFactory/server.truststore.p12"; + private static final String KEYSTORE_TYPE = "PKCS12"; + private static final String TEST_PASSWORD = "testpass"; + + private static ZooKeeperServer zkServer; + private static ServerCnxnFactory serverConnectionFactory; + private static Properties serverProperties; + private static NiFiProperties clientProperties; + private static Path tempDir; + private static Path dataDir; + private static int clientPort; + + @BeforeClass + public static void setup() throws IOException, GeneralSecurityException, InterruptedException { + tempDir = Paths.get("target/TestSecureClientZooKeeperFactory"); + dataDir = tempDir.resolve("state"); + clientPort = InstanceSpec.getRandomPort(); + + Files.createDirectory(tempDir); + + serverProperties = createServerProperties( Review comment: Are the serverProperties ever used? ---------------------------------------------------------------- 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]
