summaryrefslogtreecommitdiffstats
path: root/inc/simplesamlphp/vendor/simplesamlphp/xmlseclibs/tests/xml-sign.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'inc/simplesamlphp/vendor/simplesamlphp/xmlseclibs/tests/xml-sign.phpt')
-rwxr-xr-xinc/simplesamlphp/vendor/simplesamlphp/xmlseclibs/tests/xml-sign.phpt43
1 files changed, 43 insertions, 0 deletions
diff --git a/inc/simplesamlphp/vendor/simplesamlphp/xmlseclibs/tests/xml-sign.phpt b/inc/simplesamlphp/vendor/simplesamlphp/xmlseclibs/tests/xml-sign.phpt
new file mode 100755
index 0000000..47f4d57
--- /dev/null
+++ b/inc/simplesamlphp/vendor/simplesamlphp/xmlseclibs/tests/xml-sign.phpt
@@ -0,0 +1,43 @@
+--TEST--
+Basic Signature
+--FILE--
+<?php
+require(dirname(__FILE__) . '/../xmlseclibs.php');
+
+if (file_exists(dirname(__FILE__) . '/sign-basic-test.xml')) {
+ unlink(dirname(__FILE__) . '/sign-basic-test.xml');
+}
+
+$doc = new DOMDocument();
+$doc->load(dirname(__FILE__) . '/basic-doc.xml');
+
+$objDSig = new XMLSecurityDSig();
+
+$objDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N);
+
+$objDSig->addReference($doc, XMLSecurityDSig::SHA1, array('http://www.w3.org/2000/09/xmldsig#enveloped-signature'));
+
+$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type'=>'private'));
+/* load private key */
+$objKey->loadKey(dirname(__FILE__) . '/privkey.pem', TRUE);
+
+/* if key has Passphrase, set it using $objKey->passphrase = <passphrase> " */
+
+
+$objDSig->sign($objKey);
+
+/* Add associated public key */
+$objDSig->add509Cert(file_get_contents(dirname(__FILE__) . '/mycert.pem'));
+
+$objDSig->appendSignature($doc->documentElement);
+$doc->save(dirname(__FILE__) . '/sign-basic-test.xml');
+
+$sign_output = file_get_contents(dirname(__FILE__) . '/sign-basic-test.xml');
+$sign_output_def = file_get_contents(dirname(__FILE__) . '/sign-basic-test.res');
+if ($sign_output != $sign_output_def) {
+ echo "NOT THE SAME";
+}
+echo "DONE";
+?>
+--EXPECTF--
+DONE