This is an automated email from the ASF dual-hosted git repository.
sergehuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new aab6c9e5e Keep Jetty client types out of GraphQLWebSocketIT method
signatures (#882)
aab6c9e5e is described below
commit aab6c9e5ef3a65ec8c20235970bac62c2616c144
Author: Serge Huber <[email protected]>
AuthorDate: Tue Sep 22 15:57:13 2026 +0200
Keep Jetty client types out of GraphQLWebSocketIT method signatures (#882)
Co-authored-by: Claude Opus 4.8 <[email protected]>
---
.../unomi/itests/graphql/GraphQLWebSocketIT.java | 29 +++++++++++++---------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git
a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLWebSocketIT.java
b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLWebSocketIT.java
index b0160cb78..65a5e2479 100644
---
a/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLWebSocketIT.java
+++
b/itests/src/test/java/org/apache/unomi/itests/graphql/GraphQLWebSocketIT.java
@@ -108,15 +108,13 @@ public class GraphQLWebSocketIT extends BaseGraphQLIT {
*/
@Test
public void testWebSocketUpgrade_withoutAuth_upgradesButCannotOperate()
throws Exception {
- assertStartIsRefusedBeforeAuthentication(new ClientUpgradeRequest());
+ assertStartIsRefusedBeforeAuthentication(null, null);
}
/** A public API key is not a subscription credential, on the handshake or
anywhere else. */
@Test
public void testWebSocketUpgrade_withPublicApiKeyOnly_cannotOperate()
throws Exception {
- ClientUpgradeRequest request = new ClientUpgradeRequest();
- request.setHeader("X-Unomi-Api-Key", testPublicKeyValue);
- assertStartIsRefusedBeforeAuthentication(request);
+ assertStartIsRefusedBeforeAuthentication("X-Unomi-Api-Key",
testPublicKeyValue);
}
/** connection_init carrying a valid credential is how a browser client
authenticates. */
@@ -167,11 +165,20 @@ public class GraphQLWebSocketIT extends BaseGraphQLIT {
* The core property of the unauthenticated-upgrade path: an operation
sent before authenticating is
* refused and the socket is closed. Without this, opening the handshake
would be a regression.
*/
- private void assertStartIsRefusedBeforeAuthentication(ClientUpgradeRequest
request) throws Exception {
+ /**
+ * Jetty's websocket-client types are kept out of method signatures on
purpose: JUnit resolves
+ * signature types when it scans the class, before {@code @Before} has
waited for the container,
+ * and that bundle is not necessarily wired yet at that point.
+ */
+ private void assertStartIsRefusedBeforeAuthentication(String headerName,
String headerValue) throws Exception {
WebSocketClient client = new WebSocketClient();
Socket socket = new Socket();
try {
client.start();
+ ClientUpgradeRequest request = new ClientUpgradeRequest();
+ if (headerName != null) {
+ request.setHeader(headerName, headerValue);
+ }
Future<Session> onConnected = client.connect(socket,
graphqlWebSocketUri(), request);
RemoteEndpoint remote = onConnected.get(10,
TimeUnit.SECONDS).getRemote();
@@ -198,16 +205,12 @@ public class GraphQLWebSocketIT extends BaseGraphQLIT {
@Test
public void testWebSocketUpgrade_withWrongJaasPassword_returns401() throws
Exception {
- ClientUpgradeRequest request = new ClientUpgradeRequest();
- request.setHeader("Authorization",
basicAuthHeader(BASIC_AUTH_USER_NAME, "definitely-not-the-password"));
- assertWebSocketUpgradeRejected(request);
+ assertWebSocketUpgradeRejected(basicAuthHeader(BASIC_AUTH_USER_NAME,
"definitely-not-the-password"));
}
@Test
public void testWebSocketUpgrade_withMalformedBasic_returns401() throws
Exception {
- ClientUpgradeRequest request = new ClientUpgradeRequest();
- request.setHeader("Authorization", "Basic !!!");
- assertWebSocketUpgradeRejected(request);
+ assertWebSocketUpgradeRejected("Basic !!!");
}
@Test
@@ -270,12 +273,14 @@ public class GraphQLWebSocketIT extends BaseGraphQLIT {
}
}
- private void assertWebSocketUpgradeRejected(ClientUpgradeRequest request)
throws Exception {
+ private void assertWebSocketUpgradeRejected(String authorization) throws
Exception {
WebSocketClient client = new WebSocketClient();
Socket socket = new Socket();
try {
client.start();
URI echoUri = new URI("ws://localhost:" + getHttpPort() +
"/graphql");
+ ClientUpgradeRequest request = new ClientUpgradeRequest();
+ request.setHeader("Authorization", authorization);
Future<Session> onConnected = client.connect(socket, echoUri,
request);
try {
onConnected.get(10, TimeUnit.SECONDS);