forked from adamfisk/LittleProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adamfisk#149 ProxyToServerConnection now removes itself as handler fr…
…om the old context when falling back to another chained proxy
- Loading branch information
Showing
8 changed files
with
125 additions
and
9 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/java/org/littleshoot/proxy/BadServerAuthenticationTCPChainedProxyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.littleshoot.proxy; | ||
|
||
import static org.littleshoot.proxy.TransportProtocol.*; | ||
|
||
import javax.net.ssl.SSLEngine; | ||
|
||
import org.littleshoot.proxy.extras.SelfSignedSslEngineSource; | ||
|
||
/** | ||
* Tests that servers are authenticated and that if they're missing certs, we | ||
* get an error. | ||
*/ | ||
public class BadServerAuthenticationTCPChainedProxyTest extends | ||
BaseChainedProxyTest { | ||
protected final SslEngineSource serverSslEngineSource = new SelfSignedSslEngineSource( | ||
"chain_proxy_keystore_1.jks"); | ||
|
||
protected final SslEngineSource clientSslEngineSource = new SelfSignedSslEngineSource( | ||
"chain_proxy_keystore_2.jks"); | ||
|
||
@Override | ||
protected boolean expectBadGatewayForEverything() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected HttpProxyServerBootstrap upstreamProxy() { | ||
return super.upstreamProxy() | ||
.withTransportProtocol(TCP) | ||
.withSslEngineSource(serverSslEngineSource); | ||
} | ||
|
||
@Override | ||
protected ChainedProxy newChainedProxy() { | ||
return new BaseChainedProxy() { | ||
@Override | ||
public TransportProtocol getTransportProtocol() { | ||
return TransportProtocol.TCP; | ||
} | ||
|
||
@Override | ||
public boolean requiresEncryption() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public SSLEngine newSslEngine() { | ||
return clientSslEngineSource.newSslEngine(); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...t/java/org/littleshoot/proxy/ChainedProxyWithFallbackToOtherChainedProxyDueToSSLTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
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(); | ||
} | ||
}); | ||
} | ||
}; | ||
} | ||
} |