Skip to content

test(utils): cover hashIp and getClientIp - #65

Merged
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
waterlemonnn:test/hash-utils
Aug 7, 2026
Merged

test(utils): cover hashIp and getClientIp#65
royalpinto007 merged 1 commit into
AgentPostmortem:mainfrom
waterlemonnn:test/hash-utils

Conversation

@waterlemonnn

Copy link
Copy Markdown
Contributor

Summary

Adds lib/utils/hash.test.ts, covering the two functions in lib/utils/hash.ts that had no test coverage.

  • hashIp() throws when IP_HASH_PEPPER is unset
  • hashIp() is deterministic for a given input/pepper pair, and differs across peppers
  • hashIp() trims surrounding whitespace before hashing
  • getClientIp() takes the first entry of a comma-separated x-forwarded-for
  • getClientIp() falls back to x-real-ip, then to "unknown"

Closes #26.

Test plan

  • npx vitest run lib/utils/hash.test.ts — 7/7 passing
  • npx vitest run — full suite, 94/94 passing
  • npm run lint — clean
  • npx tsc --noEmit — clean

@royalpinto007
royalpinto007 merged commit 03f7a99 into AgentPostmortem:main Aug 7, 2026
11 checks passed
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Merged. Thanks a lot, @waterlemonnn.

Genuinely helpful change for agentpostmortem.

If this project helps you out, a star helps others find it too.

Happy to see more from you whenever you have the time.

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.

Add unit tests for lib/utils/hash.ts (hashIp and getClientIp)

2 participants