]> granicus.if.org Git - php/commitdiff
Rename and clean up OpenSSL tests
authorJakub Zelenka <bukka@php.net>
Wed, 3 Feb 2016 16:20:27 +0000 (16:20 +0000)
committerJakub Zelenka <bukka@php.net>
Wed, 3 Feb 2016 16:20:27 +0000 (16:20 +0000)
32 files changed:
ext/openssl/tests/002.phpt [deleted file]
ext/openssl/tests/012.phpt [deleted file]
ext/openssl/tests/026.phpt [deleted file]
ext/openssl/tests/cert.csr [moved from ext/openssl/tests/005_crt.txt with 100% similarity]
ext/openssl/tests/openssl_csr_export_bacis.phpt [moved from ext/openssl/tests/022.phpt with 99% similarity]
ext/openssl/tests/openssl_csr_get_subject_basic.phpt [moved from ext/openssl/tests/005.phpt with 90% similarity]
ext/openssl/tests/openssl_csr_new_basic.phpt [moved from ext/openssl/tests/004.phpt with 84% similarity]
ext/openssl/tests/openssl_csr_sign_basic.phpt [moved from ext/openssl/tests/021.phpt with 100% similarity]
ext/openssl/tests/openssl_decrypt_basic.phpt [moved from ext/openssl/tests/011.phpt with 95% similarity]
ext/openssl/tests/openssl_open_basic.phpt [moved from ext/openssl/tests/013.phpt with 100% similarity]
ext/openssl/tests/openssl_pbkdf2_basic.phpt [moved from ext/openssl/tests/openssl_pbkdf2.phpt with 100% similarity]
ext/openssl/tests/openssl_peer_fingerprint_basic.phpt [moved from ext/openssl/tests/openssl_peer_fingerprint.phpt with 100% similarity]
ext/openssl/tests/openssl_pkcs7_decrypt_basic.phpt [moved from ext/openssl/tests/024.phpt with 100% similarity]
ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt [moved from ext/openssl/tests/003.phpt with 98% similarity]
ext/openssl/tests/openssl_pkcs7_encrypt_basic.phpt [moved from ext/openssl/tests/023.phpt with 100% similarity]
ext/openssl/tests/openssl_pkcs7_sign_basic.phpt [moved from ext/openssl/tests/025.phpt with 98% similarity]
ext/openssl/tests/openssl_pkey_export_basic.phpt [moved from ext/openssl/tests/027.phpt with 100% similarity]
ext/openssl/tests/openssl_pkey_get_details_basic.phpt [moved from ext/openssl/tests/028.phpt with 100% similarity]
ext/openssl/tests/openssl_pkey_new_basic.phpt [moved from ext/openssl/tests/006.phpt with 91% similarity]
ext/openssl/tests/openssl_private_decrypt_basic.phpt [moved from ext/openssl/tests/017.phpt with 100% similarity]
ext/openssl/tests/openssl_private_encrypt_basic.phpt [moved from ext/openssl/tests/014.phpt with 93% similarity]
ext/openssl/tests/openssl_public_decrypt_basic.phpt [moved from ext/openssl/tests/016.phpt with 100% similarity]
ext/openssl/tests/openssl_public_encrypt_basic.phpt [moved from ext/openssl/tests/015.phpt with 93% similarity]
ext/openssl/tests/openssl_random_pseudo_bytes_basic.phpt [moved from ext/openssl/tests/openssl_random_pseudo_bytes.phpt with 100% similarity]
ext/openssl/tests/openssl_seal_basic.phpt [new file with mode: 0644]
ext/openssl/tests/openssl_sign_basic.phpt [moved from ext/openssl/tests/018.phpt with 100% similarity]
ext/openssl/tests/openssl_verify_basic.phpt [moved from ext/openssl/tests/019.phpt with 100% similarity]
ext/openssl/tests/openssl_x509_check_private_key_basic.phpt [moved from ext/openssl/tests/009.phpt with 100% similarity]
ext/openssl/tests/openssl_x509_export_basic.phpt [moved from ext/openssl/tests/008.phpt with 94% similarity]
ext/openssl/tests/openssl_x509_fingerprint_basic.phpt [moved from ext/openssl/tests/openssl_x509_fingerprint.phpt with 100% similarity]
ext/openssl/tests/openssl_x509_parse_v9_basic.phpt [moved from ext/openssl/tests/openssl_x509_parse_basic_v9.phpt with 100% similarity]
ext/openssl/tests/openssl_x509_read_basic.phpt [moved from ext/openssl/tests/007.phpt with 96% similarity]

diff --git a/ext/openssl/tests/002.phpt b/ext/openssl/tests/002.phpt
deleted file mode 100644 (file)
index dd4f04a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-openssl_seal() tests
---SKIPIF--
-<?php if (!extension_loaded("openssl")) print "skip"; ?>
---FILE--
-<?php
-
-$a = 1;
-$b = array(1);
-$c = array(1);
-$d = array(1);
-
-var_dump(openssl_seal($a, $b, $c, $d));
-var_dump(openssl_seal($a, $a, $a, array()));
-var_dump(openssl_seal($c, $c, $c, 1));
-var_dump(openssl_seal($b, $b, $b, ""));
-
-echo "Done\n";
-?>
---EXPECTF--    
-Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d
-bool(false)
-
-Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
-bool(false)
-
-Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
-NULL
-
-Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
-NULL
-Done
diff --git a/ext/openssl/tests/012.phpt b/ext/openssl/tests/012.phpt
deleted file mode 100644 (file)
index dbd03ac..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-openssl_seal() error tests
---SKIPIF--
-<?php if (!extension_loaded("openssl")) print "skip"; ?>
---FILE--
-<?php
-$data = "openssl_open() test";
-$pub_key = "file://" . dirname(__FILE__) . "/public.key";
-$wrong = "wrong";
-
-openssl_seal($data, $sealed, $ekeys, array($pub_key));                  // no output
-openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key));        // no output
-openssl_seal($data, $sealed, $ekeys, array($pub_key, $wrong));
-openssl_seal($data, $sealed, $ekeys, $pub_key);
-openssl_seal($data, $sealed, $ekeys, array());
-openssl_seal($data, $sealed, $ekeys, array($wrong));
-?>
---EXPECTF--
-
-Warning: openssl_seal(): not a public key (2th member of pubkeys) in %s on line %d
-
-Warning: openssl_seal() expects parameter 4 to be array, string given in %s on line %d
-
-Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
-
-Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d
-
diff --git a/ext/openssl/tests/026.phpt b/ext/openssl/tests/026.phpt
deleted file mode 100644 (file)
index 38d626d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-Options type checks
---SKIPIF--
-<?php if (!extension_loaded("openssl")) print "skip"; ?>
---FILE--
-<?php
-$x = openssl_pkey_new();
-$csr = openssl_csr_new(["countryName" => "DE"], $x, ["x509_extensions" => 0xDEADBEEF]);
-?>
-DONE
---EXPECT--
-DONE
similarity index 99%
rename from ext/openssl/tests/022.phpt
rename to ext/openssl/tests/openssl_csr_export_bacis.phpt
index 1fa84d9f4244777549fe048f9631ff18d90be1d6..d3f8842e7170c38d20d5c73ce8cd7b288e1be1ff 100644 (file)
@@ -14,7 +14,7 @@ $dn = array(
        "localityName" => "Porto Alegre",
        "commonName" => "Henrique do N. Angelo",
        "emailAddress" => "hnangelo@php.net"
-       );
+);
 
 $args = array(
        "digest_alg" => "sha1",
@@ -22,7 +22,7 @@ $args = array(
        "private_key_type" => OPENSSL_KEYTYPE_DSA,
        "encrypt_key" => true,
        "config" => $config,
-       );
+);
 
 $privkey = openssl_pkey_new($config_arg);
 $csr = openssl_csr_new($dn, $privkey, $args);
similarity index 90%
rename from ext/openssl/tests/005.phpt
rename to ext/openssl/tests/openssl_csr_get_subject_basic.phpt
index f7fa2015610b301979efebc99af805b87d5e783a..895ed3695de98029f7b6b36e7efcf11444c0a88a 100644 (file)
@@ -8,7 +8,7 @@ if (!function_exists("utf8_decode")) die("skip");
 --FILE--
 <?php
 
-$csr = file_get_contents(dirname(__FILE__) . '/005_crt.txt');
+$csr = file_get_contents(dirname(__FILE__) . '/cert.csr');
 if ($out = openssl_csr_get_subject($csr, 1)) {
        var_dump($out);
 }
similarity index 84%
rename from ext/openssl/tests/004.phpt
rename to ext/openssl/tests/openssl_csr_new_basic.phpt
index 508ccabc8538c480e09e7d0dbacce528ceb837e5..a3a4746b395476b706ac1d6b8719730f9aa38c0c 100644 (file)
@@ -11,11 +11,15 @@ var_dump(openssl_csr_new(1,$a,1,1));
 $a = array();
 var_dump(openssl_csr_new(array(), $a, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'), array()));
 
-//this leaks
+// this leaks
 $a = array(1,2);
 $b = array(1,2);
 var_dump(openssl_csr_new($a, $b, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf')));
 
+// options type check
+$x = openssl_pkey_new();
+var_dump(openssl_csr_new(["countryName" => "DE"], $x, ["x509_extensions" => 0xDEADBEEF]));
+
 
 echo "Done\n";
 ?>
@@ -31,4 +35,5 @@ Warning: openssl_csr_new(): key array must be of the form array(0 => key, 1 => p
 Warning: openssl_csr_new(): add1_attr_by_txt challengePassword_min -> 4 (failed; check error queue and value of string_mask OpenSSL option if illegal characters are reported) in %s on line %d
 bool(false)
 resource(%d) of type (OpenSSL X.509 CSR)
+resource(%d) of type (OpenSSL X.509 CSR)
 Done
similarity index 95%
rename from ext/openssl/tests/011.phpt
rename to ext/openssl/tests/openssl_decrypt_basic.phpt
index 118e952a5107ec0e8d629e76d3c5d8caea0abde3..1c29767cc597013185e54daf24f59a63761266af 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-openssl_encrypt() and openssl_decrypt() tests
+openssl_decrypt() tests dependent on openssl_encrypt
 --SKIPIF--
 <?php if (!extension_loaded("openssl")) print "skip"; ?>
 --FILE--
similarity index 98%
rename from ext/openssl/tests/003.phpt
rename to ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt
index 92c8c85b1381fd86bf42862946fee56af497d577..0fdb9856ebcbefca85aa52f026b76f7231235b18 100644 (file)
@@ -6,7 +6,7 @@ openssl_pkcs7_decrypt() and invalid parameters
 <?php
 
 function myErrorHandler($errno, $errstr, $errfile, $errline) {
-var_dump($errstr);
+       var_dump($errstr);
 } 
 set_error_handler("myErrorHandler"); 
 
similarity index 98%
rename from ext/openssl/tests/025.phpt
rename to ext/openssl/tests/openssl_pkcs7_sign_basic.phpt
index 46c3926fe8c36885376433f8a31723197d06f8a3..ac8edf19a950e074e126b8f912a607f0cea685f5 100644 (file)
@@ -6,8 +6,9 @@ openssl_pkcs7_sign() tests
 <?php
 $infile = dirname(__FILE__) . "/cert.crt";
 $outfile = tempnam("/tmp", "ssl");
-if ($outfile === false)
+if ($outfile === false) {
        die("failed to get a temporary filename!");
+}
 
 $privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
 $single_cert = "file://" . dirname(__FILE__) . "/cert.crt";
similarity index 91%
rename from ext/openssl/tests/006.phpt
rename to ext/openssl/tests/openssl_pkey_new_basic.phpt
index d6e41e496b32e7decc795b445f312084d6dfdf93..3c434978d2eef41764870c110eddb8274400196f 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-openssl_pkey_new() with an empty sub-array arg generates a malformed resource
+openssl_pkey_new() tests
 --SKIPIF--
 <?php if (!extension_loaded("openssl")) print "skip"; ?>
 --FILE--
similarity index 93%
rename from ext/openssl/tests/014.phpt
rename to ext/openssl/tests/openssl_private_encrypt_basic.phpt
index 72ac154058792af44cefa15775c988f17aaa9235..a2a51521587df29d937f522ce1e361baec23544e 100644 (file)
@@ -8,10 +8,11 @@ $data = "Testing openssl_private_encrypt()";
 $privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
 $pubkey = "file://" . dirname(__FILE__) . "/public.key";
 $wrong = "wrong";
+
 class test {
-        function __toString() {
-                return "test";
-        }
+       function __toString() {
+               return "test";
+       }
 }
 $obj = new test;
 
similarity index 93%
rename from ext/openssl/tests/015.phpt
rename to ext/openssl/tests/openssl_public_encrypt_basic.phpt
index 7caa66fa3b3c8092469219bbe5f2c3be9ca5b982..a3c4c57539683695e26a276e60a48031a3e3ca28 100644 (file)
@@ -8,10 +8,11 @@ $data = "Testing openssl_public_encrypt()";
 $privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
 $pubkey = "file://" . dirname(__FILE__) . "/public.key";
 $wrong = "wrong";
+
 class test {
-        function __toString() {
-                return "test";
-        }
+       function __toString() {
+               return "test";
+       }
 }
 $obj = new test;
 
diff --git a/ext/openssl/tests/openssl_seal_basic.phpt b/ext/openssl/tests/openssl_seal_basic.phpt
new file mode 100644 (file)
index 0000000..4f1958a
--- /dev/null
@@ -0,0 +1,58 @@
+--TEST--
+openssl_seal() tests
+--SKIPIF--
+<?php if (!extension_loaded("openssl")) print "skip"; ?>
+--FILE--
+<?php
+// simple tests
+$a = 1;
+$b = array(1);
+$c = array(1);
+$d = array(1);
+
+var_dump(openssl_seal($a, $b, $c, $d));
+var_dump(openssl_seal($a, $a, $a, array()));
+var_dump(openssl_seal($c, $c, $c, 1));
+var_dump(openssl_seal($b, $b, $b, ""));
+
+// tests with cert
+$data = "openssl_open() test";
+$pub_key = "file://" . dirname(__FILE__) . "/public.key";
+$wrong = "wrong";
+
+var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key)));                  // no output
+var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key)));        // no output
+var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $wrong)));
+var_dump(openssl_seal($data, $sealed, $ekeys, $pub_key));
+var_dump(openssl_seal($data, $sealed, $ekeys, array()));
+var_dump(openssl_seal($data, $sealed, $ekeys, array($wrong)));
+
+echo "Done\n";
+?>
+--EXPECTF--    
+Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d
+bool(false)
+
+Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
+bool(false)
+
+Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
+NULL
+
+Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
+NULL
+int(19)
+int(19)
+
+Warning: openssl_seal(): not a public key (2th member of pubkeys) in %s on line %d
+bool(false)
+
+Warning: openssl_seal() expects parameter 4 to be array, string given in %s on line %d
+NULL
+
+Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
+bool(false)
+
+Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d
+bool(false)
+Done
similarity index 94%
rename from ext/openssl/tests/008.phpt
rename to ext/openssl/tests/openssl_x509_export_basic.phpt
index 8963864ee51d88e27170310704665ae52dce29f4..e0988c095a33bc1313e645b427a154928e283708 100644 (file)
@@ -20,8 +20,9 @@ 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!");
+if ($outfilename === false) {
+       die("failed to get a temporary filename!");
+}
 
 echo "---\n";
 
@@ -34,7 +35,7 @@ echo "---\n";
 
 var_dump($exists = file_exists($outfilename));
 if ($exists) {
-        @unlink($outfilename);
+       @unlink($outfilename);
 }
 echo "---\n";
 
similarity index 96%
rename from ext/openssl/tests/007.phpt
rename to ext/openssl/tests/openssl_x509_read_basic.phpt
index 0a74bd341115c2ba954be2b9694e04db3d668e4a..cc36e989c6ccf5f2a611caf4af457dc08f0ae7b4 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-openssl_x509_read() and openssl_x509_free() tests
+openssl_x509_read() tests with testing openssl_x509_free as well
 --SKIPIF--
 <?php if (!extension_loaded("openssl")) print "skip"; ?>
 --FILE--