@@ -10,11 +10,10 @@ const signatureAlgorithms = [
1010 "http://www.w3.org/2000/09/xmldsig#rsa-sha1" ,
1111 "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" ,
1212 "http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1" ,
13- "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512"
14- ]
13+ "http://www.w3.org/2001/04/xmldsig-more#rsa-sha512" ,
14+ ] ;
1515
1616describe ( "Signature unit tests" , function ( ) {
17-
1817 describe ( "sign and verify" , function ( ) {
1918 signatureAlgorithms . forEach ( ( signatureAlgorithm ) => {
2019 function signWith ( signatureAlgorithm : string ) : string {
@@ -31,7 +30,7 @@ describe("Signature unit tests", function () {
3130 sig . canonicalizationAlgorithm = "http://www.w3.org/2001/10/xml-exc-c14n#" ;
3231 sig . signatureAlgorithm = signatureAlgorithm ;
3332 sig . computeSignature ( xml ) ;
34- return sig . getSignedXml ( )
33+ return sig . getSignedXml ( ) ;
3534 }
3635
3736 function loadSignature ( xml : string ) : SignedXml {
@@ -48,27 +47,30 @@ describe("Signature unit tests", function () {
4847 }
4948
5049 it ( `should verify signed xml with ${ signatureAlgorithm } ` , function ( ) {
51- const xml = signWith ( signatureAlgorithm )
52- const sig = loadSignature ( xml )
50+ const xml = signWith ( signatureAlgorithm ) ;
51+ const sig = loadSignature ( xml ) ;
5352 const res = sig . checkSignature ( xml ) ;
54- expect ( res , `expected all signatures with ${ signatureAlgorithm } to be valid, but some reported invalid` ) . to . be . true ;
53+ expect (
54+ res ,
55+ `expected all signatures with ${ signatureAlgorithm } to be valid, but some reported invalid` ,
56+ ) . to . be . true ;
5557 } ) ;
5658
5759 it ( `should fail verification of signed xml with ${ signatureAlgorithm } after manipulation` , function ( ) {
58- const xml = signWith ( signatureAlgorithm )
60+ const xml = signWith ( signatureAlgorithm ) ;
5961 const doc = new xmldom . DOMParser ( ) . parseFromString ( xml ) ;
60- const node = xpath . select1 (
61- "//*[local-name(.)='x']" ,
62- doc ,
63- ) ;
62+ const node = xpath . select1 ( "//*[local-name(.)='x']" , doc ) ;
6463 isDomNode . assertIsElementNode ( node ) ;
6564 const targetElement = node as Element ;
66- targetElement . setAttribute ( "attr" , "manipulatedValue" )
67- const manipulatedXml = new xmldom . XMLSerializer ( ) . serializeToString ( doc )
65+ targetElement . setAttribute ( "attr" , "manipulatedValue" ) ;
66+ const manipulatedXml = new xmldom . XMLSerializer ( ) . serializeToString ( doc ) ;
6867
69- const sig = loadSignature ( manipulatedXml )
68+ const sig = loadSignature ( manipulatedXml ) ;
7069 const res = sig . checkSignature ( manipulatedXml ) ;
71- expect ( res , `expected all signatures with ${ signatureAlgorithm } to be invalid, but some reported valid` ) . to . be . false ;
70+ expect (
71+ res ,
72+ `expected all signatures with ${ signatureAlgorithm } to be invalid, but some reported valid` ,
73+ ) . to . be . false ;
7274 } ) ;
7375 } ) ;
7476 } ) ;
0 commit comments