test: add error-path and edge-case coverage#95
Conversation
|
review test hang with Enter PEM pass phrase: perl -I blib/lib/ -I blib/arch/ t/error.t |
PR Review — test: add error-path and edge-case coverageGood error-path test coverage initiative, but one critical blocker: the encrypted-key-without-passphrase test (line 50) hangs because OpenSSL prompts on the terminal for a passphrase, as timlegge reported. Additionally, the 512-bit key test will fail on OpenSSL 3.x with default security levels and should use a SKIP block. Cross-key verify assertions should wrap in eval for portability across OpenSSL versions. Fix the hang, add SKIP blocks for platform-dependent tests, and this is merge-ready. 🔴 Blocking1. Test hangs: OpenSSL prompts for passphrase on terminal ( Two options to fix:
Option 1 is quick but tests a subtly different code path (empty passphrase vs no passphrase). A proper fix would be in 🟡 Important1. 512-bit key generation may fail on modern OpenSSL ( my $small_rsa = eval { Crypt::OpenSSL::RSA->generate_key(512) };
SKIP: {
skip "OpenSSL rejected 512-bit key", 2 if $@;
ok($small_rsa, "512-bit key generation succeeds");
is($small_rsa->size() * 8, 512, "512-bit key has correct size");
}2. Cross-key verify may croak instead of returning false ( ok(!eval { $rsa2->verify("message to sign", $sig) }, "signature from key1 does not verify with key2");This ensures the test passes whether verify returns false or croaks. 🟢 Suggestions1. Missing 'use warnings' ( Checklist
SummaryGood error-path test coverage initiative, but one critical blocker: the encrypted-key-without-passphrase test (line 50) hangs because OpenSSL prompts on the terminal for a passphrase, as timlegge reported. Additionally, the 512-bit key test will fail on OpenSSL 3.x with default security levels and should use a SKIP block. Cross-key verify assertions should wrap in eval for portability across OpenSSL versions. Fix the hang, add SKIP blocks for platform-dependent tests, and this is merge-ready. Automated review by Kōan |
|
Good catch — this is a real bug. The hang happens because Quick test-side fix: pass an empty string Proper fix (separate PR): add a no-op password callback in static int no_passphrase_cb(char *buf, int size, int rwflag, void *u) {
(void)buf; (void)size; (void)rwflag; (void)u;
return 0;
}Then use |
|
Thanks @Koan-Bot fix the test as you suggested |
Rebase: test: add error-path and edge-case coverageBranch Diff: 1 file changed, 158 insertions(+) Review feedback was analyzed and applied. Actions
Automated by Kōan |
8c9b5c5 to
773ab68
Compare
|
The CI failed with a 6h timeout, can be unrelated and seems architecture issue. ( or not... same issue at first glance on the new run ) |
|
Looks like bullseye is failing and becoming non responsive on the 3rd unit test |
773ab68 to
95414b1
Compare
Rebase: test: add error-path and edge-case coverageBranch Diff: 1 file changed, 158 insertions(+) Review feedback was analyzed and applied. Actions
CICI still running (timed out waiting). Automated by Kōan |
|
@Koan-Bot rebase try to understand the failure from CI on bullseye it reach timeout and run forever https://github.com/cpan-authors/Crypt-OpenSSL-RSA/actions/runs/23235531481/job/67538449941?pr=95 |
95414b1 to
4c28a53
Compare
Rebase: test: add error-path and edge-case coverageBranch Diff: 1 file changed, 158 insertions(+) Review feedback was analyzed and applied. Actions
CICI still failing after 2 fix attempts. Last failure logsAutomated by Kōan |
|
@Koan-Bot please review: This test fails on openssl 1.1.1d by hanging on the following test: Even exponent should failCrypt::OpenSSL::RSA->generate_key(2048, 2); There is some information about old versions of openssl if it is given incorrect parameters but 1.1.1d is not supposed to have the issue It hangs on: if (!RSA_generate_key_ex(rsa, SvIV(bitsSV), e, NULL)) |
|
@Koan-Bot rebase |
RSA_generate_key_ex() on OpenSSL 1.1.x enters an infinite loop when given an even exponent (e.g. 2). Add pre-validation in generate_key() to croak immediately if the exponent is < 3 or even, preventing the hang on all OpenSSL versions. Fixes the CI timeout on Debian Bullseye (OpenSSL 1.1.1d) reported in PR cpan-authors#95. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root Cause AnalysisThe hang on Debian Bullseye (OpenSSL 1.1.1d) is caused by Fix: PR #151 adds a pre-validation check in No changes needed to |
Rebase: test: add error-path and edge-case coverageBranch Diff: 1 file changed, 158 insertions(+) Review feedback was analyzed and applied. Actions
CICI will be checked asynchronously. Automated by Kōan |
4c28a53 to
2c17ba2
Compare
|
@Koan-Bot rebase from main |
Add t/error.t with 34 tests covering previously untested error paths: - Malformed PEM key loading (garbage, empty, undef, corrupted body) - Unrecognized public key format detection - Wrong/missing passphrase on encrypted keys - Public key operation restrictions (sign, decrypt, private_encrypt, check_key) - Corrupted/truncated/wrong-length ciphertext handling - Plaintext size boundary for OAEP padding (max and overflow) - Cross-key signature verification (sign with key1, verify with key2) - Empty message signing and verification - Truncated and extended signature rejection - Custom exponent key generation (3, 17, even exponent rejection) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rebase: test: add error-path and edge-case coverageBranch Diff: 1 file changed, 158 insertions(+) Review feedback was analyzed and applied. Actions
CICI will be checked asynchronously. Automated by Kōan |
2c17ba2 to
1474085
Compare
What
Add
t/error.twith 34 tests covering error paths and edge cases that had zero test coverage.Why
The existing test suite validates happy paths well but lacks coverage for error conditions — malformed inputs, corrupted ciphertext, cross-key operations, and size boundary violations. A crypto library needs strong error-path testing to catch regressions.
How
New test file organized by error category:
Testing
All 315 tests pass (278 existing + 34 new + 3 author tests).
🤖 Generated with Claude Code
Quality Report
Changes: 1 file changed, 155 insertions(+)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline