@Test(expected = Exception.class) public void testLoadTrustStoreWithWrongPassword() throws Exception { String path = x509TestContext.getTrustStoreFile(KeyStoreFileType.JKS) .getAbsolutePath(); new JKSFileLoader.Builder() .setTrustStorePath(path) .setTrustStorePassword("wrong password") .build() .loadTrustStore(); }
@Test(expected = IOException.class) public void testLoadTrustStoreWithWrongFilePath() throws Exception { String path = x509TestContext.getTrustStoreFile(KeyStoreFileType.JKS) .getAbsolutePath(); new JKSFileLoader.Builder() .setTrustStorePath(path + ".does_not_exist") .setTrustStorePassword(x509TestContext.getTrustStorePassword()) .build() .loadTrustStore(); }
@Test(expected = IOException.class) public void testLoadTrustStoreWithWrongFileType() throws Exception { // Trying to load a PEM file with JKS loader should fail String path = x509TestContext.getTrustStoreFile(KeyStoreFileType.PEM) .getAbsolutePath(); new JKSFileLoader.Builder() .setTrustStorePath(path) .setTrustStorePassword(x509TestContext.getTrustStorePassword()) .build() .loadTrustStore(); } }
@Test public void testLoadTrustStore() throws Exception { String path = x509TestContext.getTrustStoreFile(KeyStoreFileType.JKS) .getAbsolutePath(); KeyStore ts = new JKSFileLoader.Builder() .setTrustStorePath(path) .setTrustStorePassword(x509TestContext.getTrustStorePassword()) .build() .loadTrustStore(); Assert.assertEquals(1, ts.size()); }