[Python SDK] Expand verification.py tests — did:key, constraints, refresh
Test coverage: Python SDK verification.py — did:key resolution, constraint operators, refresh
sdk/python/agentfield/verification.py already has test_verification.py, but several public methods of LocalVerifier are uncovered — and they are security-critical (policy evaluation + signature verification).
Scope
Extend sdk/python/tests/test_verification.py.
Uncovered callables:
_resolve_public_key—did:key:z...parsing + admin-key fallback_evaluate_constraints— operator logicrefresh()— success and partial-failure paths
Test cases
did:key resolution:
test_resolve_did_key_z_success— validdid:key:z6Mkp..., assert correct 32-byte public key returnedtest_resolve_did_key_invalid_multicodec—did:key:zwith wrong prefix, assertNonetest_resolve_fallback_to_admin_key— setadmin_public_key_jwkwith validx, call withdid:web:example.com, assert admin key bytes returnedtest_resolve_no_key_available— call withdid:web:...when no admin key set, assertNone
Constraints:
test_constraint_equality—{"operator": "==", "value": 10}, input 10 (allow) vs 11 (deny)test_constraint_greater_than—{"operator": ">", "value": 10}, input 11 (allow) vs 10 (deny)test_constraint_invalid_float— input"not-a-number"for a numeric constraint, assertFalse(fail-closed)test_constraint_missing_param— skip parameter required by constraint, assertTrue(silently skipped per current behavior)
Refresh:
test_refresh_success_populates_caches— mockaiohttp.ClientSession.getto return JSON for policies, revocations, and keys; assert verifier attributes updatedtest_refresh_sets_initialized_and_timestamp— assert_initializedisTrueand_last_refresh > 0test_refresh_partial_failure— one endpoint 500s; assertrefresh()returnsFalsebut other caches still update
Fixture / mock strategy
- Pre-calculated Ed25519 public keys + their
did:keyrepresentation respxorunittest.mock.AsyncMockforaiohttppytest-asyncioforrefresh
Acceptance criteria
- [ ] ≥11 new tests across the three concerns
- [ ]
uv run pytest sdk/python/tests/test_verification.pypasses - [ ] Coverage on
verification.py≥90%
Size: M · Difficulty: intermediate · Language: Python
Part of epic #387 — parent tracker.
How to work on this
Setup
git clone https://github.com/Agent-Field/agentfield.git
cd agentfield
make install # installs Go, Python (via uv), and Node deps
make build # optional — builds the control plane binary
Run the baseline test suite
Before you change anything, run the tests for the language this issue targets so you know what "green" looks like:
- Go control plane:
cd control-plane && go test ./... -count=1 - Go SDK:
cd sdk/go && go test ./... -count=1 - Python SDK:
cd sdk/python && uv run pytest -q - TypeScript SDK:
cd sdk/typescript && bun test
Package coverage baseline (so you can show improvement in the PR):
go test -cover ./control-plane/internal/...uv run pytest --cov=agentfield sdk/python/testsbun test --coverage(TypeScript)
Using Claude Code or another AI coding agent
This repo has a CLAUDE.md at the root that Claude Code and compatible agents will read automatically. A working flow:
cdinto the repo and runclaude(or open in your IDE's agent).- Paste this issue URL and say: "Please implement this issue, following every acceptance-criteria checkbox. Do not change source files — only add tests under the target path in the issue. When you're done, run the test suite command from the issue and paste the result."
- Let the agent read existing tests in the same package as a model for style / fixtures — we point to them in the issue.
- Run
make lintbefore opening the PR.
See the AI-Assisted Contributions guide for testing requirements. Tag your PR with ai-assisted if you used an AI agent.
Claiming this issue
Comment I'd like to work on this and a maintainer will assign it to you. If you're new to open source, issues labelled good first issue or first-timers-only are hand-picked for a smooth first PR — we'll guide you if you get stuck.
Opening the PR
- Branch name:
tests/<short-description>orrefactor/<short-description> - Link this issue in the PR description with
Closes #<number> - Paste the before/after test output or coverage delta in the PR body
- Keep the diff to the scope in this issue — no drive-by cleanups
Help & questions
- Comment on this issue — we monitor all assigned issues.
- Join the community Discord: run
/gsd-join-discordor check the README for the invite. - For repo-wide questions, open a discussion with the
helptag.
I would like to work on this
Hi! I’d like to work on this.
The scope and acceptance criteria are clear: add focused Python tests for LocalVerifier did:key/admin-key resolution, constraint operator behavior, and async refresh() success/partial-failure paths, without changing source files.
Rough estimate:
- Timeline: 1–2 days
- Quote: $250–$400
I’d follow the existing sdk/python/tests/test_verification.py style, use precomputed Ed25519/did:key fixtures, mock aiohttp.ClientSession.get with async-compatible mocks, and verify both the specific new test cases and the coverage target with:
uv run pytest sdk/python/tests/test_verification.py
uv run pytest --cov=agentfield sdk/python/tests
One quick clarification before starting:
- For the
refresh_partial_failurecase, should the expected behavior be “best-effort cache updates from successful endpoints + returnFalse,” even if the failing endpoint is encountered before later endpoints?
Happy to take this on and submit a clean PR.
Hi! I’d like to work on this.
The scope and acceptance criteria are clear: add focused Python tests for
LocalVerifierdid:key/admin-key resolution, constraint operator behavior, and asyncrefresh()success/partial-failure paths, without changing source files.Rough estimate:
- Timeline: 1–2 days
- Quote: $250–$400
I’d follow the existing
sdk/python/tests/test_verification.pystyle, use precomputed Ed25519/did:key fixtures, mockaiohttp.ClientSession.getwith async-compatible mocks, and verify both the specific new test cases and the coverage target with:uv run pytest sdk/python/tests/test_verification.py uv run pytest --cov=agentfield sdk/python/tests One quick clarification before starting:
- For the
refresh_partial_failurecase, should the expected behavior be “best-effort cache updates from successful endpoints + returnFalse,” even if the failing endpoint is encountered before later endpoints?Happy to take this on and submit a clean PR.
go for it!
Thanks for picking this up, @tradego579! :tada:
Here's what to expect:
- We'll check in after 7 days if we haven't heard an update
- After 14 days, we'll send a second reminder
- After 21 days without activity, we'll unassign to let others contribute
Tips for success:
- Drop a comment when you start working on it
- Share any blockers - we're here to help!
- Link your PR with
Fixes #398in the description
Happy coding! :rocket:
Hey @tradego579! :wave:
Just a friendly reminder that you're assigned to this issue. It's been about a week since assignment.
How's it going? We'd love to hear:
- Any progress updates?
- Running into any blockers we can help with?
- Need more time? (Totally fine!)
A quick comment helps us know you're still interested. If your plans have changed, no worries at all - just let us know and we can find another contributor.
Thanks for contributing to AgentField! :rocket:
Hi @tradego579,
Just checking in again! It's been 14 days since we last heard from you on this issue.
Quick options:
- :speech_balloon: Drop a comment with a progress update
- :link: Link a draft PR if you've started working on it
- :wave: Let us know if you'd like to be unassigned (no judgment!)
If we don't hear back in 7 days, we'll unassign this issue to give other contributors a chance to help.
Thanks for understanding!
Hi @tradego579,
It's been 21 days since the last update on this issue. To keep the project moving, we've unassigned this issue so other contributors can pick it up.
No worries at all! Life happens, and we totally understand. If you'd like to continue working on this, just comment here and we'll reassign it to you.
This issue is now available for anyone who'd like to contribute. Check out our contribution guidelines if you're interested!
Thanks for your interest in AgentField! :heart:
Hi, I would like to work on this test-only task. I plan to add the requested LocalVerifier coverage for did:key resolution, constraint evaluation, and refresh success/partial-failure paths, then report focused test and coverage results. I will use AI assistance transparently, review every change myself, and keep the diff within the issue scope.