This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Description
I use an Authorization: Bearer {jwt} HTTP header for permissions on various parts of the graph. My tests use GraphQLTestTemplate which is super useful but I don't see any way to send the required header for tests of those parts that require it.
(Excuse my kotlin here but the code should be very similar to Java.)
@RunWith(SpringRunner::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class ApplicationTests {
@Autowired
private lateinit var graphQLTestTemplate: GraphQLTestTemplate
@Test
fun testQueryThatRequiresPermissions() {
val response = graphQLTestTemplate.postForResource("graphql/query-that-requires-permissions.graphql")
assertEquals(1, response.get("$.data.thingQueried.id", Int::class.java))
}
}
GraphQLTestTemplate has a postRequest method that looks like it might be useful to fiddle with the request before it goes to the endpoint but unfortunately it is private.
Any obvious workaround or should I not use GraphQLTestTemplate for this?