spring-security-testing
Spring Security 7 changed method security defaults and CSRF handling — tests using hasRole() or csrf() may need updates. Read before testing authentication, authorization, or secured endpoints. Triggers: @WithMockUser, csrf(), jwt(), oauth2Login(), SecurityFilterChain, @PreAuthorize, AccessDeniedException, @WithUserDetails, @WithSecurityContext, hasRole, hasAuthority, SCOPE_, JwtAuthenticationToken.
How do I install this agent skill?
npx skills add https://github.com/spring-ai-community/spring-testing-skills --skill spring-security-testingIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides comprehensive and safe guidance for testing Spring Security applications, following industry best practices for authentication and authorization testing.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- Runlayerpass
1/2 files flagged
What does this agent skill do?
Spring Security Testing
Signals: @WithMockUser, @WithUserDetails, csrf(), jwt(), oauth2Login(), mockOidcLogin(), @WithSecurityContext, SecurityMockMvcRequestPostProcessors, AccessDeniedException, SCOPE_
Tested With
- Spring Boot 3.2+ / Spring Boot 4.x
- Spring Security 6.x / 7.x
- Spring Framework 6.x / Spring Framework 7.x
- JUnit 5
Do NOT Use This Skill When
- Testing REST controller HTTP behavior (status codes, JSON body, headers) without security focus → use
spring-mvc-testing - Testing reactive endpoints with security → use
spring-webflux-testing - Testing JPA repositories → use
spring-jpa-testing - Writing pure unit tests for service logic without security context → use
spring-testing-fundamentals
When to Read References
| Situation | Read |
|---|---|
@WithMockUser and @WithUserDetails setup | references/security-testing-patterns.md |
roles vs authorities and the ROLE_ prefix trap | references/security-testing-patterns.md |
Per-request auth with SecurityMockMvcRequestPostProcessors (user(), httpBasic()) | references/security-testing-patterns.md |
| CSRF on POST/PUT/DELETE — preventing 403 in tests | references/security-testing-patterns.md |
JWT resource server testing with jwt() post-processor | references/security-testing-patterns.md |
OAuth2 login and OIDC testing with oauth2Login(), mockOidcLogin() | references/security-testing-patterns.md |
Custom @WithSecurityContext for complex JWT scenarios | references/security-testing-patterns.md |
@PreAuthorize method security testing | references/security-testing-patterns.md |
| Boot 3.x → 4.x security testing changes | references/security-testing-patterns.md |
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/spring-ai-community/spring-testing-skills/spring-security-testing">View spring-security-testing on skillZs</a>