Skip to content

Commit 95fd5b9

Browse files
authored
Merge pull request #5 from timlegge/bug-fix
Fix a couple of bugs in tests
2 parents a0d296c + 9934d81 commit 95fd5b9

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

t/06-test-encryption-methods.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ my @data_methods = qw/aes128-cbc aes192-cbc aes256-cbc tripledes-cbc aes128-g
1818
my @oaep_mgf_algs = qw/mgf1sha1 mgf1sha224 mgf1sha256 mgf1sha384 mgf1sha512/;
1919

2020
my $xmlsec = get_xmlsec_features();
21-
my $lax_key_search = $xmlsec->{lax_key_search} ? '--lax_key_search': '';
21+
my $lax_key_search = $xmlsec->{lax_key_search} ? '--lax-key-search': '';
2222

2323
foreach my $km (@key_methods) {
2424
foreach my $dm (@data_methods) {

t/08-support-oaepparams.t

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
use strict;
22
use warnings;
3-
use Test::More tests => 5;
3+
use Test::More tests => 7;
44
use XML::Enc;
5+
use Test::Lib;
6+
use Test::XML::Enc;
57
use MIME::Base64 qw/decode_base64/;
6-
use File::Which;
78
use File::Slurper qw/read_text/;
89

10+
my $xmlsec = get_xmlsec_features();
11+
my $lax_key_search = $xmlsec->{lax_key_search} ? '--lax-key-search' : '';
12+
913
my $xml = <<'ENDXML';
1014
<?xml version="1.0" encoding="UTF-8"?>
1115
<PaymentInfo xmlns="http://example.org/paymentv2">
@@ -75,6 +79,19 @@ ok($encrypted =~ /CipherData/, "Successfully Encrypted with XML::Enc using OAEPp
7579

7680
ok($encrypter->decrypt($encrypted) =~ /<bar>123<\/bar>/, "Successfully Decrypted with XML::Enc using OAEPparams");
7781

82+
SKIP: {
83+
skip "xmlsec1 not installed", 2 unless $xmlsec->{installed};
84+
85+
ok( open ENCRYPTED, '>', 'encrypted.xml' );
86+
print ENCRYPTED $encrypted;
87+
close ENCRYPTED;
88+
89+
# Decrypt using xmlsec
90+
my $encrypt_response = `xmlsec1 decrypt $lax_key_search --privkey-pem t/sign-private.pem encrypted.xml 2>&1`;
91+
is($? >> 8, 0, "xmlsec1 decrypted oaep_params encrypted XML");
92+
unlink 'encrypted.xml';
93+
}
94+
7895
$decrypter = XML::Enc->new(
7996
{
8097
key => 't/sign-private.pem',

t/lib/Test/XML/Enc/Util.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ sub get_xmlsec_features {
5151
minor => $minor,
5252
patch => $patch,
5353
ripemd160 => ($major >= 1 and $minor >= 3) ? 1 : 0,
54-
aes_gcm => ($major >= 1 and $minor >= 2 and $patch >= 27) ? 1 : 0,
54+
aes_gcm => ($major <= 1 and $minor <= 2 and $patch <= 27) ? 0 : 1,
5555
lax_key_search => ($major >= 1 and $minor >= 3) ? 1 : 0,
5656
);
5757
return \%xmlsec;

0 commit comments

Comments
 (0)