Annotation of embedaddon/php/ext/phar/tests/tar/phar_setsignaturealgo2.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Phar::setSupportedSignatures() with hash, tar-based
        !             3: --SKIPIF--
        !             4: <?php if (!extension_loaded("phar")) die("skip"); ?>
        !             5: <?php if (!extension_loaded("hash")) die("skip extension hash required");
        !             6: $arr = Phar::getSupportedSignatures();
        !             7: if (!in_array("OpenSSL", $arr)) die("skip openssl support required");
        !             8: if (!in_array('SHA-256', $arr)) die("skip hash extension loaded shared"); ?>
        !             9: --INI--
        !            10: phar.require_hash=0
        !            11: phar.readonly=0
        !            12: --FILE--
        !            13: <?php
        !            14: $fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
        !            15: $p = new Phar($fname);
        !            16: $p['file1.txt'] = 'hi';
        !            17: var_dump($p->getSignature());
        !            18: $p->setSignatureAlgorithm(Phar::MD5);
        !            19: var_dump($p->getSignature());
        !            20: $p->setSignatureAlgorithm(Phar::SHA1);
        !            21: var_dump($p->getSignature());
        !            22: try {
        !            23: $p->setSignatureAlgorithm(Phar::SHA256);
        !            24: var_dump($p->getSignature());
        !            25: } catch (Exception $e) {
        !            26: echo $e->getMessage();
        !            27: }
        !            28: try {
        !            29: $p->setSignatureAlgorithm(Phar::SHA512);
        !            30: var_dump($p->getSignature());
        !            31: } catch (Exception $e) {
        !            32: echo $e->getMessage();
        !            33: }
        !            34: try {
        !            35: $private = openssl_get_privatekey(file_get_contents(dirname(dirname(__FILE__)) . '/files/private.pem'));
        !            36: $pkey = '';
        !            37: openssl_pkey_export($private, $pkey);
        !            38: $p->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
        !            39: var_dump($p->getSignature());
        !            40: } catch (Exception $e) {
        !            41: echo $e->getMessage();
        !            42: }
        !            43: ?>
        !            44: ===DONE===
        !            45: --CLEAN--
        !            46: <?php
        !            47: unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
        !            48: ?>
        !            49: --EXPECTF--
        !            50: array(2) {
        !            51:   ["hash"]=>
        !            52:   string(%d) "%s"
        !            53:   ["hash_type"]=>
        !            54:   string(5) "SHA-1"
        !            55: }
        !            56: array(2) {
        !            57:   ["hash"]=>
        !            58:   string(%d) "%s"
        !            59:   ["hash_type"]=>
        !            60:   string(3) "MD5"
        !            61: }
        !            62: array(2) {
        !            63:   ["hash"]=>
        !            64:   string(%d) "%s"
        !            65:   ["hash_type"]=>
        !            66:   string(5) "SHA-1"
        !            67: }
        !            68: array(2) {
        !            69:   ["hash"]=>
        !            70:   string(%d) "%s"
        !            71:   ["hash_type"]=>
        !            72:   string(7) "SHA-256"
        !            73: }
        !            74: array(2) {
        !            75:   ["hash"]=>
        !            76:   string(%d) "%s"
        !            77:   ["hash_type"]=>
        !            78:   string(7) "SHA-512"
        !            79: }
        !            80: array(2) {
        !            81:   ["hash"]=>
        !            82:   string(%d) "%s"
        !            83:   ["hash_type"]=>
        !            84:   string(7) "OpenSSL"
        !            85: }
        !            86: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>