forked from verygoodsecurity/LittleProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChainedProxyWithFallbackToOtherChainedProxyDueToSSLTest.java
More file actions
53 lines (45 loc) · 1.76 KB
/
ChainedProxyWithFallbackToOtherChainedProxyDueToSSLTest.java
File metadata and controls
53 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package org.littleshoot.proxy;
import io.netty.handler.codec.http.HttpRequest;
import java.util.Queue;
import javax.net.ssl.SSLEngine;
/**
* Tests a proxy chained to a downstream proxy with an untrusted SSL cert. When
* the downstream proxy is unavailable, the downstream proxy should just fall
* back to a the next chained proxy.
*/
public class ChainedProxyWithFallbackToOtherChainedProxyDueToSSLTest extends
BadServerAuthenticationTCPChainedProxyTest {
@Override
protected boolean expectBadGatewayForEverything() {
return false;
}
protected ChainedProxyManager chainedProxyManager() {
return new ChainedProxyManager() {
@Override
public void lookupChainedProxies(HttpRequest httpRequest,
Queue<ChainedProxy> chainedProxies) {
// This first one has a bad cert
chainedProxies.add(newChainedProxy());
// This 2nd one should work
chainedProxies.add(new BaseChainedProxy() {
@Override
public TransportProtocol getTransportProtocol() {
return TransportProtocol.TCP;
}
@Override
public boolean requiresEncryption() {
return true;
}
@Override
public SSLEngine newSslEngine() {
return serverSslEngineSource.newSslEngine();
}
@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return serverSslEngineSource.newSslEngine(peerHost, peerPort);
}
});
}
};
}
}