fix: use time.Truncate to avoid int32 overflow on i686

Summary

Test_helperRun/support_OAuth2 fails on 32-bit architectures (i686) because the manual expiry time truncation arithmetic at helper_test.go:43-46 overflows int32.

Root Cause

The expression 1_000_000_000 * oauth2SuccessExpiryTime.Second() uses platform-native int type. On i686, int is 32-bit, and when seconds >= 3, the product (up to 59 × 10⁹) exceeds MaxInt32 (~2.1 × 10⁹), causing silent integer overflow and incorrect time offset computation.

This results in password_expiry_utc not matching the expected value:

Error: "...password_expiry_utc=1772713260..." does not contain "password_expiry_utc=1772713294"

Fix

Replace the manual arithmetic with time.Truncate(time.Minute), which achieves the same result (zeroing sub-minute components) using int64 arithmetic internally, making it safe on all architectures.

-expiryOffset := time.Duration(
-    (1_000_000_000*oauth2SuccessExpiryTime.Second() +
-        oauth2SuccessExpiryTime.Nanosecond()) * -1,
-)
-oauth2SuccessExpiryTime = oauth2SuccessExpiryTime.Add(expiryOffset)
+oauth2SuccessExpiryTime = oauth2SuccessExpiryTime.Truncate(time.Minute)

Testing

All 12 Test_helperRun subtests pass locally.

Closes #8198 (closed)

Changelog: fixed

Edited by Ashutosh Kumar Singh

Merge request reports

Loading