From 612fb579067ea79d0148462a45eeff737a58503f Mon Sep 17 00:00:00 2001 From: mpriyank Date: Tue, 1 Aug 2023 15:36:27 +0100 Subject: Ability to disable sending auth header - introduced configurable parameter to disable sending auth header in the request to dmi-plugin - default is to include the auth header - DMI_AUTH_ENABLED flag can be set to true/false to control the behaviour - Also added the env variables to the CSITs - updated release-notes Issue-ID: CPS-1819 Change-Id: If97c06e33f06e391d2190b7300d73210ed2f4e27 Signed-off-by: mpriyank --- .../ncmp/api/impl/client/DmiRestClientSpec.groovy | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'cps-ncmp-service/src/test/groovy/org') 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 + } + } -- cgit 1.2.3-korg