Skip to content

fix directory constructor option broken since async refactor - #82

Draft
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/fix-directory-option
Draft

fix directory constructor option broken since async refactor#82
toddr-bot wants to merge 1 commit into
mainfrom
koan.toddr.bot/fix-directory-option

Conversation

@toddr-bot

@toddr-bot toddr-bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What

Restores the directory constructor option for Net::ACME2->new(), which has been silently broken since the async refactor.

Why

The original code used $self->{'_directory'} as both the user-supplied cache seed and the fetched directory cache. During the async refactor, _get_directory() was changed to use a new _directory_cache field, but _directory was never connected to it — making the documented directory option a no-op.

How

_get_directory() now checks for a pre-supplied $self->{'_directory'} before falling back to the HTTP fetch. The hash is consumed (delete) on first use, and the nonce URL is extracted and set just as it would be from a server response.

Also removes incorrect directory usage from t/Net-ACME2-get-certificate-guard.t (was passing a string path instead of a hashref, masked by the bug).

Testing

  • New test file t/Net-ACME2-directory-cache.t with 3 subtests:
    • Pre-cached directory enables account creation without fetching
    • Missing newNonce in directory hash throws
    • Directory is consumed once and cached for subsequent requests
  • Full suite passes: 382 tests across 24 files

Quality Report

Changes: 4 files changed, 141 insertions(+), 14 deletions(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan

The 'directory' option to new() was documented and stored in
$self->{'_directory'} but _get_directory() always fetched from
the server using the separate '_directory_cache' field. Before
the async refactor, both used '_directory' and the option worked.

Now _get_directory() checks for a pre-supplied directory hash
before falling back to the HTTP fetch. The hash is consumed
(deleted) on first use so it doesn't leak into the cache path.

Also removes incorrect 'directory' usage from the certificate
guard test (was passing a string instead of a hashref, masked
by the bug).
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