Fix use of bundle-name 36/92936/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 7 Oct 2020 12:05:49 +0000 (14:05 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 7 Oct 2020 12:06:26 +0000 (14:06 +0200)
The tests (and implementation) are not correctly using the mandatory
bundle-name parameter. Fix that.

Change-Id: Ie37850d9308841c75b9b76463bf116fea6bf8943
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
aaa-cert/src/main/java/org/opendaylight/aaa/cert/impl/DefaultMdsalSslData.java
aaa-cert/src/test/java/org/opendaylight/aaa/cert/test/AaaCertMdsalProviderTest.java
aaa-cert/src/test/java/org/opendaylight/aaa/cert/test/AaaCertRpcServiceImplTest.java
aaa-cert/src/test/java/org/opendaylight/aaa/cert/test/KeyStoresDataUtilsTest.java
aaa-cert/src/test/java/org/opendaylight/aaa/cert/test/MdsalUtilsTest.java

index 1b104978e2848dbfc1c19750048c1de3a125e570..d3c7fcc1bf23f8433af9053d0b02024dec77f931 100644 (file)
@@ -5,9 +5,10 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.aaa.cert.impl;
 
+import static java.util.Objects.requireNonNull;
+
 import com.google.common.base.MoreObjects;
 import java.security.KeyStore;
 import java.util.ArrayList;
@@ -39,7 +40,7 @@ public class DefaultMdsalSslData implements IAaaCertProvider {
 
     public DefaultMdsalSslData(final AaaCertMdsalProvider aaaCertMdsalProv, final String bundleName,
             final CtlKeystore ctlKeyStore, final TrustKeystore trustKeystore) {
-        this.bundleName = bundleName;
+        this.bundleName = requireNonNull(bundleName);
         this.aaaCertMdsalProv = aaaCertMdsalProv;
         this.ctlKeyStore = ctlKeyStore;
         this.trustKeystore = trustKeystore;
index 10f22bff6308a63d7fe9207f80c2bf259211d58e..3f331b56315f7ae586d87cb23ed32c662c40d6ad 100644 (file)
@@ -77,7 +77,7 @@ public class AaaCertMdsalProviderTest {
         final List<CipherSuites> cipherSuites = new ArrayList<>(Arrays.asList(cipherSuite));
 
         signedSslData = new SslDataBuilder().setCipherSuites(cipherSuites).setOdlKeystore(signedOdlKeystore)
-                .setTrustKeystore(signedTrustKeyStore).setTlsProtocols(PROTOCOL).build();
+                .setTrustKeystore(signedTrustKeyStore).setTlsProtocols(PROTOCOL).setBundleName(BUNDLE_NAME).build();
 
         final OdlKeystore unsignedOdlKeystore = new OdlKeystoreBuilder().setAlias(ALIAS).setDname(D_NAME)
                 .setName(ODL_NAME).setStorePassword(PASSWORD).setValidity(KeyStoreConstant.DEFAULT_VALIDITY)
@@ -86,7 +86,7 @@ public class AaaCertMdsalProviderTest {
                 .build();
 
         unsignedSslData = new SslDataBuilder().setOdlKeystore(unsignedOdlKeystore)
-                .setTrustKeystore(unsignedTrustKeyStore).build();
+                .setTrustKeystore(unsignedTrustKeyStore).setBundleName(BUNDLE_NAME).build();
 
         when(aaaEncryptionServiceInit.decrypt(unsignedTrustKeyStore.getKeystoreFile()))
                 .thenReturn(unsignedTrustKeyStore.getKeystoreFile());
index 47ca24939ed9e0a5a75293835ae216861c3ca758..e7792062e3f159895a1eabb035efaaa392846f3e 100644 (file)
@@ -90,7 +90,7 @@ public class AaaCertRpcServiceImplTest {
         final List<CipherSuites> cipherSuites = new ArrayList<>(Arrays.asList(cipherSuite));
 
         signedSslData = new SslDataBuilder().setCipherSuites(cipherSuites).setOdlKeystore(signedOdlKeystore)
-                .setTrustKeystore(signedTrustKeyStore).setTlsProtocols(PROTOCOL).build();
+                .setTrustKeystore(signedTrustKeyStore).setTlsProtocols(PROTOCOL).setBundleName(BUNDLE_NAME).build();
 
         final OdlKeystore unsignedOdlKeystore = new OdlKeystoreBuilder().setAlias(ALIAS).setDname(D_NAME)
                 .setName(ODL_NAME).setStorePassword(PASSWORD).setValidity(KeyStoreConstant.DEFAULT_VALIDITY)
@@ -99,7 +99,7 @@ public class AaaCertRpcServiceImplTest {
                 .build();
 
         unsignedSslData = new SslDataBuilder().setOdlKeystore(unsignedOdlKeystore)
-                .setTrustKeystore(unsignedTrustKeyStore).build();
+                .setTrustKeystore(unsignedTrustKeyStore).setBundleName(BUNDLE_NAME).build();
 
         when(aaaEncryptionServiceInit.decrypt(unsignedTrustKeyStore.getKeystoreFile()))
                 .thenReturn(unsignedTrustKeyStore.getKeystoreFile());
@@ -111,6 +111,7 @@ public class AaaCertRpcServiceImplTest {
         final AaaCertServiceConfig aaaCertServiceConfigInit = mock(AaaCertServiceConfig.class);
         when(aaaCertServiceConfigInit.isUseConfig()).thenReturn(true);
         when(aaaCertServiceConfigInit.isUseMdsal()).thenReturn(true);
+        when(aaaCertServiceConfigInit.getBundleName()).thenReturn(BUNDLE_NAME);
         aaaCertServiceConfig = aaaCertServiceConfigInit;
 
         // Create class
index a5cc8470b63c86e9be8dd2d88eafe5e581312f77..6d43435301036f358a7bd2d5d60131e7f0881984 100644 (file)
@@ -81,7 +81,7 @@ public class KeyStoresDataUtilsTest {
 
         final List<CipherSuites> cipherSuites = new ArrayList<>(Arrays.asList(cipherSuite));
         final SslData sslData = new SslDataBuilder().setOdlKeystore(odlKeystore).setTrustKeystore(trustKeyStore)
-                .build();
+                .setBundleName(BUNDLE_NAME).build();
 
         final ODLKeyTool odlKeyTool = new ODLKeyTool(TEST_PATH);
         final KeyStoresDataUtils keyStoresDataUtils = new KeyStoresDataUtils(AAA_ENCRYPTION_SERVICE);
index fe2c3a3645afc9c1fae8850c6a271c24e521e73b..3e148c3251ee7eeded24464d1c4ff7f30b07a2b8 100644 (file)
@@ -47,7 +47,8 @@ public class MdsalUtilsTest {
         final TrustKeystore trustKeyStore = new TrustKeystoreBuilder().setName(TRUST_NAME).setStorePassword(PASSWORD)
                 .build();
 
-        sslData = new SslDataBuilder().setOdlKeystore(odlKeystore).setTrustKeystore(trustKeyStore).build();
+        sslData = new SslDataBuilder().setOdlKeystore(odlKeystore).setTrustKeystore(trustKeyStore)
+            .setBundleName("bundle").build();
 
         final SslDataKey sslDataKey = new SslDataKey(BUNDLE_NAME);
         instanceIdentifier = InstanceIdentifier.create(KeyStores.class).child(SslData.class, sslDataKey);