This project is a Spring Boot application that demonstrates a simple employee management service with caching implemented using Caffeine. The repository has been enhanced with new features to improve functionality and security as a way to implement what we learn.
- Description: Access to cache statistics and related endpoints is restricted based on user roles.
- Implementation: Utilized Spring Security to define roles (
ADMIN
andUSER
) and restrict access to cache-related endpoints only to users with theADMIN
role.
- Description: Allows updating specific entries in the cache when the source data changes.
- Implementation: Introduced a new endpoint that uses Spring’s
@CachePut
annotation to update cache entries without invalidating the entire cache.
- Description: Implement unit tests to ensure the results of caching, security, and data update mechanisms.
- Implementation: Created end-to-end tests using
MockMvc
to simulate requests and validate responses for all key endpoints.
- Method:
GET
- Objective: Fetches the list of employees.
- Access: Open to all authenticated users.
- Method:
PUT
- Objective: Updates a specific employee and also updates the cache.
- Access: Open to all authenticated users.
- Method:
GET
- Objective: Provides statistics and details about the cache.
- Access: Restricted to authenticated users's with
ADMIN
role.
- Roles:
ADMIN
: Has full access, including cache statistics.USER
: Limited access, cannot view cache statistics.
- Authentication: Basic authentication is used for simplicity in this demonstration.
End-to-end test is implemented to test our endpoints and check the results and status codes.
Fork the repository, make your enhancements, and open a pull request for review.