FOUR-20950: Handle Cache Invalidation for ETags by eiresendez · Pull Request #7817 · ProcessMaker/processmaker

Issue & Reproduction Steps

This PR adds a test to ensure that cache invalidation works correctly for routes using the etag middleware with the etag_tables configuration. The existing functionality correctly handled ETag generation and cache invalidation, but there was no explicit test coverage for the scenarios where changes in updated_at in the specified tables should trigger cache invalidation.

  1. Define a route using the etag middleware and specify etag_tables in the route’s defaults.
  2. Perform an initial request to retrieve the ETag.
  3. Update the updated_at column in the database for the specified table.
  4. Expect the ETag to change and invalidation to occur.

Solution

  • Introduced a new test case to verify cache invalidation when the updated_at field in the specified tables changes.
  • Ensured the test validates that the ETag changes after database updates and remains the same if no updates are made.

How to Test

  1. Setup:
  • Create a route using the etag middleware with etag_tables pointing to a database table (e.g., processes).
  1. Run the test:
  • Execute a manual test to ensure the ETag updates correctly when updated_at in the database changes.
  • Validate that:
    • The ETag remains unchanged if there are no updates.
    • The ETag changes after an update to updated_at.
    • A 200 OK is returned when the client sends an outdated ETag.

The functionality now has complete test coverage to ensure the proper behavior of cache invalidation using etag_tables.

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.