Project: InterimPlaza Recruitment Platform For: Development & QA Teams Last Updated: October 10, 2025
cd /workspace/backend
./mvnw test -Dtest="*SecurityTest"
# Authentication Security
./mvnw test -Dtest=AuthControllerSecurityTest
# JWT Token Security
./mvnw test -Dtest=JwtTokenSecurityTest
# Password Security
./mvnw test -Dtest=PasswordSecurityTest
# Security Headers & CORS
./mvnw test -Dtest=SecurityHeadersTest
# Rate Limiting & DDoS
./mvnw test -Dtest=RateLimitingSecurityTest
./mvnw clean test jacoco:report
open target/site/jacoco/index.html
File: AuthControllerSecurityTest.java
Tests: 50+
Coverage: SQL injection, XSS, authentication, input validation
Key Test Categories:
Example Test:
@Test
void testSqlInjectionProtection_Login() {
// Verifies SQL injection is blocked
}
File: JwtTokenSecurityTest.java
Tests: 40+
Coverage: Token generation, validation, tampering detection
Key Test Categories:
Example Test:
@Test
void testValidateToken_WrongSignature() {
// Verifies tampered tokens are rejected
}
File: PasswordSecurityTest.java
Tests: 30+
Coverage: Hashing, strength validation, common password detection
Key Test Categories:
Example Test:
@Test
void testPasswordHashing_UniqueSalts() {
// Verifies each password gets unique salt
}
File: SecurityHeadersTest.java
Tests: 35+
Coverage: CORS, CSP, XSS protection, security headers
Key Test Categories:
Example Test:
@Test
void testCors_LocalhostOriginsAllowed() {
// Verifies CORS from localhost:4200
}
File: RateLimitingSecurityTest.java
Tests: 20+
Coverage: Brute force protection, DDoS prevention, concurrent requests
Key Test Categories:
Example Test:
@Test
void testBruteForceProtection_MultipleFailedLogins() {
// Verifies system handles brute force attacks
}
@Test
void testSqlInjection() {
String maliciousInput = "' OR '1'='1' --";
mockMvc.perform(post("/api/auth/login")
.contentType(MediaType.APPLICATION_JSON)
.content("{\"email\":\"" + maliciousInput + "\"}"))
.andExpect(status().isUnauthorized());
}
@Test
void testXssProtection() {
String xssAttempt = "<script>alert('XSS')</script>";
RegisterRequest request = RegisterRequest.builder()
.firstName(xssAttempt)
.build();
mockMvc.perform(post("/api/auth/register")
.content(objectMapper.writeValueAsString(request)))
.andExpect(status().isBadRequest());
}
@Test
void testJwtValidation() {
String token = jwtTokenProvider.generateToken(userDetails);
assertTrue(jwtTokenProvider.isTokenValid(token, userDetails));
}
@Test
void testPasswordStrength() {
String weakPassword = "weak";
assertFalse(isPasswordStrong(weakPassword));
}
@Test
void testSecurityHeaders() {
mockMvc.perform(get("/api/jobs"))
.andExpect(header().exists("X-Frame-Options"))
.andExpect(header().exists("X-XSS-Protection"));
}
Solution:
./mvnw clean install
./mvnw test -Dtest="*SecurityTest"
Solution: Check that JWT secret is properly configured in test profile
# application-test.yml
security:
jwt:
secret: test-secret-key-minimum-256-bits-long
Solution: Verify CORS origins in SecurityConfig.java match test expectations
Solution: Rate limiting tests include concurrent operations; this is expected
# Run without rate limiting tests
./mvnw test -Dtest="*SecurityTest" -Dtest="!RateLimitingSecurityTest"
@Transactional for automatic rollback@BeforeEach or @AfterEach// Good
@Test
@DisplayName("Should reject SQL injection in login email field")
void testSqlInjectionProtection_Login() { }
// Bad
@Test
void test1() { }
// Good
assertFalse(isPasswordStrong(weakPassword),
"Weak passwords should be rejected");
// Bad
assertFalse(isPasswordStrong(weakPassword));
@ParameterizedTest
@ValueSource(strings = {"admin", "password", "123456"})
void testCommonPasswords(String password) {
assertTrue(isCommonPassword(password));
}
name: Security Tests
on: [push, pull_request]
jobs:
security-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
- name: Run Security Tests
run: ./mvnw test -Dtest="*SecurityTest"
- name: Generate Coverage Report
run: ./mvnw jacoco:report
- name: Upload Coverage
uses: codecov/codecov-action@v3
| Test Suite | Execution Time | Status | |------------|----------------|--------| | AuthController Security | ~15 seconds | ✅ Fast | | JWT Token Security | ~8 seconds | ✅ Fast | | Password Security | ~12 seconds | ✅ Fast | | Security Headers | ~10 seconds | ✅ Fast | | Rate Limiting | ~25 seconds | ⚠️ Moderate | | Total | ~70 seconds | ✅ Acceptable |
| Component | Target | Current | Status | |-----------|--------|---------|--------| | AuthController | 80% | 85% | ✅ Met | | JWT Token Provider | 80% | 92% | ✅ Exceeded | | Password Encoder | 80% | 95% | ✅ Exceeded | | Security Config | 80% | 88% | ✅ Exceeded | | Overall | 80% | 87% | ✅ Exceeded |
# application-test.yml
logging:
level:
nl.glorylabs: DEBUG
org.springframework.security: DEBUG
./mvnw test -Dtest=AuthControllerSecurityTest#testSqlInjectionProtection_Login -X
# HTML report
open target/surefire-reports/index.html
# Console output
cat target/surefire-reports/TEST-*.xml
find backend/src/test -name "*Security*Test.java"
grep -r "@Test" backend/src/test/java/*Security* | wc -l
./mvnw jacoco:report
grep -A 3 "Total" target/site/jacoco/index.html
./mvnw test -Dtest="*SecurityTest" -DforkCount=4
If you find security issues:
Last Updated: October 10, 2025 Maintained by: Development Team Project: InterimPlaza Recruitment Platform
"Testing is not just about finding bugs; it's about preventing them." 🛡️
Reacties