Search in sources :

Example 1 with OutputStreamFactory

use of org.apache.nifi.toolkit.tls.util.OutputStreamFactory in project nifi by apache.

the class TlsCertificateAuthorityTest method setup.

@Before
public void setup() throws FileNotFoundException {
    objectMapper = new ObjectMapper();
    serverConfigFile = new File("fake.server.config");
    clientConfigFile = new File("fake.client.config");
    String serverKeyStore = "serverKeyStore";
    String clientKeyStore = "clientKeyStore";
    String clientTrustStore = "clientTrustStore";
    serverKeyStoreOutputStream = new ByteArrayOutputStream();
    clientKeyStoreOutputStream = new ByteArrayOutputStream();
    clientTrustStoreOutputStream = new ByteArrayOutputStream();
    serverConfigFileOutputStream = new ByteArrayOutputStream();
    clientConfigFileOutputStream = new ByteArrayOutputStream();
    String myTestTokenUseSomethingStronger = "myTestTokenUseSomethingStronger";
    int port = availablePort();
    serverConfig = new TlsConfig();
    serverConfig.setCaHostname("localhost");
    serverConfig.setToken(myTestTokenUseSomethingStronger);
    serverConfig.setKeyStore(serverKeyStore);
    serverConfig.setPort(port);
    serverConfig.setDays(5);
    serverConfig.setKeySize(2048);
    serverConfig.initDefaults();
    clientConfig = new TlsClientConfig();
    clientConfig.setCaHostname("localhost");
    clientConfig.setDn("OU=NIFI,CN=otherHostname");
    clientConfig.setKeyStore(clientKeyStore);
    clientConfig.setTrustStore(clientTrustStore);
    clientConfig.setToken(myTestTokenUseSomethingStronger);
    clientConfig.setPort(port);
    clientConfig.setKeySize(2048);
    clientConfig.initDefaults();
    outputStreamFactory = mock(OutputStreamFactory.class);
    mockReturnOutputStream(outputStreamFactory, new File(serverKeyStore), serverKeyStoreOutputStream);
    mockReturnOutputStream(outputStreamFactory, new File(clientKeyStore), clientKeyStoreOutputStream);
    mockReturnOutputStream(outputStreamFactory, new File(clientTrustStore), clientTrustStoreOutputStream);
    mockReturnOutputStream(outputStreamFactory, serverConfigFile, serverConfigFileOutputStream);
    mockReturnOutputStream(outputStreamFactory, clientConfigFile, clientConfigFileOutputStream);
    inputStreamFactory = mock(InputStreamFactory.class);
    mockReturnProperties(inputStreamFactory, serverConfigFile, serverConfig);
    mockReturnProperties(inputStreamFactory, clientConfigFile, clientConfig);
}
Also used : TlsClientConfig(org.apache.nifi.toolkit.tls.configuration.TlsClientConfig) OutputStreamFactory(org.apache.nifi.toolkit.tls.util.OutputStreamFactory) TlsConfig(org.apache.nifi.toolkit.tls.configuration.TlsConfig) ByteArrayOutputStream(java.io.ByteArrayOutputStream) InputStreamFactory(org.apache.nifi.toolkit.tls.util.InputStreamFactory) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 TlsClientConfig (org.apache.nifi.toolkit.tls.configuration.TlsClientConfig)1 TlsConfig (org.apache.nifi.toolkit.tls.configuration.TlsConfig)1 InputStreamFactory (org.apache.nifi.toolkit.tls.util.InputStreamFactory)1 OutputStreamFactory (org.apache.nifi.toolkit.tls.util.OutputStreamFactory)1 Before (org.junit.Before)1