chunking-strategy
Provides chunking strategies for RAG systems. Generates chunk size recommendations (256-1024 tokens), overlap percentages…
Provides patterns for unit testing Spring Security with `@PreAuthorize`, `@Secured`, `@RolesAllowed`. Validates role-based access control and authorization policies. Use when testing security configurations and access control logic.
Claude Code
$ npx -y skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-security-authorization --agent claude-code
Codex
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-security-authorization -a codex -y
Cursor
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-security-authorization -a cursor -y
Gemini CLI
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-security-authorization -a gemini-cli -y
GitHub Copilot
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-security-authorization -a github-copilot -y
OpenCode
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-security-authorization -a opencode -y
Windsurf
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-security-authorization -a windsurf -y
name: unit-test-security-authorization description: Provides patterns for unit testing Spring Security with `@PreAuthorize`, `@Secured`, `@RolesAllowed`. Validates role-based access control and authorization policies. Use when testing security configurations and access control logic. allowed-tools: Read, Write, Bash, Glob, Grep
This skill provides patterns for unit testing Spring Security authorization logic using `@PreAuthorize`, `@Secured`, `@RolesAllowed`, and custom permission evaluators. It covers testing role-based access control (RBAC), expression-based authorization, custom permission evaluators, and verifying access denied scenarios without full Spring Security context.
Use this skill when:
Follow these steps to test Spring Security authorization:
Add spring-security-test to your test dependencies:
<dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency>
@Configuration
@EnableMethodSecurity
class TestSecurityConfig { }@Test
@WithMockUser(roles = "ADMIN")
void shouldAllowAdminAccess() {
assertThatCode(() -> service.deleteUser(1L))
.doesNotThrowAnyException();
}
@Test
@WithMockUser(roles = "USER")
void shouldDenyUserAccess() {
assertThatThrownBy(() -> service.deleteUser(1L))
.isInstanceOf(AccessDeniedException.class);
}@Test
void shouldGrantPermissionToOwner() {
Authentication auth = new UsernamePasswordAuthenticationToken(
"alice", null, List.of(new SimpleGrantedAuthority("ROLE_USER"))
);
Document doc = new Document(1L, "Test", new User("alice"));
boolean result = evaluator.hasPermission(auth, doc, "WRITE");
assertThat(result).isTrue();
}If tests pass unexpectedly, add this assertion to verify security is enforced:
@Test
void shouldRejectUnauthorizedWhenSecurityEnabled() {
assertThatThrownBy(() -> service.deleteUser(1L))
.isInstanceOf(AccessDeniedException.class);
}| Annotation | Description | Example | |------------|-------------|---------| | `@PreAuthorize` | Pre-invocation authorization | `@PreAuthorize("hasRole('ADMIN')")` | | `@PostAuthorize` | Post-invocation authorization | `@PostAuthorize("returnObject.owner == authentication.name")` | | `@Secured` | Simple role-based security | `@Secured("ROLE_ADMIN")` | | `@RolesAllowed` | JSR-250 standard | `@RolesAllowed({"ADMIN", "MANAGER"})` | | `@WithMockUser` | Test annotation | `@WithMockUser(roles = "ADMIN")` |
@Service
public class UserService {
@PreAuthorize("hasRole('ADMIN')")
public void deleteUser(Long userId) {
// delete logic
}
}
// Test
@Test
@WithMockUser(roles = "ADMIN")
void shouldAllowAdminToDeleteUser() {
assertThatCode(() -> service.deleteUser(1L))
.doesNotThrowAnyException();
}
@Test
@WithMockUser(roles = "USER")
void shouldDenyUserFromDeletingUser() {
assertThatThrownBy(() -> service.deleteUser(1L))
.isInstanceOf(AccessDeniedException.class);
}@PreAuthorize("#userId == authentication.principal.id")
public UserProfile getUserProfile(Long userId) {
// get profile
}
// For custom principal properties, use @WithUserDetails with a custom UserDetailsService
@Test
@WithUserDetails("alice")
void shouldAllowUserToAccessOwnProfile() {
assertThatCode(() -> service.getUserProfile(1L))
.doesNotThrowAnyException();
}> **Validation tip**: If a security test passes unexpectedly, verify that `@EnableMethodSecurity` is active on the test configuration — a missing annotation causes all `@PreAuthorize` checks to be bypassed silently.
See [references/basic-testing.md](references/basic-testing.md) for more basic patterns and [references/advanced-authorization.md](references/advanced-authorization.md) for complex expressions and custom evaluators.
1. **Use `@WithMockUser`** for setting authenticated user context 2. **Test both allow and deny cases** for each security rule 3. **Test with different roles** to verify role-based decisions 4. **Test expression-based security** comprehensively 5. **Mock external dependencies** (permission evaluators, etc.) 6. **Test anonymous access separately** from authenticated access 7. **Use `@EnableGlobalMethodSecurity`** in configuration for method-level security
Modular plugin marketplace for Claude Code and agentic CLIs, with validated, spec-driven skills, agents, commands, and workflows for Java, TypeScript, Python, PHP, AWS, and AI.
Provides chunking strategies for RAG systems. Generates chunk size recommendations (256-1024 tokens), overlap percentages…
Provides workflows to write, debug, and optimize prompts for LLMs, including few-shot example selection, chain-of-thought…
Implements document chunking, embedding generation, vector storage, and retrieval pipelines for Retrieval-Augmented Generation…
Provides AWS CloudFormation patterns for Auto Scaling including EC2, ECS, and Lambda. Use when creating Auto Scaling groups,…
Provides AWS CloudFormation patterns for Amazon Bedrock resources including agents, knowledge bases, data sources, guardrails,…
Provides AWS CloudFormation patterns for CloudFront distributions, origins (ALB, S3, Lambda@Edge, VPC Origins), CacheBehaviors,…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.