@@ -365,6 +365,31 @@ describe('saml 2.0', function () {
365365 } ) ;
366366
367367 it ( 'should place signature with prefix where specified' , function ( ) {
368+ var options = {
369+ cert : fs . readFileSync ( __dirname + '/test-auth0.pem' ) ,
370+ key : fs . readFileSync ( __dirname + '/test-auth0.key' ) ,
371+ xpathToNodeBeforeSignature : "//*[local-name(.)='Conditions']" ,
372+ signatureNamespacePrefix : 'anyprefix' ,
373+ attributes : {
374+ 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress' :
'[email protected] ' , 375+ 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name' : 'Foo Bar' ,
376+ 'http://example.org/claims/testemptyarray' : [ ] , // should dont include empty arrays
377+ 'http://example.org/claims/testaccent' : 'fóo' , // should supports accents
378+ 'http://undefinedattribute/ws/com.com' : undefined
379+ }
380+ } ;
381+
382+ var signedAssertion = saml . create ( options ) ;
383+
384+ var isValid = utils . isValidSignature ( signedAssertion , options . cert ) ;
385+ assert . equal ( true , isValid ) ;
386+
387+ var doc = new xmldom . DOMParser ( ) . parseFromString ( signedAssertion ) ;
388+ var signature = doc . documentElement . getElementsByTagName ( options . signatureNamespacePrefix + ':Signature' ) ;
389+ assert . equal ( 'saml:Conditions' , signature [ 0 ] . previousSibling . nodeName ) ;
390+ } ) ;
391+
392+ it ( 'should place signature with prefix where specified (backwards compat)' , function ( ) {
368393 var options = {
369394 cert : fs . readFileSync ( __dirname + '/test-auth0.pem' ) ,
370395 key : fs . readFileSync ( __dirname + '/test-auth0.key' ) ,
@@ -385,7 +410,7 @@ describe('saml 2.0', function () {
385410 assert . equal ( true , isValid ) ;
386411
387412 var doc = new xmldom . DOMParser ( ) . parseFromString ( signedAssertion ) ;
388- var signature = doc . documentElement . getElementsByTagName ( options . prefix + ':Signature' ) ;
413+ var signature = doc . documentElement . getElementsByTagName ( options . signatureNamespacePrefix + ':Signature' ) ;
389414 assert . equal ( 'saml:Conditions' , signature [ 0 ] . previousSibling . nodeName ) ;
390415 } ) ;
391416
@@ -394,7 +419,7 @@ describe('saml 2.0', function () {
394419 cert : fs . readFileSync ( __dirname + '/test-auth0.pem' ) ,
395420 key : fs . readFileSync ( __dirname + '/test-auth0.key' ) ,
396421 xpathToNodeBeforeSignature : "//*[local-name(.)='Conditions']" ,
397- prefix : 123 ,
422+ signatureNamespacePrefix : 123 ,
398423 attributes : {
399424 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress' :
'[email protected] ' , 400425 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name' : 'Foo Bar' ,
0 commit comments