|
1 | 1 | #!/usr/bin/env python
|
2 | 2 |
|
3 | 3 | import base64
|
| 4 | +from saml2.xmldsig import SIG_RSA_SHA256 |
4 | 5 | from saml2 import sigver
|
5 | 6 | from saml2 import extension_elements_to_elements
|
6 | 7 | from saml2 import class_name
|
@@ -510,9 +511,36 @@ def test_xmlsec_err():
|
510 | 511 | assert False
|
511 | 512 |
|
512 | 513 |
|
| 514 | +def test_sha256_signing(): |
| 515 | + conf = config.SPConfig() |
| 516 | + conf.load_file("server_conf") |
| 517 | + md = MetadataStore([saml, samlp], None, conf) |
| 518 | + md.load("local", full_path("idp_example.xml")) |
| 519 | + |
| 520 | + conf.metadata = md |
| 521 | + conf.only_use_keys_in_metadata = False |
| 522 | + sec = sigver.security_context(conf) |
| 523 | + |
| 524 | + assertion = factory( |
| 525 | + saml.Assertion, version="2.0", id="11111", |
| 526 | + issue_instant="2009-10-30T13:20:28Z", |
| 527 | + signature=sigver.pre_signature_part("11111", sec.my_cert, 1, |
| 528 | + sign_alg=SIG_RSA_SHA256), |
| 529 | + attribute_statement=do_attribute_statement( |
| 530 | + {("", "", "surName"): ("Foo", ""), |
| 531 | + ("", "", "givenName"): ("Bar", ""), }) |
| 532 | + ) |
| 533 | + |
| 534 | + s = sec.sign_statement(assertion, class_name(assertion), |
| 535 | + key_file=full_path("test.key"), |
| 536 | + node_id=assertion.id) |
| 537 | + assert s |
| 538 | + |
| 539 | + |
| 540 | + |
513 | 541 | if __name__ == "__main__":
|
514 |
| - t = TestSecurity() |
515 |
| - t.setup_class() |
516 |
| - t.test_sign_assertion() |
| 542 | + # t = TestSecurity() |
| 543 | + # t.setup_class() |
| 544 | + # t.test_sign_assertion() |
517 | 545 |
|
518 |
| - #test_xmlsec_err() |
| 546 | + test_sha256_signing() |
0 commit comments