Skip to content

fix(test): align OrderBySessionHardeningTest with shipped get_order_string#7185

Merged
TheWitness merged 2 commits into
Cacti:1.2.xfrom
somethingwithproof:fix/1.2.x-ordertest-align
Jun 3, 2026
Merged

fix(test): align OrderBySessionHardeningTest with shipped get_order_string#7185
TheWitness merged 2 commits into
Cacti:1.2.xfrom
somethingwithproof:fix/1.2.x-ordertest-align

Conversation

@somethingwithproof
Copy link
Copy Markdown
Contributor

OrderBySessionHardeningTest (added in #7054) asserts that get_order_string() rebuilds the ORDER BY via implode(', ', $order_parts) from $_SESSION['sort_data']. #7098 later reworked the function to the cacti_normalize_sort_column / cacti_build_sort_fragment design and the test was not updated, so it is red on the current 1.2.x tip.

This updates the source-inspection assertions to the helpers the shipped function actually uses (cacti_normalize_sort_column, cacti_build_sort_fragment, allowlist validate_sort_column). No production code change. Base: 1.2.x.

…tring

Cacti#7098 reworked get_order_string() to the cacti_build_sort_fragment design but
left this test asserting the earlier implode($order_parts) shape, so it failed
on the 1.2.x tip. Assert the helpers the function actually uses.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Copilot AI review requested due to automatic review settings May 30, 2026 00:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the unit test that inspects get_order_string() to assert the hardened sorting flow (normalize/build fragment + validation) rather than the prior session-string rebuild behavior.

Changes:

  • Renamed the test to describe sort-column hardening via normalization + fragment building.
  • Updated assertions to check for cacti_normalize_sort_column(...), cacti_build_sort_fragment(...), and validate_sort_column(...) usage.

Comment thread tests/Unit/OrderBySessionHardeningTest.php
Comment thread tests/Unit/OrderBySessionHardeningTest.php Outdated
Drop the fixed 1800-byte substr window so the assertions do not break if
the function grows, and rename the test to reflect the validate_sort_column
check it enforces.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@TheWitness TheWitness merged commit 0b23a8c into Cacti:1.2.x Jun 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants