Skip to content

test(rate-limit): cover the req.socket.remoteAddress fallback branch#291

Merged
CryptoJones merged 1 commit into
masterfrom
test/rate-limit-key-socket-fallback-coverage
May 19, 2026
Merged

test(rate-limit): cover the req.socket.remoteAddress fallback branch#291
CryptoJones merged 1 commit into
masterfrom
test/rate-limit-key-socket-fallback-coverage

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Summary

#287 swapped the deprecated req.connection for req.socket in the rate-limit key generator's fallback path. The existing unit tests inject a plain { ip } object and never traverse the fallback, so the new accessor was technically untested.

This PR adds an explicit case that forces the fallback by passing { socket: { remoteAddress: ... } } without req.ip — the keygen should pick the socket address up and route it through the IPv6-aware helper.

Test plan

  • npm run lint && npm test761 passing (was 760).
  • No production-code change; the regression-pin is the only addition.

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

#287 swapped the deprecated \`req.connection\` for \`req.socket\` in
the rate-limit key generator's fallback path. The existing unit tests
inject a plain { ip } object and never traverse the fallback, so the
new accessor was technically untested. Add an explicit case that
forces the fallback by passing { socket: { remoteAddress: ... } }
without req.ip — the keygen should pick the socket address up and
route it through the IPv6-aware helper.

Test count: 760 → 761.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit 075e260 into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the test/rate-limit-key-socket-fallback-coverage branch May 19, 2026 16:10
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.

1 participant