summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cps-application/src/main/resources/application.yml1
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java4
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java2
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy20
-rw-r--r--cps-ncmp-service/src/test/resources/application.yml1
-rwxr-xr-xcsit/plans/cps/setup.sh2
-rw-r--r--csit/plans/cps/test.properties2
-rwxr-xr-xdocs/release-notes.rst1
8 files changed, 31 insertions, 2 deletions
diff --git a/cps-application/src/main/resources/application.yml b/cps-application/src/main/resources/application.yml
index 47592b41f0..a18de2acdb 100644
--- a/cps-application/src/main/resources/application.yml
+++ b/cps-application/src/main/resources/application.yml
@@ -174,6 +174,7 @@ ncmp:
auth:
username: ${DMI_USERNAME}
password: ${DMI_PASSWORD}
+ enabled: ${DMI_AUTH_ENABLED:true}
api:
base-path: dmi
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java
index 136935ba53..28e09ac4bc 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/client/DmiRestClient.java
@@ -61,7 +61,9 @@ public class DmiRestClient {
}
private HttpHeaders configureHttpHeaders(final HttpHeaders httpHeaders) {
- httpHeaders.setBasicAuth(dmiProperties.getAuthUsername(), dmiProperties.getAuthPassword());
+ if (dmiProperties.isDmiBasicAuthEnabled()) {
+ httpHeaders.setBasicAuth(dmiProperties.getAuthUsername(), dmiProperties.getAuthPassword());
+ }
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
return httpHeaders;
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java
index 6decaf8444..ffecf9c7f1 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/NcmpConfiguration.java
@@ -52,6 +52,8 @@ public class NcmpConfiguration {
private String authPassword;
@Value("${ncmp.dmi.api.base-path}")
private String dmiBasePath;
+ @Value("${ncmp.dmi.auth.enabled}")
+ private boolean dmiBasicAuthEnabled;
}
/**
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy
index 6b0355eee8..0d03fd9acf 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/client/DmiRestClientSpec.groovy
@@ -27,6 +27,7 @@ import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.http.HttpEntity
+import org.springframework.http.HttpHeaders
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.test.context.ContextConfiguration
@@ -50,6 +51,13 @@ class DmiRestClientSpec extends Specification {
def resourceUrl = 'some url'
def mockResponseEntity = Mock(ResponseEntity)
+ def dmiProperties = new NcmpConfiguration.DmiProperties()
+
+ def setup() {
+ dmiProperties.authUsername = 'test user'
+ dmiProperties.authPassword = 'test pass'
+ dmiProperties.dmiBasePath = 'dmi'
+ }
def 'DMI POST operation with JSON.'() {
given: 'the rest template returns a valid response entity'
@@ -77,4 +85,16 @@ class DmiRestClientSpec extends Specification {
operation << [CREATE, READ, PATCH]
}
+ def 'Basic auth header #scenario'() {
+ when: 'Specific dmi properties are provided'
+ dmiProperties.dmiBasicAuthEnabled = authEnabled
+ objectUnderTest.dmiProperties = dmiProperties
+ then: 'http headers to conditionally have Authorization header'
+ assert (objectUnderTest.configureHttpHeaders(new HttpHeaders()).get('Authorization') != null) == isPresentInHttpHeader
+ where: 'the following configurations are used'
+ scenario | authEnabled || isPresentInHttpHeader
+ 'auth enabled' | true || true
+ 'auth disabled' | false || false
+ }
+
}
diff --git a/cps-ncmp-service/src/test/resources/application.yml b/cps-ncmp-service/src/test/resources/application.yml
index 7442670920..6e7577b1a8 100644
--- a/cps-ncmp-service/src/test/resources/application.yml
+++ b/cps-ncmp-service/src/test/resources/application.yml
@@ -39,6 +39,7 @@ ncmp:
auth:
username: some-user
password: some-password
+ enabled: true
api:
base-path: dmi
diff --git a/csit/plans/cps/setup.sh b/csit/plans/cps/setup.sh
index 269d3cb29d..bdea01985d 100755
--- a/csit/plans/cps/setup.sh
+++ b/csit/plans/cps/setup.sh
@@ -129,4 +129,4 @@ check_health $DMI_HOST:$DMI_MANAGEMENT_PORT 'dmi-plugin'
###################### ROBOT Configurations ##########################
# Pass variables required for Robot test suites in ROBOT_VARIABLES
-ROBOT_VARIABLES="-v CPS_CORE_HOST:$CPS_CORE_HOST -v CPS_CORE_PORT:$CPS_CORE_PORT -v DMI_HOST:$LOCAL_IP -v DMI_PORT:$DMI_PORT -v DMI_CSIT_STUB_HOST:$LOCAL_IP -v DMI_CSIT_STUB_PORT:$DMI_DEMO_STUB_PORT -v CPS_CORE_MANAGEMENT_PORT:$CPS_CORE_MANAGEMENT_PORT -v DATADIR:$WORKSPACE/data --exitonfailure"
+ROBOT_VARIABLES="-v CPS_CORE_HOST:$CPS_CORE_HOST -v CPS_CORE_PORT:$CPS_CORE_PORT -v DMI_HOST:$LOCAL_IP -v DMI_PORT:$DMI_PORT -v DMI_CSIT_STUB_HOST:$LOCAL_IP -v DMI_CSIT_STUB_PORT:$DMI_DEMO_STUB_PORT -v DMI_AUTH_ENABLED:$DMI_AUTH_ENABLED -v CPS_CORE_MANAGEMENT_PORT:$CPS_CORE_MANAGEMENT_PORT -v DATADIR:$WORKSPACE/data --exitonfailure"
diff --git a/csit/plans/cps/test.properties b/csit/plans/cps/test.properties
index 474a718181..b3dcf05fa7 100644
--- a/csit/plans/cps/test.properties
+++ b/csit/plans/cps/test.properties
@@ -32,3 +32,5 @@ CPS_HOME=$CPS_HOME
DMI_DEMO_STUB_PORT=8784
DMI_DEMO_STUB_VERSION=latest
+
+DMI_AUTH_ENABLED=true
diff --git a/docs/release-notes.rst b/docs/release-notes.rst
index 66dde1cfb7..cd70cf8be7 100755
--- a/docs/release-notes.rst
+++ b/docs/release-notes.rst
@@ -43,6 +43,7 @@ Bug Fixes
Features
--------
- `CPS-1696 <https://jira.onap.org/browse/CPS-1696>`_ Get Data Node to return entire List data node.
+ - `CPS-1819 <https://jira.onap.org/browse/CPS-1819>`_ Ability to disable sending authorization header.
Version: 3.3.5