Add regression test for FactorGrantedAuthority Jackson support - #19594
Add regression test for FactorGrantedAuthority Jackson support#19594jyx-07 wants to merge 1 commit into
Conversation
Add a test to OAuth2AuthorizationServerJackson2ModuleTests and its Jackson 3 counterpart that round-trips an OAuth2Authorization's Principal attribute when the principal's authorities include a FactorGrantedAuthority, using the same ObjectMapper/JsonMapper setup JdbcOAuth2AuthorizationService builds internally. FactorGrantedAuthorityMixin already exists and is registered in CoreJackson2Module/CoreJacksonModule (added together with FactorGrantedAuthority itself), so this round trip already succeeds on main. This test only locks in that existing, previously uncovered behavior so a future regression is caught before release. Closes spring-projectsgh-18771 Signed-off-by: jyx-07 <s25069@gsm.hs.kr>
|
Acknowledged, I will update my test project to springboot 4.1.0 and retest the native image within the week, thanks for the heads-up, @jyx-07. |
|
hi @jyx-07, I had a quick test by upgrading springboot to 4.1.0 in my test project, replacing my own FactorGrantedAuthorityJacksonModule with CoreJacksonModule, but for some reason it didn't work at all, I ran into 2 issues:
I haven't really got time to dig deep into the issue while I am busy preparing a job interview, I will come back to it as soon as its over. Thanks for following up with me, I promise I will get back to it as it is also very important to my personal project. |
|
Thought I could leave it alone and prepare my job interview... but my curiosity just made me do this observation: |
Summary
#18771 reports that
JdbcOAuth2AuthorizationServicefails to deserializeFactorGrantedAuthoritybecause of a missing Jackson mixin, and @k6leung validated aFactorGrantedAuthorityMixin+ module as a workaround.Investigating on current
main,FactorGrantedAuthorityMixinalready exists and is already registered in bothCoreJackson2ModuleandCoreJacksonModule— it was added together withFactorGrantedAuthorityitself, before this issue was filed. A from-scratch reproduction (round-tripping aUsernamePasswordAuthenticationTokenwhose authorities include aFactorGrantedAuthority, through the exactObjectMapper/JsonMappersetupJdbcOAuth2AuthorizationServicebuilds internally) already passes onmain, so adding another mixin would just duplicate existing plumbing.Rather than duplicate that fix, this PR adds a regression test — to
OAuth2AuthorizationServerJackson2ModuleTestsand its Jackson 3 counterpartOAuth2AuthorizationServerJacksonModuleTests— that locks in the already-working round trip so a future regression here is caught before release. I verified the test is non-tautological by temporarily reverting the mixin registration locally and confirming both new tests fail without it.I'll comment on #18771 to let @k6leung know the underlying mixin is already fixed on
main.Test plan
readValueWhenOAuth2AuthorizationAttributesWithFactorGrantedAuthorityThenSuccessto bothOAuth2AuthorizationServerJackson2ModuleTestsandOAuth2AuthorizationServerJacksonModuleTests.FactorGrantedAuthorityMixinregistration is reverted, confirming they're not tautological../gradlew :spring-security-oauth2-authorization-server:test— full module suite passes.Closes gh-18771