spring-projects / spring-projects/spring-graphql

Add support for @WithMockUser to WebGraphQlTester

Open
#455 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
1.6k
Forks
336
PR merge metrics
No merged PRs in 30d

Description

We currently use the annotation @WithMockUser to impersonate a user with a specific role in our integration tests.

The WebGraphQlTester only allows for basic or bearer auth headers, so for right now, we can't create any test cases for our internal api.

Maybe there is a way currently to get the WebGraphQlTester to use the test security context overridden by WithMockUserSecurityContextFactory?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading WebGraphQlTester and the WithMockUserSecurityContextFactory mentioned in the issue, then trace how the tester currently applies basic or bearer authentication. Determine how the test security context should be used for @WithMockUser. Done means integration tests can exercise an internal GraphQL API with the mocked user and role.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, java, spring
Domain
api, authentication, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.