Skip to content

test: cover the interactions handler, settings commands, server and crypto; fuzz the parser and rules - #50

Merged
jordan-simonovski merged 2 commits into
mainfrom
test/fill-gaps
Nov 14, 2026
Merged

jordan-simonovski merged 2 commits into
mainfrom
test/fill-gaps

Conversation

@jordan-simonovski

Copy link
Copy Markdown
Owner

Implements docs/backlog/16-test-gaps.md (deleted in this PR, with its index row), the last backlog item. Tests only; no production code changes.

What's covered

  • interactions_processor_test.go, new; the handler had no tests. It goes through the same signature gate the server uses:
    • an unsigned request gets 401 and never reaches the service
    • a body without payload gets 400
    • a non-block_actions payload, or one without the snark dropdown, gets 200 with no call
    • levels 0, 11 and abc get "Invalid snark level."
    • levels 7 and 10 reach the service with the payload's team, channel and user
    • a service error gets 500
  • Settings commands (commands_settings_test.go, new):
    • reply_mode thread|channel, and sideways gets usage
    • snark 7 sets it, snark abc is rejected, and a service validation error is shown with 200
    • emoji, emoji reset, emoji workspace reset and emoji 3 :fire: reach the service with the right workspace flag
    • an InputError is shown with the example; any other error shows only the generic retry message
    • emoji without reaction settings gets usage
  • internal/http: /healthz returns status: ok, and with OAuth off /slack/install and /slack/oauth/callback return 503.
  • internal/crypto:
    • wrong-length keys, bad base64 and an empty key are rejected
    • a blob shorter than the nonce, or with one flipped bit, fails to decrypt
    • two encryptions of the same token differ
  • Fuzz tests:
    • FuzzParseKarmaSegments: never panics; every segment has exactly one well-formed ID and a symbol run that is all + or only the dash characters the parser accepts
    • FuzzEvaluateKarmaActionWithLimits: an applied outcome moves karma by 1 to 5, and self-karma is never applied

Results

Package Before After Target
internal/slack 77.7% 84.2% above 75%
internal/crypto 68.0% 88.0% above 85%
internal/http 61.9% 95.2% above 80%
internal/parser 90.7% 92.6% —

Both fuzzers ran 30 seconds each locally, about 11.4M and 9.3M executions, with no failures. No corpus files are committed; go test runs the seed inputs on every run. make check passes. No changeset.

Review

/ce-code-review ran as a lite testing review. It confirmed every bullet in the brief has an asserting test that would fail if its behaviour broke, the fuzz invariants match the parser and the rules exactly, and nothing depends on map order or timing. Applied: its one finding, the test fake's level encoding (wrong for levels of 10 and above), plus a level-10 case.

…rypto; fuzz the parser and rules

- interactions_processor_test.go: signatures, malformed payloads, the snark
  dropdown's valid and invalid levels, service errors
- settings command paths: reply_mode, snark text, every emoji subcommand,
  input errors versus generic errors, emoji without reaction settings
- /healthz and the disabled OAuth routes; crypto key validation, short and
  tampered blobs, random nonces
- native fuzz tests for ParseKarmaSegments and EvaluateKarmaActionWithLimits

Coverage: slack 77.7% to 84.2%, crypto 68.0% to 88.0%, http 61.9% to 95.2%,
parser 90.7% to 92.6%.
@jordan-simonovski
jordan-simonovski merged commit b5a8576 into main Nov 14, 2026
4 checks passed
@jordan-simonovski
jordan-simonovski deleted the test/fill-gaps branch November 14, 2026 10:03
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