Skip to content

test: cover REST auth permission checks and queue retry backoff (1.8.18) - #67

Merged
Atroci merged 1 commit into
mainfrom
agent-v1-8-18-test-coverage
Aug 16, 2026
Merged

test: cover REST auth permission checks and queue retry backoff (1.8.18)#67
Atroci merged 1 commit into
mainfrom
agent-v1-8-18-test-coverage

Conversation

@Atroci

@Atroci Atroci commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds tests/unit/RestAuthPermissionsTest.php (36 tests): the actual permission_callback methods on Tracking_Controller and its attribution-token/security traits — missing/malformed/expired/wrong-host/wrong-blog client tokens on batch_events_permissions_check, attribution_token_sign_permissions_check, attribution_token_verify_permissions_check; the hash_equals()-gated CRM token on lifecycle_permissions_check; disabled-provider/missing-secret/valid-signature on webhook_permissions_check; plus a full create_attribution_token()/verify_attribution_token() sign-verify round trip.
  • Adds tests/unit/QueueRetryTest.php (6 tests): Queue::get_backoff_seconds() retry-interval growth and 1-hour cap (invoked via reflection — it's private) and a redact_retry_payload() no-identity-present edge case.
  • Extends tests/bootstrap.php with 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 an ArrayAccess-capable WP_REST_Request) — additive only, existing BoundarySecurityTest/ChannelResolverTest still pass unchanged.
  • Bumps clicutcl.php to 1.8.18 (Version header + CLICUTCL_VERSION), changelog.txt + readme.txt changelog entries, and updates docs/guides/CODE-QUALITY.md §4 to reflect the narrowed gap. readme.txt Stable tag intentionally 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 $wpdb and are not reachable from this unit suite (no live WP+DB harness), same constraint the existing BoundarySecurityTest.php already 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 via podman 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 violations
  • php -l on all 3 changed/added PHP files under both 8.1 and 8.3
  • CI (GitHub Actions PHPUnit matrix 8.1/8.2/8.3 + PHPCS) — will confirm on push

🤖 Generated with Claude Code

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>
@Atroci
Atroci merged commit d62a184 into main Aug 16, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant