Add tests for sha256-rsa-MGF1#1
Open
kaibernhard wants to merge 4 commits intoStadtLandNetz:masterfrom
Open
Conversation
valid_saml_sha256_rsa_mgf1.xml has been signed with:
xmlsectool --sign \
--inFile unsigned_saml_response.xml \
--outFile valid_saml_sha256_rsa_mgf1.xml \
--keyFile idp_private_key.pem \
--certificate idp_certificate.pem \
--signatureAlgorithm http://www.w3.org/2007/05/xmldsig-more#sha256-rsa-MGF1
cjbarth
reviewed
Sep 11, 2025
test/signature-unit-tests.spec.ts
Outdated
| const xml = signWith(signatureAlgorithm) | ||
| const sig = loadSignature(xml) | ||
| const res = sig.checkSignature(xml); | ||
| expect(res, "expected all signatures to be valid, but some reported invalid").to.be.true; |
There was a problem hiding this comment.
The error should vary with the test, thus, I'd expect ${signatureAlgorithm} to be in the expect().
cjbarth
reviewed
Sep 11, 2025
| expect(nodes.length).to.equal(1) | ||
| const node = nodes[0]; | ||
| isDomNode.assertIsElementNode(node); | ||
| const targetElement = node as Element; |
There was a problem hiding this comment.
Just curious, did you do this because the type narrowing on isDomNode.assertIsElementNode(node) isn't working?
Author
There was a problem hiding this comment.
isDomNode.assertIsElementNode on the result of xpath.select failed with Error: Value is not of type ELEMENT_NODE, but I realized that I can use select1 and simplify that code. Thanks!
cjbarth
reviewed
Sep 11, 2025
test/signature-unit-tests.spec.ts
Outdated
|
|
||
| const sig = loadSignature(manipulatedXml) | ||
| const res = sig.checkSignature(manipulatedXml); | ||
| expect(res, "expected all signatures to be invalid, but some reported valid").to.be.false; |
There was a problem hiding this comment.
See my previous note about errors varying with the test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add unit tests for signing and verifying with all signature algorithms and saml response tests with sha256-rsa-MGF1.
valid_saml_sha256_rsa_mgf1.xml has been signed with: