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 fd2780c commit 77788eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface RedisClientBuildTimeConfig {
* </ul>
*/
@ConfigDocDefault("import.redis in DEV, TEST ; no-file otherwise")
Optional<@WithConverter(TrimmedStringConverter.class) List<String>> loadScript();
Optional<List<String>> loadScript();

/**
* When using {@code redisLoadScript}, indicates if the Redis database must be flushed (erased) before importing.
Expand Down
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 77788eb

Please sign in to comment.