SSLStoreOverlay extends AbstractContainerOverlay { @Override public void configure(ContainerSpecification container) throws IOException { if(keystore != null) { container.getArtifacts().add(ContainerSpecification.Artifact.newBuilder() .setSource(keystore) .setDest(TARGET_KEYSTORE_PATH) .setCachable(false) .build()); container.getDynamicConfiguration().setString(SecurityOptions.SSL_KEYSTORE, TARGET_KEYSTORE_PATH.getPath()); } if(truststore != null) { container.getArtifacts().add(ContainerSpecification.Artifact.newBuilder() .setSource(truststore) .setDest(TARGET_TRUSTSTORE_PATH) .setCachable(false) .build()); container.getDynamicConfiguration().setString(SecurityOptions.SSL_TRUSTSTORE, TARGET_TRUSTSTORE_PATH.getPath()); } } SSLStoreOverlay(@Nullable File keystoreFile, @Nullable File truststoreFile); @Override void configure(ContainerSpecification container); static Builder newBuilder();  }
@Test public void testConfigure() throws Exception { File keystore = tempFolder.newFile(); File truststore = tempFolder.newFile(); SSLStoreOverlay overlay = new SSLStoreOverlay(keystore, truststore); ContainerSpecification spec = new ContainerSpecification(); overlay.configure(spec); assertEquals(TARGET_KEYSTORE_PATH.getPath(), spec.getDynamicConfiguration().getString(SecurityOptions.SSL_KEYSTORE)); checkArtifact(spec, TARGET_KEYSTORE_PATH); assertEquals(TARGET_TRUSTSTORE_PATH.getPath(), spec.getDynamicConfiguration().getString(SecurityOptions.SSL_TRUSTSTORE)); checkArtifact(spec, TARGET_TRUSTSTORE_PATH); }
@Test public void testNoConf() throws Exception { SSLStoreOverlay overlay = new SSLStoreOverlay(null, null); ContainerSpecification containerSpecification = new ContainerSpecification(); overlay.configure(containerSpecification); }