🧪 Add unit test for HTTP.secure_pool_opts/0 - #38
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Greptile SummaryThis PR adds a previously missing unit test for
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| test/x402/facilitator/http_test.exs | Adds a unit test for secure_pool_opts/0 asserting the correct TLS keyword-list structure and removes an unused import X402.TestHelpers. The structural pattern-match assertion is solid; the secondary equality assertion against a second :public_key.cacerts_get() call is tautological (already raised in previous review thread). |
| test/x402/extensions/payment_identifier/ets_cache_test.exs | Increases ttl_ms and cleanup_interval_ms from 10 ms to 50 ms in the periodic-cleanup test to give the scheduler more headroom, reducing timing-related flakiness with no logic changes. |
| test/x402/extensions/siwx/ets_storage_test.exs | Prefixes three unused table bindings with _ (_table) to silence Elixir unused-variable warnings. The one test that still uses table for a direct ETS lookup is correctly left unchanged. |
Sequence Diagram
sequenceDiagram
participant Test as secure_pool_opts/0 test
participant HTTP as X402.Facilitator.HTTP
participant PK as :public_key (OTP)
Test->>HTTP: secure_pool_opts()
HTTP->>PK: cacerts_get()
PK-->>HTTP: [cert, ...]
HTTP-->>Test: [conn_opts: [transport_opts: [verify: :verify_peer, cacerts: [...]]]]
Note over Test: Pattern-match asserts structure<br/>and binds `cacerts`
Test->>PK: cacerts_get() (second call for equality check)
PK-->>Test: [cert, ...]
Test->>Test: assert cacerts == result
Reviews (5): Last reviewed commit: "fix: Resolve test flake in ETSCacheTest ..." | Re-trigger Greptile
| ] | ||
| ] = HTTP.secure_pool_opts() | ||
|
|
||
| assert cacerts == :public_key.cacerts_get() |
There was a problem hiding this comment.
Tautological assertion — consider a structural check instead
The second assertion calls :public_key.cacerts_get() a second time, which means both the function under test and the assertion use the identical underlying call. This is inherently tautological: the assertion can never fail unless the CA store changes between the two calls (milliseconds apart), which is functionally impossible in a test environment.
A stronger assertion would verify that the certs were actually loaded and are non-empty — that's what "system CA certificates loaded" really means:
| assert cacerts == :public_key.cacerts_get() | |
| assert is_list(cacerts) and cacerts != [] |
This would catch a regression where secure_pool_opts/0 is changed to return an empty list or nil for cacerts, which the current assertion would also fail on, but it more directly encodes the intent ("real certs were loaded") rather than "this equals a second call of the same function."
|
@greptile review |
|
LGTM! The test correctly validates that This is a solid addition that locks in the expected TLS defaults. Good work on improving test coverage! ✅ |
|
@greptile review |
|
I'm here to help with the review of PR #38. What would you like to know about the new test for |
|
@greptile review |
|
I see a message that appears to be a system acknowledgment. If you'd like me to review the PR or if you have specific questions about the test changes, please let me know what you'd like me to look at. This PR adds unit test coverage for |
|
It looks like your message may have been sent incomplete or by accident. Is there anything about the PR or the test coverage I can help you with? |
Co-authored-by: cardotrejos <[email protected]>
Co-authored-by: cardotrejos <[email protected]>
* Increased `ttl_ms` and `cleanup_interval_ms` in `ETSCacheTest` to prevent race conditions during cleanup assertions. * Fixed unused variable warnings for `table` in `ETSStorageTest`. * Removed unused import in `http_test.exs`. Co-authored-by: cardotrejos <[email protected]>
* Increased `ttl_ms` and `cleanup_interval_ms` in `ETSCacheTest` to prevent race conditions during cleanup assertions. * Fixed unused variable warnings for `table` in `ETSStorageTest`. * Removed unused import in `http_test.exs`. Co-authored-by: cardotrejos <[email protected]>
Asserting cacerts == :public_key.cacerts_get() calls the same underlying function twice and can never catch a regression where secure_pool_opts/0 returns empty or nil certs. Assert is_list(cacerts) and cacerts != [] directly encodes the intent: real system CA certs were loaded. Greptile P2 comment.
123bd34 to
a91b6a2
Compare
🎯 What: Added a missing unit test for the
secure_pool_opts/0function inX402.Facilitator.HTTPwhich was previously uncovered.📊 Coverage: The new test validates that the function returns the correct keyword list containing the
:verify_peerinstruction and properly loads system CA certificates using:public_key.cacerts_get().✨ Result: Test coverage for
X402.Facilitator.HTTPis improved, ensuring the default TLS configuration remains correct and won't be accidentally broken during future refactoring.PR created automatically by Jules for task 11500381449924262208 started by @cardotrejos
Note
Low Risk
Low risk: changes are limited to test adjustments, adding coverage for TLS pool options and tweaking timings/unused vars to reduce flakiness.
Overview
Adds a unit test in
X402.Facilitator.HTTPTestto assertHTTP.secure_pool_opts/0returns a TLS config withverify: :verify_peerand non-empty system CA certs, and removes an unusedimport.Stabilizes ETS-related tests by increasing TTL/cleanup intervals in
ETSCacheTestand replacing unusedtablebindings with_tableinETSStorageTest.Written by Cursor Bugbot for commit a91b6a2. This will update automatically on new commits. Configure here.