Skip to content

test: add error-path coverage for key format operations#106

Merged
atoomic merged 1 commit into
cpan-authors:mainfrom
atoomic:koan.atoomic/test-key-format-errors
Mar 16, 2026
Merged

test: add error-path coverage for key format operations#106
atoomic merged 1 commit into
cpan-authors:mainfrom
atoomic:koan.atoomic/test-key-format-errors

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Mar 15, 2026

What

Add 6 tests covering previously untested error paths in key format operations.

Why

The new_public_key(), new_private_key(), and get_private_key_string() functions
have error paths (unrecognized format, bad passphrase, unsupported cipher, garbage PEM)
that had zero test coverage. These are the kind of paths that silently break during
refactoring.

Testing

All 287 tests pass (281 existing + 6 new). Tested on macOS with OpenSSL 3.x.

New tests

  • new_public_key("garbage") → croak "unrecognized key format"
  • get_private_key_string(undef, 'aes-128-cbc') → croak "Passphrase is required"
  • get_private_key_string('secret', 'no-such-cipher') → croak "Unsupported cipher"
  • new_private_key($encrypted_key, 'wrong-passphrase') → croak
  • new_private_key("garbage") → croak
  • new_private_key("-----BEGIN RSA PRIVATE KEY-----\ngarbage\n...") → croak

Quality Report

Changes: 1 file changed, 25 insertions(+), 1 deletion(-)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Cover 6 previously untested error paths:
- new_public_key() with unrecognized key format
- get_private_key_string() with cipher but no passphrase
- get_private_key_string() with unsupported cipher name
- new_private_key() with wrong passphrase
- new_private_key() with garbage input
- new_private_key() with truncated PEM
@atoomic atoomic marked this pull request as ready for review March 16, 2026 02:44
@atoomic atoomic merged commit 9be6d02 into cpan-authors:main Mar 16, 2026
55 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.

2 participants