diff options
author | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-10-08 14:46:09 -0400 |
---|---|---|
committer | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-10-08 14:46:09 -0400 |
commit | 0ee2ca49f61f75179f3118cbadd2406f7c72cfb3 (patch) | |
tree | 54282cf239abfd073658629e8e9476b00ccea477 /models-interactions/model-impl/cds/src | |
parent | 3b44a9887ab7ba8d0ba4f1159e2fc0a93c0247d0 (diff) |
Correct the CDS basic auth header in the request
Issue-ID: POLICY-2088
Signed-off-by: Rashmi Pujar <rashmi.pujar@bell.ca>
Change-Id: Ibcdfdbd1de66fcf193e52fcc14a1220c7520f140
Diffstat (limited to 'models-interactions/model-impl/cds/src')
2 files changed, 5 insertions, 3 deletions
diff --git a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java index 850531848..1b3149089 100644 --- a/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java +++ b/models-interactions/model-impl/cds/src/main/java/org/onap/policy/cds/properties/CdsServerProperties.java @@ -82,7 +82,9 @@ public class CdsServerProperties implements ParameterGroup { * @return Base64 encoded string */ public String getBasicAuth() { - return Base64.getEncoder().encodeToString(String.format("%s:%s", getUsername(), getPassword()) - .getBytes(StandardCharsets.UTF_8)); + String encodedAuth = Base64.getEncoder().encodeToString( + String.format("%s:%s", getUsername(), getPassword()).getBytes(StandardCharsets.UTF_8)); + // Return encoded basic auth header + return "Basic " + encodedAuth; } } diff --git a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java index fedf4703c..3192520ae 100644 --- a/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java +++ b/models-interactions/model-impl/cds/src/test/java/org/onap/policy/cds/client/BasicAuthClientHeaderInterceptorTest.java @@ -120,7 +120,7 @@ public class BasicAuthClientHeaderInterceptorTest { Key<String> authHeader = Key .of(BasicAuthClientHeaderInterceptor.BASIC_AUTH_HEADER_KEY, Metadata.ASCII_STRING_MARSHALLER); - String expectedBaseAuth = Base64.getEncoder().encodeToString(String.format("%s:%s", CREDS, CREDS) + String expectedBaseAuth = "Basic " + Base64.getEncoder().encodeToString(String.format("%s:%s", CREDS, CREDS) .getBytes(StandardCharsets.UTF_8)); assertEquals(expectedBaseAuth, metadataCaptor.getValue().get(authHeader)); } |