test: cover REST auth permission checks and queue retry backoff (1.8.18) - #67
Merged
Conversation
CODE-QUALITY.md named REST auth edge cases and queue retry semantics as the highest-risk gaps in runtime test coverage (2 test files for 80 source files). Adds RestAuthPermissionsTest for the permission_callback boundary on Tracking_Controller (client/CRM/webhook token validation, attribution-token sign/verify round trip) and QueueRetryTest for the queue's pure backoff-interval logic; DB-backed queue paths remain untestable without a live $wpdb harness, noted in the PR/changelog. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/unit/RestAuthPermissionsTest.php(36 tests): the actualpermission_callbackmethods onTracking_Controllerand its attribution-token/security traits — missing/malformed/expired/wrong-host/wrong-blog client tokens onbatch_events_permissions_check,attribution_token_sign_permissions_check,attribution_token_verify_permissions_check; thehash_equals()-gated CRM token onlifecycle_permissions_check; disabled-provider/missing-secret/valid-signature onwebhook_permissions_check; plus a fullcreate_attribution_token()/verify_attribution_token()sign-verify round trip.tests/unit/QueueRetryTest.php(6 tests):Queue::get_backoff_seconds()retry-interval growth and 1-hour cap (invoked via reflection — it'sprivate) and aredact_retry_payload()no-identity-present edge case.tests/bootstrap.phpwith the additional WP stubs these needed (current_user_can,wp_verify_nonce,get_option,wp_cache_get/set,wp_salt,home_url,wp_parse_url,wp_json_encode,WP_REST_Controller, and anArrayAccess-capableWP_REST_Request) — additive only, existingBoundarySecurityTest/ChannelResolverTeststill pass unchanged.clicutcl.phpto 1.8.18 (Versionheader +CLICUTCL_VERSION),changelog.txt+readme.txtchangelog entries, and updatesdocs/guides/CODE-QUALITY.md§4 to reflect the narrowed gap.readme.txtStable tagintentionally left at 1.8.13 per the 3-version buffer policy.Known gap, called out rather than papered over:
class-queue.php's DB-backed paths —process(),update_row_failure(),mark_row_failed(),requeue_failed(),get_stats()— all read/write via$wpdband are not reachable from this unit suite (no live WP+DB harness), same constraint the existingBoundarySecurityTest.phpalready operates under. Only the pure backoff calculation was testable.Test plan
composer install && vendor/bin/phpunit— 60/60 passing (18 pre-existing + 42 new) on PHP 8.1 and PHP 8.3 viapodman run php:8.3-cli/php:8.1-cli(no local PHP interpreter in the dispatch sandbox, so verified this way instead of trusting an unexecuted diff)composer run phpcs(full repo,phpcs.xml.dist) — clean, no new violationsphp -lon all 3 changed/added PHP files under both 8.1 and 8.3🤖 Generated with Claude Code