Subject: | wsseBasicAuth throws "Unknown encoding" when used with UTP11_PDIGEST |
The arguments to "encode" are backwards. It attempts to encode the
string "utf8" instead of the password. The patch is simple. This comes
against XML-Compiles-WWW-0.13. I'm using Encode version 2.12, in case
that's interesting. In the test I wrote, I chose a particular WSDL to
work with but there might be a more elegant way to make it.
Run the attached "properDigest.t" against the current version and you
should get something like
Unknown encoding 'bar' at lib/XML/Compile/WSS.pm line 68
RT wants me to tell you about perl -V but I doubt you care that much:
[mcdave@epgy-dsk-999 XML-Compile-WSS-0.13]$ perl -V | head -4
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=linux, osvers=2.6.18-128.1.10.el5,
archname=x86_64-linux-thread-multi
uname='linux ls20-bc2-13.build.redhat.com 2.6.18-128.1.10.el5 #1 smp
wed apr 29 13:53:08 edt 2009 x86_64 x86_64 x86_64 gnulinux '
Subject: | digestEncoding.patch |
diff --git a/lib/XML/Compile/WSS.pm b/lib/XML/Compile/WSS.pm
index f7ef5a4..0250c9a 100644
--- a/lib/XML/Compile/WSS.pm
+++ b/lib/XML/Compile/WSS.pm
@@ -65,7 +65,7 @@ sub wsseBasicAuth($$;$)
my $pwtype = $schema->findName('wsse:Password');
my $untype = $schema->findName('wsse:UsernameToken');
- $password = sha1_base64 encode($password, 'utf8')
+ $password = sha1_base64 encode('utf8', $password)
if $type && $type eq UTP11_PDIGEST;
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
diff --git a/t/properDigestEncoding.t b/t/properDigestEncoding.t
new file mode 100644
index 0000000..45a10dc
--- /dev/null
+++ b/t/properDigestEncoding.t
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use lib 'lib';
+use Test::More tests => 2;
+
+use XML::Compile::WSDL11 ;
+use XML::Compile::SOAP::WSS ;
+use XML::Compile::WSS::Util qw/:wss11 :utp11/ ;
+
+## How to get a relative path right??
+my $wsdl = XML::Compile::WSDL11->new( 'examples/wsse/example.wsdl' ) ;
+ok( my $wss = XML::Compile::SOAP::WSS->new( version => 1.1, schema => $wsdl ), 'Created a WSS object' ) ;
+ok( my $sec = $wss->wsseBasicAuth( 'foo', 'bar', UTP11_PDIGEST ), '#PasswordDigest returns something sensible' ) ;