summaryrefslogtreecommitdiff
path: root/player-android/lib/api
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-20 07:39:55 +0300
committerPaul Buetow <paul@buetow.org>2026-05-20 07:39:55 +0300
commit26d3dc4e031cf195638d2483bcfcdf45fd216502 (patch)
tree7d605c37280a664dbdc018bba655993a27b1ae21 /player-android/lib/api
parent99736c4dbd196bd5a665e084c3251baa7dc444a0 (diff)
Inject clock.Clock into api.Server and replace time.Now() in share/auth handlers
handlers_share.go (handleCreateShare share-expiry) and handlers_auth.go (setSessionCookie and apiTokenExpiresAt) previously called time.Now() directly, which made time-dependent semantics impossible to assert deterministically in tests. They now use s.clk.Now(), where s.clk is a clock.Clock injected through ServerDeps.Clock (nil-default to clock.RealClock{} so existing callers keep working unchanged). apiTokenExpiresAt is promoted to a method on *Server so it can reach the injected clock. Production wiring in cmd/player/main.go passes deps.clk so handlers share the same time source as the rest of the services. Two new unit tests (handlers_share_test.go) use clock.MockClock to assert handleCreateShare and setSessionCookie compute their expiry timestamps from the injected clock rather than the wall clock. While propagating, this commit also includes a mechanical fix-up for the pathID(...) signature change (now returns int64 + error) across the API handler files so the package still builds; the additional err-check makes malformed path variables produce 400 instead of silently parsing as zero. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'player-android/lib/api')
0 files changed, 0 insertions, 0 deletions