@Test public void testDefaultKeyCertOptionsJson() throws Exception { PemKeyCertOptions def = new PemKeyCertOptions(); PemKeyCertOptions json = new PemKeyCertOptions(new JsonObject()); assertEquals(def.getKeyPath(), json.getKeyPath()); assertEquals(def.getCertPath(), json.getCertPath()); assertEquals(def.getKeyValue(), json.getKeyValue()); assertEquals(def.getCertValue(), json.getCertValue()); }
@Test public void testPemKeyCertOptionsJson() throws Exception { PemKeyCertOptions options = new PemKeyCertOptions(new JsonObject()); assertEquals(null, options.getKeyPath()); assertEquals(null, options.getKeyValue()); assertEquals(null, options.getCertPath()); put("certPath", certPath1). put("certValue", certValue1.getBytes())); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); put("certPaths", new JsonArray().add(certPath1).add(certPath2)). put("certValues", new JsonArray().add(certValue1.getBytes()).add(certValue2.getBytes()))); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath());
options.setCertValue(certValue1); options = new PemKeyCertOptions(options); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); assertEquals(Collections.singletonList(certValue1), options.getCertValues()); options = new PemKeyCertOptions(options.toJson()); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); options.addCertValue(certValue2); options = new PemKeyCertOptions(options); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); assertEquals(Arrays.asList(certValue1, certValue2), options.getCertValues()); options = new PemKeyCertOptions(options.toJson()); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath());
@Test public void testKeyCertOptions() throws Exception { PemKeyCertOptions options = new PemKeyCertOptions(); assertNull(options.getKeyPath()); String randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setKeyPath(randString)); assertEquals(randString, options.getKeyPath()); assertNull(options.getCertPath()); randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setCertPath(randString)); assertEquals(randString, options.getCertPath()); }
@Test public void testPemKeyCertOptionsJson() throws Exception { PemKeyCertOptions options = new PemKeyCertOptions(new JsonObject()); assertEquals(null, options.getKeyPath()); assertEquals(null, options.getKeyValue()); assertEquals(null, options.getCertPath()); put("certPath", certPath1). put("certValue", certValue1.getBytes())); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); put("certPaths", new JsonArray().add(certPath1).add(certPath2)). put("certValues", new JsonArray().add(certValue1.getBytes()).add(certValue2.getBytes()))); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath());
@Test public void testKeyCertValue() throws Exception { PemKeyCertOptions options = Cert.SERVER_PEM.get(); Buffer key = vertx.fileSystem().readFileBlocking(options.getKeyPath()); options.setKeyValue(null).setKeyValue(key); Buffer cert = vertx.fileSystem().readFileBlocking(options.getCertPath()); options.setCertValue(null).setCertValue(cert); testKeyStore(options); }
options.setCertValue(certValue1); options = new PemKeyCertOptions(options); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); assertEquals(Collections.singletonList(certValue1), options.getCertValues()); options = new PemKeyCertOptions(options.toJson()); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); options.addCertValue(certValue2); options = new PemKeyCertOptions(options); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath()); assertEquals(Arrays.asList(certValue1, certValue2), options.getCertValues()); options = new PemKeyCertOptions(options.toJson()); assertEquals(keyPath1, options.getKeyPath()); assertEquals(keyValue1, options.getKeyValue()); assertEquals(certPath1, options.getCertPath());
@Test public void testDefaultKeyCertOptionsJson() throws Exception { PemKeyCertOptions def = new PemKeyCertOptions(); PemKeyCertOptions json = new PemKeyCertOptions(new JsonObject()); assertEquals(def.getKeyPath(), json.getKeyPath()); assertEquals(def.getCertPath(), json.getCertPath()); assertEquals(def.getKeyValue(), json.getKeyValue()); assertEquals(def.getCertValue(), json.getCertValue()); }
@Test public void testKeyCertOptions() throws Exception { PemKeyCertOptions options = new PemKeyCertOptions(); assertNull(options.getKeyPath()); String randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setKeyPath(randString)); assertEquals(randString, options.getKeyPath()); assertNull(options.getCertPath()); randString = TestUtils.randomAlphaString(100); assertEquals(options, options.setCertPath(randString)); assertEquals(randString, options.getCertPath()); }
@Test public void testKeyCertValue() throws Exception { PemKeyCertOptions options = Cert.SERVER_PEM.get(); Buffer key = vertx.fileSystem().readFileBlocking(options.getKeyPath()); options.setKeyValue(null).setKeyValue(key); Buffer cert = vertx.fileSystem().readFileBlocking(options.getCertPath()); options.setCertValue(null).setCertValue(cert); testKeyStore(options); }