Skip to content

Commit

Permalink
Expand sign timestamp test for different signature digest methods
Browse files Browse the repository at this point in the history
  • Loading branch information
colm29 authored and mvantellingen committed Aug 15, 2021
1 parent b44d732 commit 15d0f52
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/test_wsse_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@


@skip_if_no_xmlsec
def test_sign_timestamp_if_present():
@pytest.mark.parametrize("digest_method,expected_digest_href", DIGEST_METHODS_TESTDATA)
@pytest.mark.parametrize(
"signature_method,expected_signature_href", SIGNATURE_METHODS_TESTDATA
)
def test_sign_timestamp_if_present(
digest_method,
signature_method,
expected_digest_href,
expected_signature_href,
):
envelope = load_xml(
"""
<soap-env:Envelope
Expand Down Expand Up @@ -63,8 +72,23 @@ def test_sign_timestamp_if_present():
"""
)

signature.sign_envelope(envelope, KEY_FILE, KEY_FILE)
signature.sign_envelope(
envelope,
KEY_FILE,
KEY_FILE,
None,
signature_method=getattr(xmlsec_installed.Transform, signature_method),
digest_method=getattr(xmlsec_installed.Transform, digest_method),
)
signature.verify_envelope(envelope, KEY_FILE)
digests = envelope.xpath("//ds:DigestMethod", namespaces={"ds": ns.DS})
assert len(digests)
for digest in digests:
assert digest.get("Algorithm") == expected_digest_href
signatures = envelope.xpath("//ds:SignatureMethod", namespaces={"ds": ns.DS})
assert len(signatures)
for sig in signatures:
assert sig.get("Algorithm") == expected_signature_href


@skip_if_no_xmlsec
Expand Down

0 comments on commit 15d0f52

Please sign in to comment.