Skip to content

Adds option to set Principal in MockServerWebExchange #34789

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

blake-bauman
Copy link
Contributor

Add a Principal for MockServerWebExchange.Builder to allow for a mock Principal object to be used with unit tests.

Add a Principal for MockServerWebExchange.Builder to allow for
a mock Principal object to be used with unit tests

Signed-off-by: blake_bauman <blake_bauman@apple.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 21, 2025
@blake-bauman
Copy link
Contributor Author

Use case: If the class you're testing makes a call to exchange.getPrincipal() the current MockServerWebExchange will only ever return Mono.empty().

@rstoyanchev rstoyanchev self-assigned this Apr 22, 2025
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 22, 2025
@rstoyanchev rstoyanchev added this to the 6.2.7 milestone Apr 22, 2025
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We made a similar change in 6.2.5 to allow setting the ApplicationContext. We can add this as well.

@rstoyanchev rstoyanchev changed the title Adds option for Principal in MockServerWebExchange Adds option to set Principal in MockServerWebExchange Apr 22, 2025
rstoyanchev pushed a commit that referenced this pull request Apr 25, 2025
See gh-34789

Signed-off-by: blake_bauman <blake_bauman@apple.com>
@sbrannen sbrannen added the in: test Issues in the test module label May 15, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
in: test Issues in the test module in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants