From 41727e5dd167c71a63fb8b8f4e3136867b0e65b3 Mon Sep 17 00:00:00 2001 From: mpriyank Date: Mon, 4 Dec 2023 18:01:07 +0000 Subject: [BUG] Dminame to valid topic suffix - dmi name can be in the form of URL , and we are using dmi-name as topic suffix , which results in the invalid topic name. - fix to extract out domain name excluding port from the url - test case for the same - updated the documentation - fix only supports ipv4 addresses at the moment Issue-ID: CPS-1979 Change-Id: I9c6ea113afae816f727b45a30c94070af013a16d Signed-off-by: mpriyank --- .../CmSubscriptionNcmpInEventForwarderSpec.groovy | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'cps-ncmp-service/src/test') diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy index 1edfa58f9a..ce117eef57 100644 --- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy +++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/events/cmsubscription/CmSubscriptionNcmpInEventForwarderSpec.groovy @@ -179,6 +179,22 @@ class CmSubscriptionNcmpInEventForwarderSpec extends MessagingBaseSpec { 1 * mockCmSubscriptionNcmpOutEventPublisher.sendResponse(_, 'subscriptionCreatedStatus') } + def 'Extract domain name from URL for #scenario'() { + when: 'a valid dmi name is provided' + def domainName = objectUnderTest.toValidTopicSuffix(dmiName) + then: 'domain name is as expected with no port information' + assert domainName == expectedDomainName + where: '' + scenario | dmiName || expectedDomainName + 'insecure http url with port' | 'http://www.onap-dmi:8080/xyz=123' || 'onap-dmi' + 'insecure http url without port' | 'http://www.onap-dmi/xyz=123' || 'onap-dmi' + 'secure https url with port' | 'https://127.0.0.1:8080/xyz=123' || '127.0.0.1' + 'secure https url without port' | 'https://127.0.0.1/xyz=123' || '127.0.0.1' + 'servername without protocol and port' | 'dminame1' || 'dminame1' + 'servername without protocol' | 'www.onap-dmi:8080/xyz=123' || 'www.onap-dmi:8080/xyz=123' + + } + static def createYangModelCmHandleWithDmiProperty(id, dmiId, propertyName, propertyValue) { return new YangModelCmHandle(id: "CMHandle" + id, dmiDataServiceName: "DMIName" + dmiId, dmiProperties: [new YangModelCmHandle.Property(propertyName, propertyValue)]) } -- cgit 1.2.3-korg