Skip to content

Commit ac225c0

Browse files
authored
Merge pull request #193 from devondragon/feature/test-improvements
Feature/test improvements
2 parents b18ada8 + bf24f49 commit ac225c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+8719
-87
lines changed

FAILING_TESTS_ANALYSIS.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Failing Tests Analysis
2+
3+
## Summary
4+
As of July 21, 2025, there are 18 failing tests out of 232 total tests (92% passing).
5+
Failures are in authentication-related integration tests and async event handling tests.
6+
7+
## Failing Tests Details
8+
9+
### 1. AuthenticationIntegrationTest (5 failures)
10+
11+
#### Test: `login_validCredentials_authenticatesAndRedirects`
12+
- **Issue**: Login with valid credentials is being rejected
13+
- **Expected**: Redirect to `/index.html?messageKey=message.loginSuccess`
14+
- **Actual**: Redirect to `/user/login.html?error`
15+
- **Root Cause**: Unknown - user is created with properly encoded password, but authentication fails
16+
17+
#### Test: `login_withRememberMe_setsRememberMeCookie`
18+
- **Issue**: Same as above - valid login being rejected
19+
- **Expected**: Successful login with remember-me
20+
- **Actual**: Login failure
21+
22+
#### Test: `showLoginPage_unauthenticated_showsLoginPageOrNotFound`
23+
- **Issue**: Template rendering error
24+
- **Error**: `TemplateInputException: Error resolving template [user/login]`
25+
- **Root Cause**: Test environment doesn't have Thymeleaf templates
26+
27+
#### Test: `accessProtectedResource_authenticated_allowsAccess`
28+
- **Issue**: @WithMockUser not working with UserAPI endpoint
29+
- **Error**: `SecurityException: User not logged in`
30+
- **Root Cause**: UserAPI.validateAuthenticatedUser() checks for actual authentication, not mocked
31+
32+
#### Test: `login_withSavedRequest_redirectsToOriginalUrl`
33+
- **Issue**: Login fails, so saved request redirect doesn't work
34+
- **Root Cause**: Same as valid credentials test
35+
36+
### 2. SecurityConfigurationTest (2 failures)
37+
38+
#### Test: `formLogin_validCredentials_authenticatesUser`
39+
- **Issue**: Authentication fails with valid credentials
40+
- **Error**: `Authentication should not be null`
41+
- **Root Cause**: Same authentication issue as AuthenticationIntegrationTest
42+
43+
#### Test: `accessProtectedEndpoint_authenticated_allowsAccess`
44+
- **Issue**: @WithMockUser not working with UserAPI endpoint
45+
- **Error**: `SecurityException: User not logged in`
46+
- **Root Cause**: Same as AuthenticationIntegrationTest
47+
48+
## Common Patterns
49+
50+
1. **Valid Login Failures**: The main issue is that valid logins are being rejected. This suggests:
51+
- Possible mismatch between test data setup and authentication configuration
52+
- Spring Security configuration in tests might be different from expected
53+
- Password encoding/matching issue despite correct setup
54+
55+
2. **Template Rendering**: Tests expecting HTML responses fail because templates don't exist in test environment
56+
- Could be fixed by using REST endpoints or mocking template resolution
57+
58+
3. **Mock Authentication**: @WithMockUser doesn't satisfy UserAPI's authentication checks
59+
- UserAPI uses custom validation that checks actual authentication state
60+
- Would need to use real authentication or modify tests to use different endpoints
61+
62+
## Recommendations for Fixing
63+
64+
1. **For login failures**:
65+
- Add more debug logging to see what's happening during authentication
66+
- Check if Spring Security configuration is loaded correctly in tests
67+
- Verify the authentication manager configuration
68+
69+
2. **For template issues**:
70+
- Mock template resolution
71+
- Use REST endpoints instead of page endpoints
72+
- Add test templates
73+
74+
3. **For mock authentication**:
75+
- Use actual authentication flow instead of @WithMockUser
76+
- Or use endpoints that rely on Spring Security instead of custom checks
77+
78+
### 3. EventSystemIntegrationTest (8 failures)
79+
80+
#### Tests: Registration event flow tests
81+
- **Issue**: Async event handling timeout
82+
- **Error**: `CountDownLatch.await() returned false`
83+
- **Root Cause**: @Async events not being processed synchronously in tests
84+
- **Fix**: Need to configure synchronous TaskExecutor for tests
85+
86+
#### Tests: Authentication event flow tests
87+
- **Issue**: Similar async timeout issues
88+
- **Root Cause**: Same as above
89+
90+
#### Tests: Event ordering tests
91+
- **Issue**: Async processing makes event order non-deterministic
92+
- **Root Cause**: Tests assume synchronous processing
93+
94+
## Test Coverage Achieved
95+
96+
Despite these failures, we successfully added comprehensive test coverage for:
97+
- DSUserDetailsService (10 tests, 100% passing)
98+
- AuthorityService (15 tests, 100% passing)
99+
- LoginSuccessService (6 tests, 100% passing)
100+
- LoginAttemptService (5 tests, 100% passing - already existed)
101+
- UserService (Enhanced from 6 to 26 tests, 100% passing)
102+
- UserAPI (20 tests, 100% passing)
103+
- UserActionController (11 tests, 100% passing)
104+
- UserPageController (19 tests, 100% passing)
105+
- UserEmailService (12 tests, 100% passing)
106+
- RegistrationListener (8 tests, 100% passing)
107+
- AuthenticationEventListener (10 tests, 100% passing)
108+
- AuditEventListener (13 tests, 100% passing)
109+
- OnRegistrationCompleteEvent (6 tests, 100% passing)
110+
- UserPreDeleteEvent (6 tests, 100% passing)
111+
112+
Total test count increased from ~79 to 232 tests, improving overall test coverage significantly. The failing tests are primarily integration tests with environmental dependencies (templates) or async processing issues.

0 commit comments

Comments
 (0)