Skip to content

Add oauth2Login MockMvc Test Support #7789

Closed
@jzheaux

Description

@jzheaux

Related to #7618

When testing applications that use OAuth 2.0 Login, it would be nice to have MockMvc support like:

this.mvc(get("/")
    .with(oauth2Login()));

or

this.mvc(get("/")
    .with(oauth2Login()
        .attribute("name", "value")
        .authorities(new SimpleGrantedAuthority("SCOPE_read")));

as well as other builder methods relative to generating an authentication statement around an OAuth2User principal.

Note that the attribute method is necessary since the OAuth 2.0 spec doesn't specify any particular claims. It, then, correlates to the idToken and userInfo methods in the oidcLogin() MockMvc support.

Metadata

Metadata

Assignees

Labels

in: testAn issue in spring-security-testtype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions