From a6e5964ebf565b0d5bc362e3f3dc9680323fd0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C5=8Dan?= Date: Fri, 13 Mar 2026 12:06:16 -0600 Subject: [PATCH] test: fix ok(defined $@) always-true assertion in padding.t ok(defined $@) always passes because $@ is always defined (empty string on success). Replace with ok($@) to actually validate that the operation croaked. Also skip the "invalid signing" test for pkcs1_oaep: OAEP only affects encryption padding, signing uses its own padding and does not croak when OAEP is set. The defined $@ bug was hiding this behavior mismatch. Co-Authored-By: Claude Opus 4.6 --- t/padding.t | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/padding.t b/t/padding.t index c04e059..04d7857 100644 --- a/t/padding.t +++ b/t/padding.t @@ -68,7 +68,7 @@ Crypt::OpenSSL::RSA->import_random_seed(); my $rsa = Crypt::OpenSSL::RSA->generate_key(2048); is( $rsa->size() * 8, 2048, "2048-bit key has correct size" ); -ok( $rsa->check_key() ); +ok( $rsa->check_key(), "2048-bit key passes check_key()" ); my $private_key_string = $rsa->get_private_key_string(); my $public_key_string = $rsa->get_public_key_string(); @@ -142,11 +142,17 @@ foreach my $padding (keys %padding_methods) { # Invalid signing methods if ((!$sign) && $pad) { + SKIP: { + # OAEP only affects encryption; signing uses its own padding + # and does not croak when OAEP is set + skip "Signing with $padding padding does not croak", 1 + if $encrypt; eval { $rsa->$method; $rsa->sign($plaintext); }; - ok(defined $@, "Padding $padding is invalid for signing"); + ok($@, "Padding $padding is invalid for signing with $hash"); + } } # Valid encryption methods with padding