diff options
Diffstat (limited to 'nokiav2/driver/src/test/java')
12 files changed, 245 insertions, 25 deletions
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java index f5f60fb1..4ed4bf27 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/FullUnitTestSuite.java @@ -30,11 +30,12 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi.*; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.TestConditions; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.TestRealConfig; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring.TestServletInitializer; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestCbamUtils; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestStoreLoader; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestSystemFunctions; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.*; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.*; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestLifecycleChangeNotificationManager; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestProcessedNotification; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestReportedAffectedConnectionPoints; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestReportedAffectedCp; @RunWith(Suite.class) @Suite.SuiteClasses({ @@ -68,6 +69,13 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestLifecycle TestCbamUtils.class, TestStoreLoader.class, TestSystemFunctions.class, + TestUserInvisibleError.class, + TestUserVisibleError.class, + + TestLifecycleChangeNotificationManager.class, + TestProcessedNotification.class, + TestReportedAffectedConnectionPoints.class, + TestReportedAffectedCp.class, TestAdditionalParams.class, TestCbamCatalogManager.class, @@ -75,10 +83,8 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.TestLifecycle TestDriverProperties.class, TestJobManager.class, TestVfcGrantManager.class, - TestLifecycleChangeNotificationManager.class, TestLifecycleManager.class, TestSelfRegistrationManager.class, - TestNokiaSvnfmApplication.class, }) diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestCbamRestApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestCbamRestApiProvider.java index 45a3216a..0d036a63 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestCbamRestApiProvider.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestCbamRestApiProvider.java @@ -26,7 +26,6 @@ import org.junit.Test; import org.mockito.Mock; import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo; import org.onap.msb.sdk.discovery.entity.NodeInfo; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.VnfmInfoProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.TestUtil; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamTokenProvider; @@ -61,7 +60,7 @@ public class TestCbamRestApiProvider extends TestBase { setField(real, "skipCertificateVerification", true); cbamRestApiProvider = spy(real); when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn(""); - when(environment.getProperty(VnfmInfoProvider.VNFM_INFO_CACHE_EVICTION_IN_MS, Long.class, Long.valueOf(10 * 60 * 1000))).thenReturn(10 * 60 * 1000L); + when(environment.getProperty(GenericExternalSystemInfoProvider.VNFM_INFO_CACHE_EVICTION_IN_MS, Long.class, Long.valueOf(10 * 60 * 1000))).thenReturn(10 * 60 * 1000L); } /** diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java index aec53e10..537093c3 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcExternalSystemInfoProvider.java @@ -63,8 +63,8 @@ public class TestVfcExternalSystemInfoProvider extends TestBase { vfcExternalSystemInfoProvider.getVimInfo(VIM_ID); fail(); } catch (Exception e) { - assertEquals("Unable to query VIM from VF-C with " + VIM_ID +" identifier", e.getMessage()); - verify(logger).error("Unable to query VIM from VF-C with " + VIM_ID+" identifier", expectedException); + assertEquals("Unable to query VIM from VF-C with " + VIM_ID + " identifier", e.getMessage()); + verify(logger).error("Unable to query VIM from VF-C with " + VIM_ID + " identifier", expectedException); } } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java index 7ca19d63..a2bf0305 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcGrantManager.java @@ -283,7 +283,6 @@ public class TestVfcGrantManager extends TestBase { assertBasicGrantAttributes(request, org.onap.vnfmdriver.model.OperationType.SCALEIN); } - /** * test grant request for healing */ @@ -303,6 +302,13 @@ public class TestVfcGrantManager extends TestBase { assertBasicGrantAttributes(request, org.onap.vnfmdriver.model.OperationType.HEAL); } + @Test + public void testPOJO() { + VfcGrantManager.AdditionalGrantParams additionalGrantParams = new VfcGrantManager.AdditionalGrantParams(VNFM_ID, VIM_ID); + assertEquals(VNFM_ID, additionalGrantParams.getVnfmId()); + assertEquals(VIM_ID, additionalGrantParams.getVimId()); + } + private void assertBasicGrantAttributes(GrantVNFRequest request, org.onap.vnfmdriver.model.OperationType type) { assertEquals(JOB_ID, request.getJobId()); assertEquals(type, request.getLifecycleOperation()); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java index 62ffdb4f..b027ccad 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/vfc/TestVfcPackageProvider.java @@ -107,7 +107,7 @@ public class TestVfcPackageProvider extends TestBase { vfcPackageProvider.getCbamVnfdId(CSAR_ID); fail(); } catch (Exception e) { - verify(logger).error("Unable to query VNF package with csarId from VF-C", expectedException); + verify(logger).error("Unable to query VNF package with csarId", expectedException); assertEquals(expectedException, e.getCause()); } } @@ -132,7 +132,7 @@ public class TestVfcPackageProvider extends TestBase { vfcPackageProvider.getPackage(CSAR_ID); fail(); } catch (Exception e) { - verify(logger).error("Unable to download package from http://1.2.3.4/a.csar from VF-C", expectedException); + verify(logger).error("Unable to download package from http://1.2.3.4/a.csar", expectedException); assertEquals(expectedException, e.getCause()); } } @@ -149,7 +149,7 @@ public class TestVfcPackageProvider extends TestBase { vfcPackageProvider.getPackage(CSAR_ID); fail(); } catch (Exception e) { - verify(logger).error("Unable to query VNF package with csarId from VF-C", expectedException); + verify(logger).error("Unable to query VNF package with csarId", expectedException); assertEquals(expectedException, e.getCause()); } } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestUserInvisibleError.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestUserInvisibleError.java new file mode 100644 index 00000000..214c1ca9 --- /dev/null +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestUserInvisibleError.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class TestUserInvisibleError { + + /** + * test POJO + */ + @Test + public void testPojo() throws Exception { + UserInvisibleError e = new UserInvisibleError("msg"); + assertEquals("msg", e.getMessage()); + Exception cause = new Exception(); + UserInvisibleError e2 = new UserInvisibleError("msg", cause); + assertEquals("msg", e2.getMessage()); + assertEquals(cause, e2.getCause()); + } + +}
\ No newline at end of file diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestUserVisibleError.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestUserVisibleError.java new file mode 100644 index 00000000..0a107640 --- /dev/null +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestUserVisibleError.java @@ -0,0 +1,38 @@ +/* + * Copyright 2016-2017, Nokia Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class TestUserVisibleError { + + /** + * test POJO + */ + @Test + public void testPojo() throws Exception { + UserVisibleError e = new UserVisibleError("msg"); + assertEquals("msg", e.getMessage()); + Exception cause = new Exception(); + UserVisibleError e2 = new UserVisibleError("msg", cause); + assertEquals("msg", e2.getMessage()); + assertEquals(cause, e2.getCause()); + } + +}
\ No newline at end of file diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java index 5f1d6007..7a1bf7f2 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java @@ -129,6 +129,10 @@ public class TestBase { when(response.getEntity()).thenReturn(entity); when(driverProperties.getVnfmId()).thenReturn(VNFM_ID); when(systemFunctions.getHttpClient()).thenReturn(httpClient); + when(logger.isInfoEnabled()).thenReturn(true); + when(logger.isDebugEnabled()).thenReturn(true); + when(logger.isWarnEnabled()).thenReturn(true); + when(logger.isErrorEnabled()).thenReturn(true); } @After diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java index 670aa77f..44ba0e52 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamTokenProvider.java @@ -42,10 +42,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.security.GeneralSecurityException; import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.cert.CertificateException; -import java.security.spec.InvalidKeySpecException; import java.util.ArrayList; import java.util.Base64; import java.util.List; @@ -321,7 +317,7 @@ public class TestCbamTokenProvider extends TestBase { //verify fail(); } catch (RuntimeException e) { - assertTrue(e.getMessage().contains("unable to find valid certification path")); + assertTrue(e.getCause().getCause().getMessage().contains("unable to find valid certification path")); assertTrue(e.getCause() instanceof SSLHandshakeException); } } @@ -361,7 +357,7 @@ public class TestCbamTokenProvider extends TestBase { //verify fail(); } catch (RuntimeException e) { - assertTrue(e.getMessage().contains("Hostname 127.0.0.1 not verified")); + assertTrue(e.getCause().getMessage().contains("Hostname 127.0.0.1 not verified")); assertTrue(e.getCause() instanceof SSLPeerUnverifiedException); } } @@ -382,7 +378,7 @@ public class TestCbamTokenProvider extends TestBase { //verify fail(); } catch (RuntimeException e) { - assertTrue(e.getMessage().contains("Unable to load certificates")); + assertEquals("Unable to load certificates", e.getMessage()); assertTrue(e.getCause() instanceof GeneralSecurityException); } } @@ -411,7 +407,7 @@ public class TestCbamTokenProvider extends TestBase { } @Override - TrustManager[] buildTrustManager() throws KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeySpecException, CertificateException { + TrustManager[] buildTrustManager() throws KeyStoreException { throw expectedException; } } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java index 1ba58abe..aa3d63c4 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java @@ -45,8 +45,8 @@ import java.util.concurrent.Future; import static junit.framework.TestCase.*; import static org.mockito.Mockito.*; +import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.SEPARATOR; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION; -import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager.SEPARATOR; import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager.extractOnapJobId; import static org.onap.vnfmdriver.model.JobStatus.*; diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java index 64adaab1..2c28bfc1 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java @@ -245,7 +245,7 @@ public class TestLifecycleManager extends TestBase { assertEquals(2, actualVnfModifyRequest.getValue().getExtensions().size()); assertEquals(LifecycleManager.ONAP_CSAR_ID, actualVnfModifyRequest.getValue().getExtensions().get(0).getName()); assertEquals(ONAP_CSAR_ID, actualVnfModifyRequest.getValue().getExtensions().get(0).getValue()); - assertEquals(ILifecycleChangeNotificationManager.EXTERNAL_VNFM_ID, actualVnfModifyRequest.getValue().getExtensions().get(1).getName()); + assertEquals(LifecycleManager.EXTERNAL_VNFM_ID, actualVnfModifyRequest.getValue().getExtensions().get(1).getName()); assertEquals(VNFM_ID, actualVnfModifyRequest.getValue().getExtensions().get(1).getValue()); //the 3.2 API does not accept empty array @@ -303,6 +303,34 @@ public class TestLifecycleManager extends TestBase { assertTrue(!actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck()); } + + /** + * non specified SSL verification means not verified + */ + @Test + public void testInstantiationV2WithoutSsl() throws Exception { + VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V2_INFO); + + when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(vnfInfo); + additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL); + when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse); + grantResponse.setVimId(VIM_ID); + GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo(); + accessInfo.setTenant(TENANT); + vimInfo.setSslInsecure(null); + grantResponse.setAccessInfo(accessInfo); + ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class); + when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution); + //when + VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse); + waitForJobToFinishInJobManager(finished); + assertEquals(1, actualInstantiationRequest.getValue().getVims().size()); + //verify + OPENSTACKV2INFO actualVim = (OPENSTACKV2INFO) actualInstantiationRequest.getValue().getVims().get(0); + assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification()); + assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck()); + } + /** * test instantiation with KeyStone V3 based */ @@ -380,6 +408,42 @@ public class TestLifecycleManager extends TestBase { } /** + * non specified SSL verification meams not verified for KeyStone V3 based + */ + @Test + public void testInstantiationV3WithNonSpecifiedSsl() throws Exception { + VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO); + + when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(vnfInfo); + additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL); + when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse); + grantResponse.setVimId(VIM_ID); + GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo(); + accessInfo.setTenant(TENANT); + vimInfo.setSslInsecure(null); + grantResponse.setAccessInfo(accessInfo); + ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class); + when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution); + //when + VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse); + waitForJobToFinishInJobManager(finished); + assertEquals(1, actualInstantiationRequest.getValue().getVims().size()); + //verify + OPENSTACKV3INFO actualVim = (OPENSTACKV3INFO) actualInstantiationRequest.getValue().getVims().get(0); + assertEquals(VIM_ID, actualVim.getId()); + assertEquals(VimInfo.VimInfoTypeEnum.OPENSTACK_V3_INFO, actualVim.getVimInfoType()); + assertEquals("cloudUrl", actualVim.getInterfaceInfo().getEndpoint()); + //FIXME assertEquals();actualVim.getInterfaceInfo().getTrustedCertificates()); + assertEquals("vimPassword", actualVim.getAccessInfo().getPassword()); + assertEquals("regionId", actualVim.getAccessInfo().getRegion()); + assertEquals("myTenant", actualVim.getAccessInfo().getProject()); + assertEquals("myDomain", actualVim.getAccessInfo().getDomain()); + assertEquals("vimUsername", actualVim.getAccessInfo().getUsername()); + assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification()); + assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck()); + } + + /** * test instantiation with vcloud */ @Test @@ -452,6 +516,40 @@ public class TestLifecycleManager extends TestBase { } /** + * test instantiation with vCloud with SSL + */ + @Test + public void testInstantiationVcloudWithNonSecifedSSl() throws Exception { + VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO); + + when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(vnfInfo); + additionalParam.setInstantiationLevel(INSTANTIATION_LEVEL); + when(vfcGrantManager.requestGrantForInstantiate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, INSTANTIATION_LEVEL, cbamVnfdContent, JOB_ID)).thenReturn(grantResponse); + grantResponse.setVimId(VIM_ID); + GrantVNFResponseVimAccessInfo accessInfo = new GrantVNFResponseVimAccessInfo(); + accessInfo.setTenant(TENANT); + vimInfo.setSslInsecure(null); + grantResponse.setAccessInfo(accessInfo); + ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class); + when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution); + //when + VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse); + waitForJobToFinishInJobManager(finished); + assertEquals(1, actualInstantiationRequest.getValue().getVims().size()); + //verify + VMWAREVCLOUDINFO actualVim = (VMWAREVCLOUDINFO) actualInstantiationRequest.getValue().getVims().get(0); + assertEquals(VIM_ID, actualVim.getId()); + assertEquals(VimInfo.VimInfoTypeEnum.VMWARE_VCLOUD_INFO, actualVim.getVimInfoType()); + assertEquals("cloudUrl", actualVim.getInterfaceInfo().getEndpoint()); + //FIXME assertEquals();actualVim.getInterfaceInfo().getTrustedCertificates()); + assertEquals("vimPassword", actualVim.getAccessInfo().getPassword()); + assertEquals("regionId", actualVim.getAccessInfo().getOrganization()); + assertEquals("vimUsername", actualVim.getAccessInfo().getUsername()); + assertTrue(actualVim.getInterfaceInfo().isSkipCertificateVerification()); + assertTrue(actualVim.getInterfaceInfo().isSkipCertificateHostnameCheck()); + } + + /** * test failure in the instantiation request marks the job to be finished in job manager */ @Test @@ -1059,6 +1157,41 @@ public class TestLifecycleManager extends TestBase { } /** + * the VNFM should tolerate that no additional params were supplied + */ + @Test + public void testScaleWithoutAddtionalParams() throws Exception { + VnfScaleRequest scaleRequest = new VnfScaleRequest(); + scaleRequest.setNumberOfSteps("2"); + scaleRequest.setAspectId("myAspect"); + scaleRequest.setType(ScaleDirection.IN); + scaleRequest.setAdditionalParam(null); + scaleOperationExecution.setStatus(OperationStatus.FINISHED); + when(vnfApi.vnfsVnfInstanceIdGet(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(vnfInfo); + VnfProperty prop = new VnfProperty(); + prop.setValue(ONAP_CSAR_ID); + prop.setName(LifecycleManager.ONAP_CSAR_ID); + vnfInfo.getExtensions().add(prop); + vnfInfo.getOperationExecutions().add(instantiationOperationExecution); + String instantiationParams = "{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] }"; + when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet(instantiationOperationExecution.getId(), NOKIA_LCM_API_VERSION)).thenReturn(new JsonParser().parse(instantiationParams)); + //when + JobInfo job = lifecycleManager.scaleVnf(VNFM_ID, VNF_ID, scaleRequest, restResponse); + //verify + waitForJobToFinishInJobManager(finished); + assertEquals(1, actualScaleRequest.getAllValues().size()); + ScaleVnfRequest sRequest = actualScaleRequest.getValue(); + InOrder workflowOrder = Mockito.inOrder(vfcGrantManager, vnfApi); + workflowOrder.verify(vfcGrantManager).requestGrantForScale(eq(VNFM_ID), eq(VNF_ID), eq(VIM_ID), eq(ONAP_CSAR_ID), eq(scaleRequest), eq(JOB_ID)); + workflowOrder.verify(vnfApi).vnfsVnfInstanceIdScalePost(VNF_ID, sRequest, NOKIA_LCM_API_VERSION); + assertEquals("myAspect", sRequest.getAspectId()); + assertEquals(com.nokia.cbam.lcm.v32.model.ScaleDirection.IN, sRequest.getType()); + assertEquals(Integer.valueOf(2), sRequest.getNumberOfSteps()); + assertEquals("{\"jobId\":\"myJobId\"}", new Gson().toJson(sRequest.getAdditionalParams())); + verify(jobManager).spawnJob(VNF_ID, restResponse); + } + + /** * test scale out basic scenario */ @Test diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java index ed009b97..e26eab1a 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java @@ -24,7 +24,7 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; import org.mockito.Mockito; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase; import org.threeten.bp.OffsetDateTime; @@ -93,7 +93,7 @@ public class TestLifecycleChangeNotificationManager extends TestBase { vnfs.add(vnf); vnf.setId(VNF_ID); VnfProperty prop = new VnfProperty(); - prop.setName(ILifecycleChangeNotificationManager.EXTERNAL_VNFM_ID); + prop.setName(LifecycleManager.EXTERNAL_VNFM_ID); prop.setValue(VNFM_ID); vnf.setExtensions(new ArrayList<>()); vnf.getExtensions().add(prop); |