Skip to content

Commit

Permalink
Add test to ensure the result of the first operation isn't being cach…
Browse files Browse the repository at this point in the history
…ed and that all subsequent calls are correctly being authorized
  • Loading branch information
rubik-cube-man committed Nov 12, 2023
1 parent 12d04a8 commit d40e786
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,32 @@ public void testAuthenticatedUserForSubscription() throws Exception {
public void testAuthenticatedUserForQueryWebSocket() throws Exception {
DynamicGraphQLClientBuilder clientBuilder = DynamicGraphQLClientBuilder.newBuilder()
.url(url)
.header("Authorization", "Basic ZGF2aWQ6cXdlcnR5MTIz");
//.executeSingleOperationsOverWebsocket(true);
.header("Authorization", "Basic ZGF2aWQ6cXdlcnR5MTIz")
.executeSingleOperationsOverWebsocket(true);
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ foo { message} }");
assertTrue(response.hasData());
assertEquals("foo", response.getData().getJsonObject("foo").getString("message"));
}
}

@Test
public void testAuthorizedAndUnauthorizedForQueryWebSocket() throws Exception {
DynamicGraphQLClientBuilder clientBuilder = DynamicGraphQLClientBuilder.newBuilder()
.url(url)
.header("Authorization", "Basic ZGF2aWQ6cXdlcnR5MTIz")
.executeSingleOperationsOverWebsocket(true);
try (DynamicGraphQLClient client = clientBuilder.build()) {
Response response = client.executeSync("{ foo { message} }");
assertTrue(response.hasData());
assertEquals("foo", response.getData().getJsonObject("foo").getString("message"));

// Run a second query with a different result to validate that the result of the first query isn't being cached at all.
response = client.executeSync("{ bar { message} }");
assertEquals(JsonValue.ValueType.NULL, response.getData().get("bar").getValueType());
}
}

@Test
public void testUnauthorizedUserForSubscription() throws Exception {
DynamicGraphQLClientBuilder clientBuilder = DynamicGraphQLClientBuilder.newBuilder()
Expand Down

0 comments on commit d40e786

Please sign in to comment.