protected String getBasicAuthUserName(SimpleMap headers) {
String encodedAuthorizationValue = headers.get(HttpHeaders.AUTHORIZATION);
- if (encodedAuthorizationValue != null) {
+ if (encodedAuthorizationValue != null && encodedAuthorizationValue.startsWith("Basic")) {
try {
// This will strip the word Basic and single space
encodedAuthorizationValue = encodedAuthorizationValue.substring(6);
assertEquals("Bad Gateway", MDC.get(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION));
}
+ @Test
+ public void setMDCPartnerNameBearerToken() {
+ MultivaluedMap<String, String> headerMap = new MultivaluedHashMap<>();
+ String value = "Bearer some-compex-token";
+ headerMap.putSingle(HttpHeaders.AUTHORIZATION, value);
+ SimpleMap headers = new SimpleJaxrsHeadersMap(headerMap);
+
+ setMDCPartnerName(headers);
+
+ assertEquals(Constants.DefaultValues.UNKNOWN, MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME));
+ }
+
@Test
public void setMDCPartnerNameFromBasicAuth() {
MultivaluedMap<String, String> headerMap = new MultivaluedHashMap<>();