Skip to content

Mock Jwt Support should accept a fully-configured Jwt #6896

New issue

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

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

Already on GitHub? Sign in to your account

Closed
jzheaux opened this issue May 22, 2019 · 5 comments · Fixed by #7002
Closed

Mock Jwt Support should accept a fully-configured Jwt #6896

jzheaux opened this issue May 22, 2019 · 5 comments · Fixed by #7002
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) in: test An issue in spring-security-test type: enhancement A general enhancement
Milestone

Comments

@jzheaux
Copy link
Contributor

jzheaux commented May 22, 2019

A tester can configure a mock request with a Jwt like so:

this.mvc.perform(get("/")
    .with(jwt()))
// ...

Or like so:

this.mvc.perform(get("/")
    .with(jwt(jwt -> jwt.subject("sub"))))
// ...

It'd be nice to also accept a fully-configured Jwt:

Jwt jwt = // ...
this.mvc.perform(get("/")
    .with(jwt(jwt)))
// ...

Both on the servlet side as well as the reactive side:

Jwt jwt = // ...
this.client
    .mutateWith(mockJwt(jwt))
// ...
@jzheaux jzheaux added in: test An issue in spring-security-test type: enhancement A general enhancement in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: first-timers-only An issue that can only be worked on by brand new contributors labels May 22, 2019
@jzheaux jzheaux added this to the General Backlog milestone May 22, 2019
@sandmannn
Copy link
Contributor

Hi, I would like to pick this up

@jzheaux
Copy link
Contributor Author

jzheaux commented May 22, 2019

Thanks, @sandmannn! It's yours.

@jzheaux jzheaux self-assigned this May 22, 2019
@jzheaux jzheaux removed the status: first-timers-only An issue that can only be worked on by brand new contributors label May 22, 2019
@jzheaux
Copy link
Contributor Author

jzheaux commented May 29, 2019

@sandmannn how are things coming? Do you have any questions?

@sandmannn
Copy link
Contributor

I think servlet and reactive can be addressed in different PRs. Lets start iterating on servlet part in this PR #6923
What would be the best place to put tests for it? Up to now I found only https://github.com/sandmannn/spring-security/blob/d0f5b428847c1050d38da7d2af98eb2cda6a9b9e/samples/boot/oauth2resourceserver/src/test/java/sample/OAuth2ResourceServerControllerTests.java where the existing jwt() calls are used in mockMvc.perform(get(....).with(jwt())) style, as you specified in original post.

sandmannn added a commit to sandmannn/spring-security that referenced this issue Jun 10, 2019
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to the MockMvc request builder.

Issue: spring-projectsgh-6896
jzheaux pushed a commit that referenced this issue Jun 12, 2019
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to the MockMvc request builder.

Issue: gh-6896
@jzheaux jzheaux modified the milestones: General Backlog, 5.2.x Jun 12, 2019
sandmannn added a commit to sandmannn/spring-security that referenced this issue Jun 13, 2019
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to WebTestClient mutator.

Fixes: spring-projectsgh-6896
jzheaux pushed a commit that referenced this issue Jun 15, 2019
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to WebTestClient mutator.

Fixes: gh-6896
@jzheaux jzheaux modified the milestones: 5.2.x, 5.2.0.RC1 Jun 17, 2019
kostya05983 pushed a commit to kostya05983/spring-security that referenced this issue Aug 26, 2019
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to the MockMvc request builder.

Issue: spring-projectsgh-6896
kostya05983 pushed a commit to kostya05983/spring-security that referenced this issue Aug 26, 2019
Added new implementation of jwt() method that
makes it possible to directly provide a previously
prepared JWT token to WebTestClient mutator.

Fixes: spring-projectsgh-6896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) in: test An issue in spring-security-test type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants