Fix 6816 sign test delay - #6917
Conversation
… add delay validation test cases to SignService tests
Aias00
left a comment
There was a problem hiding this comment.
Review: Fix #6816 sign test delay
Verdict: ✅ Approve
What it fixes
SignServiceVersionOneTest and SignServiceVersionTwoTest built ComposableSignService with new, so Spring never processed the service's @Value("${shenyu.sign.delay:5}") — delay stayed at the JVM default 0. The tests' own @Value private int delay field was dead code (never propagated to the service), so the success-path verification window was effectively zero tolerance. When sign-timestamp creation and signatureVerify crossed a minute boundary, a valid signature was rejected as overdue → intermittent failures.
Why the fix is correct
ComposableSignService.delayis confirmed to exist (fieldprivate int delay, line 81,@Value("${shenyu.sign.delay:5}"));ReflectionTestUtils.setField(signService, "delay", DELAY)correctly injects5minutes, matching the intended production default.- Verification uses
Math.abs(between) <= delay(ms vsdelay*60_000), so a 5-minute window now actually applies in tests. - Removes the two ineffective
@Valuefields from the test classes (they were never wired in) — clean.
Test validity (verified)
normalTestWithinConfiguredDelay signs with timestamp = now - 60_000ms (1 min earlier) and expects success(). Under delay=0 this would be overdue and fail; under delay=5 it passes — so the test genuinely guards the intended behavior rather than just passing by accident. overdueTest now uses DELAY + 1 minutes and the matching error-message format. PR reports Tests run: 41, Failures: 0.
Conclusion
Correct, well-targeted test-stability fix with a meaningful regression test. Approved.
(Reviewed as part of a descending re-pass of open PRs; this PR is new since the last review cycle.)
Fixes #6816
What this PR does
Explicitly initialize the sign verification delay in
SignServiceVersionOneTestandSignServiceVersionTwoTest.Previously, both test classes constructed
ComposableSignServicedirectly withnew. As a result, Spring did not process its@Valuefield, leavingdelayat the JVM default value of0.This could make success-expecting tests fail intermittently when timestamp creation and verification crossed a minute boundary.
This PR:
DELAY = 5test constant.ComposableSignServiceinstances withReflectionTestUtils.@Valuefields from the test classes.Tests