test(adminapi): expand coverage for trust marks, stats, and subordinate flows#73
test(adminapi): expand coverage for trust marks, stats, and subordinate flows#73hmffa wants to merge 22 commits into
Conversation
- Implement tests for entity trust marks including listing, creating, updating, patching, and deleting trust marks. - Add tests for the stats API covering summary, top endpoints, top breakdowns, time series, and export functionalities. - Introduce tests for subordinate events with options for creating events and handling store errors.
…ding - Replaced the doJSONRequest helper function with newJSONRequest to streamline request creation. - Removed redundant response decoding functions and integrated JSON unmarshalling directly in test cases. - Updated all test cases to utilize the new request and response handling methods. - Ensured proper error handling for JSON decoding in tests.
- Updated tests in trustmark_types_test.go to replace assertStatus with assertErrorResponse for better error handling. - Added JSON unmarshalling of response body in DELETE tests to verify empty issuers list. - Ensured consistent error response checks across all handler tests for improved clarity and maintainability.
…es and constraints
…te effective date in mock KMS
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Go | May 16, 2026 5:34p.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
…MarkSubject handlers
…solation test for additional claims
…ty configuration middleware
6d37b8b to
177c92e
Compare
…id requests in subordinate endpoints
…subordinate history and trust mark subject creation
…rustMarkSubjectHandlers
There was a problem hiding this comment.
Pull request overview
This PR expands and refactors the api/adminapi test suite to cover additional Admin API handler surfaces (trust marks, stats, subordinate flows) while standardizing request execution and error assertions across tests.
Changes:
- Added new test suites for stats endpoints, entity trust mark CRUD/persistence, authority hints CRUD, cache invalidation middleware, and subordinate event helpers.
- Expanded subordinate-related tests (statement/metadata/policies/constraints/additional-claims) to cover more edge cases and stricter assertions.
- Refactored existing tests to use shared request helpers (
doRequest), consistent status helpers (requireStatus), and a newassertErrorResponsecontract check.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| api/adminapi/users_test.go | Refactors user handler tests to use doRequest/newJSONRequest and consistent status checks. |
| api/adminapi/trustmark_types_test.go | Expands trust mark type/issuer/owner handler coverage and standardizes error assertions. |
| api/adminapi/trustmark_owners_issuers_test.go | Updates trust mark owner/issuer tests to use consistent helper patterns and stronger response validation. |
| api/adminapi/test_helpers_test.go | Adds assertErrorResponse helper for validating standardized error bodies. |
| api/adminapi/subordinates_statement_test.go | Adds statement tests for critical extensions and lifetime default/error fallback behavior. |
| api/adminapi/subordinates_metadata_test.go | Tightens not-found expectations and strengthens “untouched data” assertions. |
| api/adminapi/subordinates_metadata_policies_test.go | Tightens not-found expectations; adds /metadata-policy-crit and operator-filtering tests. |
| api/adminapi/subordinates_lifetime_test.go | Switches to requireStatus usage for clearer lifetime test assertions. |
| api/adminapi/subordinates_keys_test.go | Tightens not-found expectations for subordinate JWKS-related endpoints. |
| api/adminapi/subordinates_events_test.go | Adds tests for subordinate event option helpers and RecordEvent behavior. |
| api/adminapi/subordinates_constraints_test.go | Adds POST-copy-from-general tests and constraint edge case coverage. |
| api/adminapi/subordinates_base_test.go | Standardizes error assertions and strengthens subordinate history response parsing. |
| api/adminapi/subordinates_additional_claims_test.go | Adds duplicate/not-found coverage for additional claims POST/PUT flows. |
| api/adminapi/stats_test.go | Adds comprehensive stats API tests (summary, top breakdowns, time series, latency, daily, export). |
| api/adminapi/router_test.go | Parallelizes table-driven tests safely (loop var capture fix). |
| api/adminapi/keys_test.go | Makes pending-change timestamp relative; normalizes HTTP status constants usage. |
| api/adminapi/entity_trustmarks_test.go | Adds entity trust mark CRUD tests + real-storage persistence tests for self-issuance specs. |
| api/adminapi/entity_configuration_test.go | Adds real-store persistence tests for object-valued additional claims; improves response validation. |
| api/adminapi/cache_middlewares_test.go | Adds tests for cache invalidation middleware behaviors (entity config + subordinate statements). |
| api/adminapi/authority_hints_test.go | Adds CRUD tests for authority hints, including cache invalidation behavior on success/failure. |
| api/adminapi/auth_test.go | Normalizes HTTP status constant usage (net/http). |
| api/adminapi/actor_test.go | Updates actor middleware test app setup to accept *testing.T and use t.Helper(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Updated `requireStatus` and `assertStatus` functions to accept response body as an argument for better error reporting. - Modified various test cases across multiple files to utilize the updated assertion functions, ensuring that the response body is included in failure messages for easier debugging. - This change enhances the clarity of test failures by providing context on the response body when status codes do not match expected values.
Summary
This PR expands admin API test coverage across additional handler surfaces and edge cases, with a focus on trust mark management, stats endpoints, subordinate behavior, and storage-backed persistence flows.
Highlights: