-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(iot-service, e2e): Upgrade Guava and Jackson dependencies
Adding a proxy implementation to our code so that we can make some modifications so it is compatible with more recent guava versions. For the most part, this proxy implementation is equivalent to the dependency we previously took All this proxy code now lives in the "tests/integration/com/microsoft/azure/sdk/iot/helpers/proxy" path.
- Loading branch information
1 parent
24c59ee
commit a3e4e29
Showing
50 changed files
with
7,662 additions
and
55 deletions.
There are no files selected for viewing
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
155 changes: 155 additions & 0 deletions
155
...est/java/tests/integration/com/microsoft/azure/sdk/iot/helpers/proxy/ActivityTracker.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,155 @@ | ||
package tests.integration.com.microsoft.azure.sdk.iot.helpers.proxy; | ||
|
||
import io.netty.handler.codec.http.HttpRequest; | ||
import io.netty.handler.codec.http.HttpResponse; | ||
|
||
import javax.net.ssl.SSLSession; | ||
import java.net.InetSocketAddress; | ||
|
||
/** | ||
* <p> | ||
* Interface for receiving information about activity in the proxy. | ||
* </p> | ||
* | ||
* <p> | ||
* Sub-classes may wish to extend {@link ActivityTrackerAdapter} for sensible | ||
* defaults. | ||
* </p> | ||
*/ | ||
public interface ActivityTracker { | ||
|
||
/** | ||
* Record that a client connected. | ||
* | ||
* @param clientAddress | ||
*/ | ||
void clientConnected(InetSocketAddress clientAddress); | ||
|
||
/** | ||
* Record that a client's SSL handshake completed. | ||
* | ||
* @param clientAddress | ||
* @param sslSession | ||
*/ | ||
void clientSSLHandshakeSucceeded(InetSocketAddress clientAddress, | ||
SSLSession sslSession); | ||
|
||
/** | ||
* Record that a client disconnected. | ||
* | ||
* @param clientAddress | ||
* @param sslSession | ||
*/ | ||
void clientDisconnected(InetSocketAddress clientAddress, | ||
SSLSession sslSession); | ||
|
||
/** | ||
* Record that the proxy received bytes from the client. | ||
* | ||
* @param flowContext | ||
* if full information is available, this will be a | ||
* {@link FullFlowContext}. | ||
* @param numberOfBytes | ||
*/ | ||
void bytesReceivedFromClient(FlowContext flowContext, | ||
int numberOfBytes); | ||
|
||
/** | ||
* <p> | ||
* Record that proxy received an {@link HttpRequest} from the client. | ||
* </p> | ||
* | ||
* <p> | ||
* Note - on chunked transfers, this is only called once (for the initial | ||
* HttpRequest object). | ||
* </p> | ||
* | ||
* @param flowContext | ||
* if full information is available, this will be a | ||
* {@link FullFlowContext}. | ||
* @param httpRequest | ||
*/ | ||
void requestReceivedFromClient(FlowContext flowContext, | ||
HttpRequest httpRequest); | ||
|
||
/** | ||
* Record that the proxy attempted to send bytes to the server. | ||
* | ||
* @param flowContext | ||
* provides contextual information about the flow | ||
* @param numberOfBytes | ||
*/ | ||
void bytesSentToServer(FullFlowContext flowContext, int numberOfBytes); | ||
|
||
/** | ||
* <p> | ||
* Record that proxy attempted to send a request to the server. | ||
* </p> | ||
* | ||
* <p> | ||
* Note - on chunked transfers, this is only called once (for the initial | ||
* HttpRequest object). | ||
* </p> | ||
* | ||
* @param flowContext | ||
* provides contextual information about the flow | ||
* @param httpRequest | ||
*/ | ||
void requestSentToServer(FullFlowContext flowContext, | ||
HttpRequest httpRequest); | ||
|
||
/** | ||
* Record that the proxy received bytes from the server. | ||
* | ||
* @param flowContext | ||
* provides contextual information about the flow | ||
* @param numberOfBytes | ||
*/ | ||
void bytesReceivedFromServer(FullFlowContext flowContext, int numberOfBytes); | ||
|
||
/** | ||
* <p> | ||
* Record that the proxy received an {@link HttpResponse} from the server. | ||
* </p> | ||
* | ||
* <p> | ||
* Note - on chunked transfers, this is only called once (for the initial | ||
* HttpRequest object). | ||
* </p> | ||
* | ||
* @param flowContext | ||
* provides contextual information about the flow | ||
* @param httpResponse | ||
*/ | ||
void responseReceivedFromServer(FullFlowContext flowContext, | ||
HttpResponse httpResponse); | ||
|
||
/** | ||
* Record that the proxy sent bytes to the client. | ||
* | ||
* @param flowContext | ||
* if full information is available, this will be a | ||
* {@link FullFlowContext}. | ||
* @param numberOfBytes | ||
*/ | ||
void bytesSentToClient(FlowContext flowContext, int numberOfBytes); | ||
|
||
/** | ||
* <p> | ||
* Record that the proxy sent a response to the client. | ||
* </p> | ||
* | ||
* <p> | ||
* Note - on chunked transfers, this is only called once (for the initial | ||
* HttpRequest object). | ||
* </p> | ||
* | ||
* @param flowContext | ||
* if full information is available, this will be a | ||
* {@link FullFlowContext}. | ||
* @param httpResponse | ||
*/ | ||
void responseSentToClient(FlowContext flowContext, | ||
HttpResponse httpResponse); | ||
|
||
} |
68 changes: 68 additions & 0 deletions
68
...a/tests/integration/com/microsoft/azure/sdk/iot/helpers/proxy/ActivityTrackerAdapter.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,68 @@ | ||
package tests.integration.com.microsoft.azure.sdk.iot.helpers.proxy; | ||
|
||
import io.netty.handler.codec.http.HttpRequest; | ||
import io.netty.handler.codec.http.HttpResponse; | ||
|
||
import javax.net.ssl.SSLSession; | ||
import java.net.InetSocketAddress; | ||
|
||
/** | ||
* Adapter of {@link ActivityTracker} interface that provides default no-op | ||
* implementations of all methods. | ||
*/ | ||
public class ActivityTrackerAdapter implements ActivityTracker { | ||
|
||
@Override | ||
public void bytesReceivedFromClient(FlowContext flowContext, | ||
int numberOfBytes) { | ||
} | ||
|
||
@Override | ||
public void requestReceivedFromClient(FlowContext flowContext, | ||
HttpRequest httpRequest) { | ||
} | ||
|
||
@Override | ||
public void bytesSentToServer(FullFlowContext flowContext, int numberOfBytes) { | ||
} | ||
|
||
@Override | ||
public void requestSentToServer(FullFlowContext flowContext, | ||
HttpRequest httpRequest) { | ||
} | ||
|
||
@Override | ||
public void bytesReceivedFromServer(FullFlowContext flowContext, | ||
int numberOfBytes) { | ||
} | ||
|
||
@Override | ||
public void responseReceivedFromServer(FullFlowContext flowContext, | ||
HttpResponse httpResponse) { | ||
} | ||
|
||
@Override | ||
public void bytesSentToClient(FlowContext flowContext, | ||
int numberOfBytes) { | ||
} | ||
|
||
@Override | ||
public void responseSentToClient(FlowContext flowContext, | ||
HttpResponse httpResponse) { | ||
} | ||
|
||
@Override | ||
public void clientConnected(InetSocketAddress clientAddress) { | ||
} | ||
|
||
@Override | ||
public void clientSSLHandshakeSucceeded(InetSocketAddress clientAddress, | ||
SSLSession sslSession) { | ||
} | ||
|
||
@Override | ||
public void clientDisconnected(InetSocketAddress clientAddress, | ||
SSLSession sslSession) { | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...c/test/java/tests/integration/com/microsoft/azure/sdk/iot/helpers/proxy/ChainedProxy.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,77 @@ | ||
package tests.integration.com.microsoft.azure.sdk.iot.helpers.proxy; | ||
|
||
import io.netty.handler.codec.http.HttpObject; | ||
|
||
import java.net.InetSocketAddress; | ||
|
||
/** | ||
* <p> | ||
* Encapsulates information needed to connect to a chained proxy. | ||
* </p> | ||
* | ||
* <p> | ||
* Sub-classes may wish to extend {@link ChainedProxyAdapter} for sensible | ||
* defaults. | ||
* </p> | ||
*/ | ||
public interface ChainedProxy extends SslEngineSource | ||
{ | ||
/** | ||
* Return the {@link InetSocketAddress} for connecting to the chained proxy. | ||
* Returning null indicates that we won't chain. | ||
* | ||
* @return The Chain Proxy with Host and Port. | ||
*/ | ||
InetSocketAddress getChainedProxyAddress(); | ||
|
||
/** | ||
* (Optional) ensure that the connection is opened from a specific local | ||
* address (useful when doing NAT traversal). | ||
* | ||
* @return | ||
*/ | ||
InetSocketAddress getLocalAddress(); | ||
|
||
/** | ||
* Tell LittleProxy what kind of TransportProtocol to use to communicate | ||
* with the chained proxy. | ||
* | ||
* @return | ||
*/ | ||
TransportProtocol getTransportProtocol(); | ||
|
||
/** | ||
* Implement this method to tell LittleProxy whether or not to encrypt | ||
* connections to the chained proxy for the given request. If true, | ||
* LittleProxy will call {@link SslEngineSource#newSslEngine()} to obtain an | ||
* SSLContext used by the downstream proxy. | ||
* | ||
* @return true of the connection to the chained proxy should be encrypted | ||
*/ | ||
boolean requiresEncryption(); | ||
|
||
/** | ||
* Filters requests on their way to the chained proxy. | ||
* | ||
* @param httpObject | ||
*/ | ||
void filterRequest(HttpObject httpObject); | ||
|
||
/** | ||
* Called to let us know that connecting to this proxy succeeded. | ||
*/ | ||
void connectionSucceeded(); | ||
|
||
/** | ||
* Called to let us know that connecting to this proxy failed. | ||
* | ||
* @param cause | ||
* exception that caused this failure (may be null) | ||
*/ | ||
void connectionFailed(Throwable cause); | ||
|
||
/** | ||
* Called to let us know that we were disconnected. | ||
*/ | ||
void disconnected(); | ||
} |
Oops, something went wrong.