public void testService1_httpProxy_basicAuthentication_failure() throws Exception {
exception.expect(TransmissionException.class);
exception.expectMessage("[407]");
HttpProxyServer proxyServer = initProxy();
proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
@Override
public boolean authenticate(String user, String pass) {
return user.equals("tom") && pass.equals("007");
}
});
final Security props = Security.builder()
.authBasic("james", "003")
.build();
try {
final Security securityContext = Security.builder()
.trustStoreUrl(getKeyStoreUrlOne())
.trustStorePassword(getKeyStorePassword())
.build();
verifyServiceBehavior(1, new ClientBuilder() {
@Override
public SoapClient buildClient(String endpointUrl) {
return SoapClient.builder().endpointUri("https://" + endpointUrl)
.proxyUri("http://127.0.0.1:" + PROXY_PORT)
.proxySecurity(props)
.endpointSecurity(securityContext)
.build();
}
});
} finally {
proxyServer.stop();
}
}