BasicAuthorizationHeaderModifier implements HeaderModifier { @Override public Header modify(Header header) { final String valueToDecode = header.value().replace("Basic", "").trim(); final String decodedHeaderValue = base64Decoder.decode(valueToDecode); return new Header(header.name(), decodedHeaderValue); } BasicAuthorizationHeaderModifier(Base64Decoder base64Decoder); @Override boolean matches(Header header); @Override Header modify(Header header);  }
@Test public void modifier_shouldReturnHeader_withDecodedValue() throws Exception { when(base64Decoder.decode("bWFjaWVrOnRham5laGFzbG8xMjM=")).thenReturn("maciej:tajnehaslo123"); final Header modifiedHeader = headerModifier.modify(basicAuthHeader); assertThat(modifiedHeader.name(), is("Authorization")); assertThat(modifiedHeader.value(), is("maciej:tajnehaslo123")); }