summaryrefslogtreecommitdiffstats
path: root/adapters/mso-vnfm-adapter
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2020-03-30 13:18:20 +0100
committerwaqas.ikram <waqas.ikram@est.tech>2020-03-30 17:08:46 +0100
commitddfefce97393d3f841cba811c3f6a20989cddec9 (patch)
tree35c0e2c15fc62962258df2ef5dee996b13cd740a /adapters/mso-vnfm-adapter
parent79d1e0244ce1f01f76640491dd6fca23420212cd (diff)
Fix for SO-2678
Change-Id: I2eea767e451e8570e6cc40d2ade3b8c6661f0a8b Issue-ID: SO-2678 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'adapters/mso-vnfm-adapter')
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java10
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterUrlProvider.java105
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java60
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java72
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java71
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java55
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java49
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java16
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java46
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java2
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java27
11 files changed, 334 insertions, 179 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
index 87e8bb4d57..bb2730bd2b 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java
@@ -28,6 +28,7 @@ import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.PkgOnboard
import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.VnfPkgInfoConverter;
import org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog.PkgmSubscriptionRequestConverter;
import org.onap.so.adapters.vnfmadapter.oauth.OAuth2AccessTokenAdapter;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -43,10 +44,17 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken;
@Configuration
public class MessageConverterConfiguration {
+ private final VnfmAdapterUrlProvider vnfmAdapterUrlProvider;
+
+ @Autowired
+ public MessageConverterConfiguration(final VnfmAdapterUrlProvider vnfmAdapterUrlProvider) {
+ this.vnfmAdapterUrlProvider = vnfmAdapterUrlProvider;
+ }
+
@Bean
public ConversionService conversionService() {
final DefaultConversionService service = new DefaultConversionService();
- service.addConverter(new VnfPkgInfoConverter());
+ service.addConverter(new VnfPkgInfoConverter(vnfmAdapterUrlProvider));
service.addConverter(new PkgmSubscriptionRequestConverter());
service.addConverter(new PkgChangeNotificationConverter());
service.addConverter(new PkgOnboardingNotificationConverter());
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterUrlProvider.java
new file mode 100644
index 0000000000..411a57069f
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterUrlProvider.java
@@ -0,0 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter;
+
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
+import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.net.URI;
+import java.security.GeneralSecurityException;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.onap.so.utils.CryptoUtils;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+
+/**
+ * Provides VNFM Adapter endpoint URLs
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+@Configuration
+public class VnfmAdapterUrlProvider {
+
+ private static final Logger logger = getLogger(VnfmAdapterUrlProvider.class);
+ private static final String COLON = ":";
+ private static final int LIMIT = 2;
+
+ private final String vnfmAdapterEndpoint;
+ private final String msoKeyString;
+ private final String vnfmAdapterAuth;
+
+ @Autowired
+ public VnfmAdapterUrlProvider(@Value("${vnfmadapter.endpoint}") final String vnfmAdapterEndpoint,
+ @Value("${mso.key}") final String msoKeyString,
+ @Value("${vnfmadapter.auth:BF29BA36F0CFE1C05507781F6B97EFBCA7EFAC9F595954D465FC43F646883EF585C20A58CBB02528A6FAAC}") final String vnfmAdapterAuth) {
+ this.vnfmAdapterEndpoint = vnfmAdapterEndpoint;
+ this.msoKeyString = msoKeyString;
+ this.vnfmAdapterAuth = vnfmAdapterAuth;
+ }
+
+ public String getEtsiSubscriptionNotificationBaseUrl() {
+ return vnfmAdapterEndpoint + ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL;
+ }
+
+ public URI getSubscriptionUri(final String subscriptionId) {
+ return URI.create(getSubscriptionUriString(subscriptionId));
+ }
+
+ public ImmutablePair<String, String> getDecryptAuth() throws GeneralSecurityException {
+ final String decryptedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoKeyString);
+ final String[] auth = decryptedAuth.split(COLON, LIMIT);
+ if (auth.length > 1) {
+ return ImmutablePair.of(auth[0], auth[1]);
+ }
+ logger.error("Unexpected auth value: {}", vnfmAdapterAuth);
+ return ImmutablePair.nullPair();
+ }
+
+ public String getSubscriptionUriString(final String subscriptionId) {
+ return vnfmAdapterEndpoint + PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions/" + subscriptionId;
+ }
+
+ public String getVnfLcmOperationOccurrenceNotificationUrl() {
+ return vnfmAdapterEndpoint + BASE_URL + OPERATION_NOTIFICATION_ENDPOINT;
+ }
+
+ public String getVnfPackageUrl(final String vnfPkgId) {
+ return vnfmAdapterEndpoint + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + vnfPkgId;
+ }
+
+ public String getVnfPackageVnfdUrl(final String vnfPkgId) {
+ return getVnfPackageUrl(vnfPkgId) + "/vnfd";
+ }
+
+ public String getVnfPackageContentUrl(final String vnfPkgId) {
+ return getVnfPackageUrl(vnfPkgId) + "/package_content";
+ }
+
+ public String getOauthTokenUrl() {
+ return vnfmAdapterEndpoint + "/oauth/token";
+ }
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java
index 160b875374..ee941f6951 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java
@@ -22,22 +22,22 @@ package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003;
import java.util.ArrayList;
import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.convert.converter.Converter;
-import org.springframework.stereotype.Service;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterUrlProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Checksum;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VNFPKGMLinkSerializer;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageArtifactInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesChecksum;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesSoftwareImages;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesAdditionalArtifacts;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageArtifactInfo;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesChecksum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinks;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VNFPKGMLinkSerializer;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Checksum;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.UriLink;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesSoftwareImages;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Service;
/**
* Converter to convert from an Etsi Catalog Manager {@link VnfPkgInfo} Object to its equivalent SOL003 Object
@@ -48,6 +48,11 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.UriLink;
@Service
public class VnfPkgInfoConverter implements Converter<VnfPkgInfo, InlineResponse2001> {
private static final Logger logger = LoggerFactory.getLogger(VnfPkgInfoConverter.class);
+ private final VnfmAdapterUrlProvider vnfmAdapterUrlProvider;
+
+ public VnfPkgInfoConverter(final VnfmAdapterUrlProvider vnfmAdapterUrlProvider) {
+ this.vnfmAdapterUrlProvider = vnfmAdapterUrlProvider;
+ }
/**
* Convert a {@link VnfPkgInfo} Object to an {@link InlineResponse2001} Object
@@ -58,7 +63,7 @@ public class VnfPkgInfoConverter implements Converter<VnfPkgInfo, InlineResponse
@Override
public InlineResponse2001 convert(final VnfPkgInfo vnfPkgInfo) {
if (vnfPkgInfo == null) {
- logger.info("No VnfPkgInfo Object Provided for Conversion. (Null object received, returning Null)");
+ logger.error("No VnfPkgInfo Object Provided for Conversion. (Null object received, returning Null)");
return null;
}
final InlineResponse2001 response = new InlineResponse2001();
@@ -87,7 +92,7 @@ public class VnfPkgInfoConverter implements Converter<VnfPkgInfo, InlineResponse
response.setUserDefinedData((vnfPkgInfo.getUserDefinedData()));
if (vnfPkgInfo.getLinks() != null) {
- response.setLinks(convertVNFPKGMLinkSerializerToVnfPackagesLinks(vnfPkgInfo.getLinks()));
+ response.setLinks(getVnfPackagesLinks(vnfPkgInfo.getLinks(), vnfPkgInfo.getId()));
}
return response;
@@ -167,22 +172,27 @@ public class VnfPkgInfoConverter implements Converter<VnfPkgInfo, InlineResponse
return vnfPackagesAdditionalArtifacts;
}
- private VnfPackagesLinks convertVNFPKGMLinkSerializerToVnfPackagesLinks(
- final VNFPKGMLinkSerializer vnfpkgmLinkSerializer) {
+ private VnfPackagesLinks getVnfPackagesLinks(final VNFPKGMLinkSerializer links, final String vnfPkgId) {
final VnfPackagesLinks vnfPackagesLinks = new VnfPackagesLinks();
- vnfPackagesLinks.setSelf(convertUriLinkToVnfPackagesLinksSelf(vnfpkgmLinkSerializer.getSelf()));
- vnfPackagesLinks.setVnfd(convertUriLinkToVnfPackagesLinksSelf(vnfpkgmLinkSerializer.getVnfd()));
- vnfPackagesLinks
- .setPackageContent(convertUriLinkToVnfPackagesLinksSelf(vnfpkgmLinkSerializer.getPackageContent()));
+
+ if (links.getSelf() != null) {
+ vnfPackagesLinks.setSelf(getVnfPackagesLinksSelf(vnfmAdapterUrlProvider.getVnfPackageUrl(vnfPkgId)));
+ }
+
+ if (links.getVnfd() != null) {
+ vnfPackagesLinks.setVnfd(getVnfPackagesLinksSelf(vnfmAdapterUrlProvider.getVnfPackageVnfdUrl(vnfPkgId)));
+ }
+
+ if (links.getPackageContent() != null) {
+ vnfPackagesLinks.setPackageContent(
+ getVnfPackagesLinksSelf(vnfmAdapterUrlProvider.getVnfPackageContentUrl(vnfPkgId)));
+ }
+
return vnfPackagesLinks;
}
- private VnfPackagesLinksSelf convertUriLinkToVnfPackagesLinksSelf(final UriLink uriLink) {
- final VnfPackagesLinksSelf vnfPackagesLinksSelf = new VnfPackagesLinksSelf();
- if (uriLink != null) {
- vnfPackagesLinksSelf.setHref(uriLink.getHref());
- }
- return vnfPackagesLinksSelf;
+ private VnfPackagesLinksSelf getVnfPackagesLinksSelf(final String href) {
+ return new VnfPackagesLinksSelf().href(href);
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java
new file mode 100644
index 0000000000..95252218c8
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
+
+import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface EtsiCatalogPackageManagementServiceProvider {
+
+ /**
+ * GET Package Content, from VNF Package.
+ *
+ * @param vnfPkgId The ID of the VNF Package from which the "package_content" will be retrieved.
+ * @return The Package Content of a VNF Package ("vnfPkgId").
+ */
+ Optional<byte[]> getVnfPackageContent(final String vnfPkgId);
+
+ /**
+ * GET VNF packages information from ETSI Catalog. Will return zero or more VNF package representations.
+ *
+ * @return An Array of all VNF packages retrieved from the ETSI Catalog.
+ */
+ Optional<InlineResponse2001[]> getVnfPackages();
+
+ /**
+ * GET specific VNF package information from ETSI Catalog.
+ *
+ * @param vnfPkgId The ID of the VNF Package that you want to query.
+ * @return The VNF package retrieved from the ETSI Catalog
+ */
+ Optional<InlineResponse2001> getVnfPackage(final String vnfPkgId);
+
+ /**
+ * GET specific VNF package VNFD from ETSI Catalog.
+ *
+ * @param vnfPkgId The ID of the VNF Package that you want to query.
+ * @return The VNF package retrieved from the ETSI Catalog
+ */
+ Optional<byte[]> getVnfPackageVnfd(final String vnfPkgId);
+
+ /**
+ * GET Package Artifact, from VNF Package.
+ *
+ * @param vnfPkgId The ID of the VNF Package from which the artifact will be retrieved.
+ * @param artifactPath Sequence of one or more path segments representing the path of the artifact within the VNF
+ * Package, e.g., foo/bar/run.sh
+ * @return The Package Artifact of a VNF Package ("vnfPkgId", "artifactPath").
+ */
+ Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath);
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
index 0dcc49eeac..61db82f38c 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java
@@ -20,80 +20,13 @@
package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
-import java.util.Optional;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
-
/**
* Provides methods for invoking REST calls to the ETSI Catalog Manager.
*
* @author gareth.roper@est.tech
*/
-public interface EtsiCatalogServiceProvider {
-
- /**
- * GET Package Content, from VNF Package.
- *
- * @param vnfPkgId The ID of the VNF Package from which the "package_content" will be retrieved.
- * @return The Package Content of a VNF Package ("vnfPkgId").
- */
- Optional<byte[]> getVnfPackageContent(final String vnfPkgId);
-
- /**
- * GET VNF packages information from ETSI Catalog. Will return zero or more VNF package representations.
- *
- * @return An Array of all VNF packages retrieved from the ETSI Catalog.
- */
- Optional<InlineResponse2001[]> getVnfPackages();
-
- /**
- * GET specific VNF package information from ETSI Catalog.
- *
- * @param vnfPkgId The ID of the VNF Package that you want to query.
- * @return The VNF package retrieved from the ETSI Catalog
- */
- Optional<InlineResponse2001> getVnfPackage(final String vnfPkgId);
-
- /**
- * GET specific VNF package VNFD from ETSI Catalog.
- *
- * @param vnfPkgId The ID of the VNF Package that you want to query.
- * @return The VNF package retrieved from the ETSI Catalog
- */
- Optional<byte[]> getVnfPackageVnfd(final String vnfPkgId);
-
- /**
- * GET Package Artifact, from VNF Package.
- *
- * @param vnfPkgId The ID of the VNF Package from which the artifact will be retrieved.
- * @param artifactPath Sequence of one or more path segments representing the path of the artifact within the VNF
- * Package, e.g., foo/bar/run.sh
- * @return The Package Artifact of a VNF Package ("vnfPkgId", "artifactPath").
- */
- Optional<byte[]> getVnfPackageArtifact(final String vnfPkgId, final String artifactPath);
-
- /**
- * POST the SubscriptionRequest Object.
- *
- * @return The ETSI Catalog Manager's PkgmSubscription object.
- */
- Optional<PkgmSubscription> postSubscription(
- final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest);
-
- /**
- * Get the Subscription from ETSI Catalog.
- *
- * @param subscriptionId Subscription ID
- * @return The Subscription {@link NsdmSubscription} from ETSI Catalog
- */
- Optional<NsdmSubscription> getSubscription(final String subscriptionId);
+public interface EtsiCatalogServiceProvider
+ extends EtsiCatalogSubscriptionServiceProvider, EtsiCatalogPackageManagementServiceProvider {
- /**
- * DELETE the SubscriptionRequest Object.
- *
- * @return A Boolean representing if the delete was successful or not.
- */
- boolean deleteSubscription(final String subscriptionId);
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java
new file mode 100644
index 0000000000..ed04ad7746
--- /dev/null
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Ericsson. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog;
+
+import java.util.Optional;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
+import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public interface EtsiCatalogSubscriptionServiceProvider {
+
+ /**
+ * POST the SubscriptionRequest Object.
+ *
+ * @return The ETSI Catalog Manager's PkgmSubscription object.
+ */
+ Optional<PkgmSubscription> postSubscription(
+ final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest);
+
+ /**
+ * Get the Subscription from ETSI Catalog.
+ *
+ * @param subscriptionId Subscription ID
+ * @return The Subscription {@link NsdmSubscription} from ETSI Catalog
+ */
+ Optional<NsdmSubscription> getSubscription(final String subscriptionId);
+
+ /**
+ * DELETE the SubscriptionRequest Object.
+ *
+ * @return A Boolean representing if the delete was successful or not.
+ */
+ boolean deleteSubscription(final String subscriptionId);
+
+}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
index 7c22020287..fabf8839a6 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
@@ -20,17 +20,13 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
-import com.google.common.reflect.TypeToken;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterUrlProvider;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.InterfaceInfo;
@@ -47,15 +43,17 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilte
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateExtVirtualLinks;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo;
-import org.onap.so.utils.CryptoUtils;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
import org.onap.vnfmadapter.v1.model.Tenant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
/**
* Provides helper methods for interactions with VNFM.
@@ -66,19 +64,13 @@ public class VnfmHelper {
private static final Logger logger = LoggerFactory.getLogger(VnfmHelper.class);
private static final String SEPARATOR = "_";
private final AaiServiceProvider aaiServiceProvider;
-
- @Value("${vnfmadapter.endpoint}")
- private String vnfmAdapterEndoint;
-
- @Value("${vnfmadapter.auth:E39823AAB2739CC654C4E92B52C05BC34149342D0A46451B00CA508C8EDC62242CE4E9DA9445D3C01A3F13}")
- private String vnfmAdapterAuth;
-
- @Value("${mso.key}")
- private String msoEncryptionKey;
+ private final VnfmAdapterUrlProvider vnfmAdapterUrlProvider;
@Autowired
- public VnfmHelper(final AaiServiceProvider aaiServiceProvider) {
+ public VnfmHelper(final AaiServiceProvider aaiServiceProvider,
+ final VnfmAdapterUrlProvider vnfmAdapterUrlProvider) {
this.aaiServiceProvider = aaiServiceProvider;
+ this.vnfmAdapterUrlProvider = vnfmAdapterUrlProvider;
}
/**
@@ -99,11 +91,6 @@ public class VnfmHelper {
return instantiateVnfRequest;
}
- private String getFlavourId() {
- // TODO read from csar
- return "default";
- }
-
private List<VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo> getVimConnectionInfos(final Tenant tenant) {
final List<VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo> connectionInfos = new ArrayList<>();
connectionInfos.add(getVimConnectionInfo(tenant));
@@ -183,7 +170,7 @@ public class VnfmHelper {
throws GeneralSecurityException {
final LccnSubscriptionRequest lccnSubscriptionRequest = new LccnSubscriptionRequest();
lccnSubscriptionRequest.setAuthentication(getSubscriptionsAuthentication());
- lccnSubscriptionRequest.setCallbackUri(vnfmAdapterEndoint + BASE_URL + OPERATION_NOTIFICATION_ENDPOINT);
+ lccnSubscriptionRequest.setCallbackUri(vnfmAdapterUrlProvider.getVnfLcmOperationOccurrenceNotificationUrl());
final SubscriptionsFilter filter = new SubscriptionsFilter();
filter.addNotificationTypesItem(NotificationTypesEnum.VNFLCMOPERATIONOCCURRENCENOTIFICATION);
final SubscriptionsFilterVnfInstanceSubscriptionFilter vnfInstanceSubscriptionFilter =
@@ -197,19 +184,19 @@ public class VnfmHelper {
private SubscriptionsAuthentication getSubscriptionsAuthentication() throws GeneralSecurityException {
final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
- final String[] decrypedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoEncryptionKey).split(":");
+ final ImmutablePair<String, String> decrypedAuth = vnfmAdapterUrlProvider.getDecryptAuth();
- SubscriptionsAuthenticationParamsOauth2ClientCredentials oauthParams =
+ final SubscriptionsAuthenticationParamsOauth2ClientCredentials oauthParams =
new SubscriptionsAuthenticationParamsOauth2ClientCredentials();
- oauthParams.setTokenEndpoint(vnfmAdapterEndoint + "/oauth/token");
- oauthParams.clientId(decrypedAuth[0]);
- oauthParams.setClientPassword(decrypedAuth[1]);
+ oauthParams.setTokenEndpoint(vnfmAdapterUrlProvider.getOauthTokenUrl());
+ oauthParams.clientId(decrypedAuth.getLeft());
+ oauthParams.setClientPassword(decrypedAuth.getRight());
authentication.addAuthTypeItem(AuthTypeEnum.OAUTH2_CLIENT_CREDENTIALS);
authentication.paramsOauth2ClientCredentials(oauthParams);
final SubscriptionsAuthenticationParamsBasic basicAuthParams = new SubscriptionsAuthenticationParamsBasic();
- basicAuthParams.setUserName(decrypedAuth[0]);
- basicAuthParams.setPassword(decrypedAuth[1]);
+ basicAuthParams.setUserName(decrypedAuth.getLeft());
+ basicAuthParams.setPassword(decrypedAuth.getRight());
authentication.addAuthTypeItem(AuthTypeEnum.BASIC);
authentication.paramsBasic(basicAuthParams);
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
index 073fc93107..eaaa8d8544 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
@@ -28,7 +28,6 @@ import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
-import java.util.ListIterator;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
@@ -40,10 +39,8 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrVnfm;
-import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.adapters.vnfmadapter.extclients.AbstractServiceProviderConfiguration;
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
-import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.onap.so.rest.service.HttpRestServiceProvider;
import org.onap.so.rest.service.HttpRestServiceProviderImpl;
import org.slf4j.Logger;
@@ -54,7 +51,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
@@ -102,7 +98,7 @@ public class VnfmServiceProviderConfiguration extends AbstractServiceProviderCon
if (trustStore != null) {
setTrustStore(restTemplate);
}
- return new HttpRestServiceProviderImpl(restTemplate, new BasicHttpHeadersProvider());
+ return new HttpRestServiceProviderImpl(restTemplate, new BasicHttpHeadersProvider().getHttpHeaders());
}
private RestTemplate createRestTemplate(final EsrVnfm vnfm) {
@@ -155,14 +151,4 @@ public class VnfmServiceProviderConfiguration extends AbstractServiceProviderCon
}
}
- private void removeSpringClientFilter(final RestTemplate restTemplate) {
- ListIterator<ClientHttpRequestInterceptor> interceptorIterator = restTemplate.getInterceptors().listIterator();
- while (interceptorIterator.hasNext()) {
- ClientHttpRequestInterceptor interceptor = interceptorIterator.next();
- if (interceptor instanceof SOSpringClientFilter || interceptor instanceof SpringClientPayloadFilter) {
- interceptorIterator.remove();
- }
- }
- }
-
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
index a23eb6c3e3..a63e14c899 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java
@@ -29,7 +29,8 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import org.onap.so.adapters.vnfmadapter.Constants;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterUrlProvider;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription;
@@ -42,10 +43,8 @@ import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement
import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException;
import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException;
-import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.convert.ConversionService;
import org.springframework.stereotype.Service;
@@ -62,22 +61,16 @@ public class SubscriptionManager {
private final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider;
private final ConversionService conversionService;
private final EtsiCatalogServiceProvider etsiCatalogServiceProvider;
- private final String vnfmAdapterEndpoint;
- private final String msoKeyString;
- private final String vnfmAdapterAuth;
+ private final VnfmAdapterUrlProvider vnfmAdapterUrlProvider;
@Autowired
public SubscriptionManager(final PackageManagementCacheServiceProvider packageManagementCacheServiceProvider,
final ConversionService conversionService, final EtsiCatalogServiceProvider etsiCatalogServiceProvider,
- @Value("${vnfmadapter.endpoint}") final String vnfmAdapterEndpoint,
- @Value("${mso.key}") final String msoKeyString,
- @Value("${vnfmadapter.auth:BF29BA36F0CFE1C05507781F6B97EFBCA7EFAC9F595954D465FC43F646883EF585C20A58CBB02528A6FAAC}") final String vnfmAdapterAuth) {
+ final VnfmAdapterUrlProvider vnfmAdapterUrlProvider) {
this.packageManagementCacheServiceProvider = packageManagementCacheServiceProvider;
this.conversionService = conversionService;
this.etsiCatalogServiceProvider = etsiCatalogServiceProvider;
- this.vnfmAdapterEndpoint = vnfmAdapterEndpoint;
- this.vnfmAdapterAuth = vnfmAdapterAuth;
- this.msoKeyString = msoKeyString;
+ this.vnfmAdapterUrlProvider = vnfmAdapterUrlProvider;
}
public Optional<InlineResponse201> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest)
@@ -100,7 +93,7 @@ public class SubscriptionManager {
final InlineResponse201 response = new InlineResponse201();
response.setId(subscriptionId);
response.setFilter(pkgmSubscriptionRequest.getFilter());
- response.setCallbackUri(getSubscriptionUri(subscriptionId).toString());
+ response.setCallbackUri(vnfmAdapterUrlProvider.getSubscriptionUriString(subscriptionId));
response.setLinks(new SubscriptionsLinks()
.self(new VnfPackagesLinksSelf().href(getSubscriptionUri(subscriptionId).toString())));
@@ -167,8 +160,7 @@ public class SubscriptionManager {
}
public URI getSubscriptionUri(final String subscriptionId) {
- return URI.create(
- vnfmAdapterEndpoint + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions/" + subscriptionId);
+ return vnfmAdapterUrlProvider.getSubscriptionUri(subscriptionId);
}
public Optional<PkgmSubscriptionRequest> getSubscriptionRequest(final String subscriptionId) {
@@ -199,25 +191,19 @@ public class SubscriptionManager {
if (etsiCatalogManagerSubscriptionRequest != null) {
etsiCatalogManagerSubscriptionRequest
- .setCallbackUri(vnfmAdapterEndpoint + Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL);
-
- final String[] auth = decryptAuth();
- final String username = auth[0];
- final String password = auth[1];
-
- etsiCatalogManagerSubscriptionRequest.setAuthentication(
- new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication()
- .addAuthTypeItem(BASIC).paramsBasic(new BasicAuth().userName(username).password(password)));
+ .setCallbackUri(vnfmAdapterUrlProvider.getEtsiSubscriptionNotificationBaseUrl());
+
+ final ImmutablePair<String, String> immutablePair = vnfmAdapterUrlProvider.getDecryptAuth();
+ if (!immutablePair.equals(ImmutablePair.nullPair())) {
+ etsiCatalogManagerSubscriptionRequest.setAuthentication(
+ new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication()
+ .addAuthTypeItem(BASIC).paramsBasic(new BasicAuth().userName(immutablePair.getLeft())
+ .password(immutablePair.getRight())));
+ }
return etsiCatalogManagerSubscriptionRequest;
}
throw new ConversionFailedException(
"Failed to convert Sol003 PkgmSubscriptionRequest to ETSI-Catalog Manager PkgmSubscriptionRequest");
}
- private String[] decryptAuth() throws GeneralSecurityException {
- final String decryptedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoKeyString);
- final String[] auth = decryptedAuth.split(":");
- return auth;
- }
-
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
index f1d20c65ef..6d067902c5 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java
@@ -170,8 +170,6 @@ public class Sol003PackageManagementController {
+ " Sol003PackageManagementController from the EtsiCatalogManager using the\n GET \"vnf_packages\" by vnfPkgId: \""
+ vnfPkgId + "\" for artifactPath: \"" + artifactPath + "\"\n" + "endpoint.";
logger.error(errorMessage);
- // return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new
- // ProblemDetails().detail(errorMessage));
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java
index 31e612a812..be8b0c2e0b 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java
@@ -45,6 +45,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageA
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinks;
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -94,7 +95,11 @@ public class Sol003PackageManagementControllerTest {
private static final String VNFD_VERSION = "vnfdVersion";
private static final String ALGORITHM = "algorithm";
private static final String HASH = "hash";
- private static final String URI_HREF = "uriHref";
+ private static final String EXPECTED_BASE_URL =
+ "https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/vnfpkgm/v1/vnf_packages/";
+ private static final String EXPECTED_SELF_HREF = EXPECTED_BASE_URL + VNF_PACKAGE_ID;
+ private static final String EXPECTED_VNFD_HREF = EXPECTED_BASE_URL + VNF_PACKAGE_ID + "/vnfd";
+ private static final String EXPECTED_PACKAGE_CONTENT_HREF = EXPECTED_BASE_URL + VNF_PACKAGE_ID + "/package_content";
private MockRestServiceServer mockRestServer;
private BasicHttpHeadersProvider basicHttpHeadersProvider;
@@ -346,7 +351,11 @@ public class Sol003PackageManagementControllerTest {
assertEquals(ARTIFACT_PATH, inlineResponse2001.getAdditionalArtifacts().get(0).getArtifactPath());
assertEquals(ALGORITHM, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getAlgorithm());
assertEquals(HASH, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getHash());
- assertEquals(URI_HREF, inlineResponse2001.getLinks().getSelf().getHref());
+ final VnfPackagesLinks links = inlineResponse2001.getLinks();
+ assertNotNull(links);
+ assertEquals(EXPECTED_SELF_HREF, links.getSelf().getHref());
+ assertEquals(EXPECTED_VNFD_HREF, links.getVnfd().getHref());
+ assertEquals(EXPECTED_PACKAGE_CONTENT_HREF, links.getPackageContent().getHref());
}
@Test
@@ -426,7 +435,12 @@ public class Sol003PackageManagementControllerTest {
assertEquals(ARTIFACT_PATH, inlineResponse2001.getAdditionalArtifacts().get(0).getArtifactPath());
assertEquals(ALGORITHM, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getAlgorithm());
assertEquals(HASH, inlineResponse2001.getAdditionalArtifacts().get(0).getChecksum().getHash());
- assertEquals(URI_HREF, inlineResponse2001.getLinks().getSelf().getHref());
+ final VnfPackagesLinks links = inlineResponse2001.getLinks();
+ assertNotNull(links);
+ assertEquals(EXPECTED_SELF_HREF, links.getSelf().getHref());
+ assertEquals(EXPECTED_VNFD_HREF, links.getVnfd().getHref());
+ assertEquals(EXPECTED_PACKAGE_CONTENT_HREF, links.getPackageContent().getHref());
+
}
@Test
@@ -648,9 +662,10 @@ public class Sol003PackageManagementControllerTest {
}
private VNFPKGMLinkSerializer createVNFPKGMLinkSerializerLinks() {
- final UriLink uriLink = new UriLink().href(URI_HREF);
- final VNFPKGMLinkSerializer vnfpkgmLinkSerializer = new VNFPKGMLinkSerializer().self(uriLink);
- return vnfpkgmLinkSerializer;
+ final String baseUrl = "http://msb-iag:443/api/vnfpkgm/v1/vnf_packages";
+ return new VNFPKGMLinkSerializer().self(new UriLink().href(baseUrl + "/myVnfPackageId"))
+ .vnfd(new UriLink().href(baseUrl + "/myVnfPackageId/vnfd"))
+ .packageContent(new UriLink().href(baseUrl + "/myVnfPackageId/package_content"));
}
}