diff options
Diffstat (limited to 'ext/openssl/tests')
7 files changed, 80 insertions, 79 deletions
diff --git a/ext/openssl/tests/openssl_x509_check_private_key_basic.phpt b/ext/openssl/tests/openssl_x509_check_private_key_basic.phpt index df18322453..b4842aae18 100644 --- a/ext/openssl/tests/openssl_x509_check_private_key_basic.phpt +++ b/ext/openssl/tests/openssl_x509_check_private_key_basic.phpt @@ -5,11 +5,11 @@ openssl_x509_check_private_key() tests --FILE-- <?php $fp = fopen(dirname(__FILE__) . "/cert.crt","r"); -$a = fread($fp,8192); +$a = fread($fp, 8192); fclose($fp); $fp = fopen(dirname(__FILE__) . "/private_rsa_1024.key","r"); -$b = fread($fp,8192); +$b = fread($fp, 8192); fclose($fp); $cert = "file://" . dirname(__FILE__) . "/cert.crt"; diff --git a/ext/openssl/tests/openssl_x509_export_basic.phpt b/ext/openssl/tests/openssl_x509_export_basic.phpt index e0988c095a..cfe1cad524 100644 --- a/ext/openssl/tests/openssl_x509_export_basic.phpt +++ b/ext/openssl/tests/openssl_x509_export_basic.phpt @@ -1,49 +1,28 @@ --TEST-- -openssl_x509_export() and openssl_x509_export_to_file() tests +openssl_x509_export() tests --SKIPIF-- <?php if (!extension_loaded("openssl")) print "skip"; ?> --FILE-- <?php -$fp = fopen(dirname(__FILE__) . "/cert.crt","r"); -$a = fread($fp,8192); -fclose($fp); +$cert_file = dirname(__FILE__) . "/cert.crt"; -$b = "file://" . dirname(__FILE__) . "/cert.crt"; +$a = file_get_contents($cert_file); +$b = "file://" . $cert_file; $c = "invalid cert"; $d = openssl_x509_read($a); $e = array(); -var_dump(openssl_x509_export($a, $output)); // read cert as a binary string -var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string -var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails -var_dump(openssl_x509_export($d, $output4)); // read cert from a resource -var_dump(openssl_x509_export($e, $output5)); // read an array, fails - -$outfilename = tempnam("/tmp", "ssl"); -if ($outfilename === false) { - die("failed to get a temporary filename!"); -} - -echo "---\n"; - -var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string -var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string -var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails -var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource -var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails -echo "---\n"; - -var_dump($exists = file_exists($outfilename)); -if ($exists) { - @unlink($outfilename); -} -echo "---\n"; +var_dump(openssl_x509_export($a, $output)); // read cert as a binary string +var_dump(openssl_x509_export($b, $output2)); // read cert from a filename string +var_dump(openssl_x509_export($c, $output3)); // read an invalid cert, fails +var_dump(openssl_x509_export($d, $output4)); // read cert from a resource +var_dump(openssl_x509_export($e, $output5)); // read an array, fails var_dump(strcmp($output, $a)); var_dump(strcmp($output, $output2)); var_dump(strcmp($output, $output3)); -var_dump(strcmp($output, $output4)); // different -var_dump(strcmp($output, $output5)); // different +var_dump(strcmp($output, $output4)); // different +var_dump(strcmp($output, $output5)); // different ?> --EXPECTF-- bool(true) @@ -55,19 +34,6 @@ bool(true) Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d bool(false) ---- -bool(true) -bool(true) - -Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d -bool(false) -bool(true) - -Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d -bool(false) ---- -bool(true) ---- int(0) int(0) int(%d) diff --git a/ext/openssl/tests/openssl_x509_export_to_file_basic.phpt b/ext/openssl/tests/openssl_x509_export_to_file_basic.phpt new file mode 100644 index 0000000000..68ba93230d --- /dev/null +++ b/ext/openssl/tests/openssl_x509_export_to_file_basic.phpt @@ -0,0 +1,42 @@ +--TEST-- +openssl_x509_export_to_file() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +$outfilename = dirname(__FILE__) . "/openssl_x509_export_to_file__outfilename.tmp"; +$cert_file = dirname(__FILE__) . "/cert.crt"; + +$a = file_get_contents($cert_file); +$b = "file://" . $cert_file; +$c = "invalid cert"; +$d = openssl_x509_read($a); +$e = array(); + +var_dump(openssl_x509_export_to_file($a, $outfilename)); // read cert as a binary string +var_dump(openssl_x509_export_to_file($b, $outfilename)); // read cert from a filename string +var_dump(openssl_x509_export_to_file($c, $outfilename)); // read an invalid cert, fails +var_dump(openssl_x509_export_to_file($d, $outfilename)); // read cert from a resource +var_dump(openssl_x509_export_to_file($e, $outfilename)); // read an array, fails +echo "---\n"; +var_dump($exists = file_exists($outfilename)); +?> +--CLEAN-- +<?php +$outfilename = dirname(__FILE__) . "/openssl_x509_export_to_file__outfilename.tmp"; +if (file_exists($outfilename)) { + unlink($outfilename); +} +?> +--EXPECTF-- +bool(true) +bool(true) + +Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d +bool(false) +bool(true) + +Warning: openssl_x509_export_to_file(): cannot get cert from parameter 1 in %s on line %d +bool(false) +--- +bool(true) diff --git a/ext/openssl/tests/openssl_x509_fingerprint_basic.phpt b/ext/openssl/tests/openssl_x509_fingerprint_basic.phpt index 6cd464a894..766b158fab 100644 --- a/ext/openssl/tests/openssl_x509_fingerprint_basic.phpt +++ b/ext/openssl/tests/openssl_x509_fingerprint_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -Testing openssl_x509_fingerprint() +openssl_x509_fingerprint() tests --SKIPIF-- <?php if (!extension_loaded("openssl")) die("skip"); diff --git a/ext/openssl/tests/openssl_x509_free_basic.phpt b/ext/openssl/tests/openssl_x509_free_basic.phpt new file mode 100644 index 0000000000..d8b586e8b4 --- /dev/null +++ b/ext/openssl/tests/openssl_x509_free_basic.phpt @@ -0,0 +1,16 @@ +--TEST-- +openssl_x509_free() tests +--SKIPIF-- +<?php if (!extension_loaded("openssl")) print "skip"; ?> +--FILE-- +<?php +var_dump($res = openssl_x509_read("file://" . dirname(__FILE__) . "/cert.crt")); +openssl_x509_free($res); +var_dump($res); +openssl_x509_free(false); +?> +--EXPECTF-- +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (Unknown) + +Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d diff --git a/ext/openssl/tests/openssl_x509_parse_basic.phpt b/ext/openssl/tests/openssl_x509_parse_basic.phpt index 325b2ee4b9..00e32c3b60 100644 --- a/ext/openssl/tests/openssl_x509_parse_basic.phpt +++ b/ext/openssl/tests/openssl_x509_parse_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -openssl_x509_parse() basic test +openssl_x509_parse() tests --SKIPIF-- <?php if (!extension_loaded("openssl")) print "skip"; if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0"); diff --git a/ext/openssl/tests/openssl_x509_read_basic.phpt b/ext/openssl/tests/openssl_x509_read_basic.phpt index cc36e989c6..5f530534ff 100644 --- a/ext/openssl/tests/openssl_x509_read_basic.phpt +++ b/ext/openssl/tests/openssl_x509_read_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -openssl_x509_read() tests with testing openssl_x509_free as well +openssl_x509_read() tests --SKIPIF-- <?php if (!extension_loaded("openssl")) print "skip"; ?> --FILE-- @@ -14,47 +14,24 @@ $d = openssl_x509_read($a); $e = array(); $f = array($b); -var_dump($res = openssl_x509_read($a)); // read cert as a string -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($b)); // read cert as a filename string -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($c)); // read an invalid cert, fails -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($d)); // read cert from a resource -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($e)); // read an array -openssl_x509_free($res); -var_dump($res); -var_dump($res = openssl_x509_read($f)); // read an array with the filename -openssl_x509_free($res); -var_dump($res); +var_dump(openssl_x509_read($a)); // read cert as a string +var_dump(openssl_x509_read($b)); // read cert as a filename string +var_dump(openssl_x509_read($c)); // read an invalid cert, fails +var_dump(openssl_x509_read($d)); // read cert from a resource +var_dump(openssl_x509_read($e)); // read an array +var_dump(openssl_x509_read($f)); // read an array with the filename ?> --EXPECTF-- resource(%d) of type (OpenSSL X.509) -resource(%d) of type (Unknown) resource(%d) of type (OpenSSL X.509) -resource(%d) of type (Unknown) Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d bool(false) - -Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d -bool(false) resource(%d) of type (OpenSSL X.509) -resource(%d) of type (Unknown) Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d bool(false) -Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d -bool(false) - Warning: openssl_x509_read(): supplied parameter cannot be coerced into an X509 certificate! in %s on line %d bool(false) -Warning: openssl_x509_free() expects parameter 1 to be resource, boolean given in %s on line %d -bool(false) |