Skip to content

test(icaptcha): assert obtain_proof consumes the mocked service#184

Open
beardthelion wants to merge 1 commit into
mainfrom
test/icaptcha-mock-consumed
Open

test(icaptcha): assert obtain_proof consumes the mocked service#184
beardthelion wants to merge 1 commit into
mainfrom
test/icaptcha-mock-consumed

Conversation

@beardthelion

@beardthelion beardthelion commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

Adds an integration test that runs obtain_proof against a mockito server and asserts both /v1/challenge and /v1/answer are consumed. This proves the iCaptcha client actually calls the service rather than short-circuiting or making a live call: a regression that skipped the network would fail the test, since the mock-consumed assertions go red when the endpoints are not hit.

Adds mockito as a dev-dependency.

Verified: the test is load-bearing (red when the mock is under-consumed or the client points elsewhere, green when the service is consumed), and cargo build --workspace, fmt --check, and clippy -D warnings are clean.

Summary by CodeRabbit

  • Tests
    • Added integration coverage confirming CAPTCHA challenge and answer requests are sent to the configured service.
    • Verified mocked responses are consumed exactly once and the expected proof is returned.
    • Ensured the test does not make unintended live network calls.

Add an integration test that runs obtain_proof against a mockito server and
asserts both /v1/challenge and /v1/answer were consumed, so the flow is proven
to call the service rather than short-circuit or make a live call. Adds mockito
as a dev-dependency.
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fd3de7a8-0f27-4235-8839-2b1c14481deb

📥 Commits

Reviewing files that changed from the base of the PR and between ad7c2b2 and 99f0845.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • crates/icaptcha-client/Cargo.toml
  • crates/icaptcha-client/tests/icaptcha_mock_consumed.rs

📝 Walkthrough

Walkthrough

Adds mockito as a development dependency and introduces an integration test verifying that obtain_proof calls mocked challenge and answer endpoints exactly once and returns the expected proof.

Changes

iCaptcha mock coverage

Layer / File(s) Summary
Mocked proof acquisition test
crates/icaptcha-client/Cargo.toml, crates/icaptcha-client/tests/icaptcha_mock_consumed.rs
Adds the mockito test dependency and validates mocked challenge/answer requests, solver integration, returned proof, and endpoint consumption.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: kind:test

Suggested reviewers: jatmn, kevincodex1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: a test asserting obtain_proof uses the mocked iCaptcha service.
Description check ✅ Passed The description covers the core summary, context, and verification, so it is mostly complete despite missing template formatting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/icaptcha-mock-consumed

Comment @coderabbitai help to get the list of available commands.

@beardthelion beardthelion added the kind:test Test coverage or harness label Jul 11, 2026

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions only verify that the local mock received one request for each route. A regression can make those two requests and also send the challenge, answer, or configured API key to DEFAULT_URL (or another origin), while this test still passes. That leaves the stated guard against unintended live iCaptcha traffic and token exposure untested. Please either constrain the test's HTTP transport so every non-mock destination fails, or narrow the test name/comments and PR claim to endpoint consumption only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:test Test coverage or harness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants