Require key specification 88/110088/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 30 Jan 2024 00:23:05 +0000 (01:23 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 30 Jan 2024 00:23:59 +0000 (01:23 +0100)
We have a testing-only utility method. Ditch it in favor of supplying
the value from tests.

JIRA: NETCONF-1237
Change-Id: Ibe0a0f3c78365043401e5a80db00c3e841ac9027
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
plugins/netconf-client-mdsal/src/main/java/org/opendaylight/netconf/client/mdsal/impl/DefaultSslHandlerFactoryProvider.java
plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/impl/DefaultSslHandlerFactoryProviderTest.java

index 0ff13593744ce7818e6c37106e80124b2bffb43c..f26655eb2e93261f617503b58d198d7fb75d6700 100644 (file)
@@ -72,19 +72,6 @@ public final class DefaultSslHandlerFactoryProvider extends AbstractNetconfKeyst
         throw new IllegalArgumentException("Cannot get TLS specification from: " + specification);
     }
 
-    /**
-     * Using private keys and trusted certificates to create a new JDK <code>KeyStore</code> which
-     * will be used by TLS clients to create <code>SSLEngine</code>. The private keys are essential
-     * to create JDK <code>KeyStore</code> while the trusted certificates are optional.
-     *
-     * @return A JDK KeyStore object
-     * @throws GeneralSecurityException If any security exception occurred
-     * @throws IOException If there is an I/O problem with the keystore data
-     */
-    KeyStore getJavaKeyStore() throws GeneralSecurityException, IOException {
-        return getJavaKeyStore(Set.of());
-    }
-
     /**
      * Using private keys and trusted certificates to create a new JDK <code>KeyStore</code> which
      * will be used by TLS clients to create <code>SSLEngine</code>. The private keys are essential
index c59f62805a1bd27f43e34712bb8f8e1225d77370..08f41b46dbcba57dba058a45118943042a54e076 100644 (file)
@@ -18,6 +18,7 @@ import static org.mockito.Mockito.doReturn;
 import java.security.KeyStoreException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
@@ -78,7 +79,7 @@ class DefaultSslHandlerFactoryProviderTest {
     @Test
     void testKeystoreAdapterInit() throws Exception {
         try (var keystoreAdapter = new DefaultSslHandlerFactoryProvider(dataBroker)) {
-            final var ex = assertThrows(KeyStoreException.class, keystoreAdapter::getJavaKeyStore);
+            final var ex = assertThrows(KeyStoreException.class, () -> keystoreAdapter.getJavaKeyStore(Set.of()));
             assertThat(ex.getMessage(), startsWith("No keystore private key found"));
         }
     }
@@ -96,7 +97,7 @@ class DefaultSslHandlerFactoryProviderTest {
         try (var keystoreAdapter = new DefaultSslHandlerFactoryProvider(dataBroker)) {
             listener.onDataTreeChanged(List.of(dataTreeModification1));
 
-            final var keyStore = keystoreAdapter.getJavaKeyStore();
+            final var keyStore = keystoreAdapter.getJavaKeyStore(Set.of());
             assertTrue(keyStore.containsAlias(privateKey.getName()));
         }
     }
@@ -129,7 +130,7 @@ class DefaultSslHandlerFactoryProviderTest {
             listener.onDataTreeChanged(List.of(dataTreeModification1, dataTreeModification2));
 
             // Check result
-            final var keyStore = keystoreAdapter.getJavaKeyStore();
+            final var keyStore = keystoreAdapter.getJavaKeyStore(Set.of());
             assertTrue(keyStore.containsAlias(privateKey.getName()));
             assertTrue(keyStore.containsAlias(trustedCertificate.getName()));
         }