Skip to content

test(caddy): cover server_idx registration scenarios#2530

Merged
henderkes merged 1 commit into
php:refactor/phpserverfrom
nicolas-grekas:server-idx-tests
Jul 20, 2026
Merged

test(caddy): cover server_idx registration scenarios#2530
henderkes merged 1 commit into
php:refactor/phpserverfrom
nicolas-grekas:server-idx-tests

Conversation

@nicolas-grekas

Copy link
Copy Markdown
Contributor

Follow-up to #2499, targeting refactor/phpserver. Test-only.

During review, an explicit server_idx colliding with an auto-assigned one could make one handler serve another's files; the fix (deferring registration to a single pass keyed by index) had no regression test, and nothing in caddy/ exercised server_idx at all. This adds unit coverage for:

  • Caddyfile parsing assigns incrementing indexes
  • modules with the same server_idx share one server instance, registered only once
  • modules without server_idx each get their own server
  • a module with an explicit server_idx equal to an already registered one joins the existing server instead of re-registering it (the double-registration scenario possible with JSON configs POSTed to the admin API)

These are pure Go unit tests on registerModules(); an end-to-end admin API config-swap test would be a natural follow-up but needs the PHP runtime, so it is not included here.

Covers the sharing and registration logic around server_idx:

- Caddyfile parsing assigns incrementing indexes
- modules with the same server_idx share one server instance and
  register it only once
- modules without server_idx each get their own server
- an explicit server_idx equal to an already registered one joins the
  existing server instead of re-registering (the double-registration
  scenario possible with JSON configs POSTed to the admin API)
@henderkes
henderkes merged commit 3c799c5 into php:refactor/phpserver Jul 20, 2026
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.

3 participants