Skip to content

Commit 1f3906c

Browse files
committed
Rename and clean up OpenSSL tests
1 parent e0332ea commit 1f3906c

32 files changed

+85
-89
lines changed

ext/openssl/tests/002.phpt

Lines changed: 0 additions & 32 deletions
This file was deleted.

ext/openssl/tests/012.phpt

Lines changed: 0 additions & 27 deletions
This file was deleted.

ext/openssl/tests/026.phpt

Lines changed: 0 additions & 12 deletions
This file was deleted.
File renamed without changes.

ext/openssl/tests/022.phpt renamed to ext/openssl/tests/openssl_csr_export_bacis.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ $dn = array(
1414
"localityName" => "Porto Alegre",
1515
"commonName" => "Henrique do N. Angelo",
1616
"emailAddress" => "hnangelo@php.net"
17-
);
17+
);
1818

1919
$args = array(
2020
"digest_alg" => "sha1",
2121
"private_key_bits" => 2048,
2222
"private_key_type" => OPENSSL_KEYTYPE_DSA,
2323
"encrypt_key" => true,
2424
"config" => $config,
25-
);
25+
);
2626

2727
$privkey = openssl_pkey_new($config_arg);
2828
$csr = openssl_csr_new($dn, $privkey, $args);

ext/openssl/tests/005.phpt renamed to ext/openssl/tests/openssl_csr_get_subject_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (!function_exists("utf8_decode")) die("skip");
88
--FILE--
99
<?php
1010

11-
$csr = file_get_contents(dirname(__FILE__) . '/005_crt.txt');
11+
$csr = file_get_contents(dirname(__FILE__) . '/cert.csr');
1212
if ($out = openssl_csr_get_subject($csr, 1)) {
1313
var_dump($out);
1414
}

ext/openssl/tests/004.phpt renamed to ext/openssl/tests/openssl_csr_new_basic.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ var_dump(openssl_csr_new(1,$a,1,1));
1111
$a = array();
1212
var_dump(openssl_csr_new(array(), $a, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf'), array()));
1313

14-
//this leaks
14+
// this leaks
1515
$a = array(1,2);
1616
$b = array(1,2);
1717
var_dump(openssl_csr_new($a, $b, array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf')));
1818

19+
// options type check
20+
$x = openssl_pkey_new();
21+
var_dump(openssl_csr_new(["countryName" => "DE"], $x, ["x509_extensions" => 0xDEADBEEF]));
22+
1923

2024
echo "Done\n";
2125
?>
@@ -31,4 +35,5 @@ Warning: openssl_csr_new(): key array must be of the form array(0 => key, 1 => p
3135
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
3236
bool(false)
3337
resource(%d) of type (OpenSSL X.509 CSR)
38+
resource(%d) of type (OpenSSL X.509 CSR)
3439
Done

ext/openssl/tests/011.phpt renamed to ext/openssl/tests/openssl_decrypt_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
openssl_encrypt() and openssl_decrypt() tests
2+
openssl_decrypt() tests dependent on openssl_encrypt
33
--SKIPIF--
44
<?php if (!extension_loaded("openssl")) print "skip"; ?>
55
--FILE--

ext/openssl/tests/003.phpt renamed to ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ openssl_pkcs7_decrypt() and invalid parameters
66
<?php
77

88
function myErrorHandler($errno, $errstr, $errfile, $errline) {
9-
var_dump($errstr);
9+
var_dump($errstr);
1010
}
1111
set_error_handler("myErrorHandler");
1212

ext/openssl/tests/025.phpt renamed to ext/openssl/tests/openssl_pkcs7_sign_basic.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ openssl_pkcs7_sign() tests
66
<?php
77
$infile = dirname(__FILE__) . "/cert.crt";
88
$outfile = tempnam("/tmp", "ssl");
9-
if ($outfile === false)
9+
if ($outfile === false) {
1010
die("failed to get a temporary filename!");
11+
}
1112

1213
$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
1314
$single_cert = "file://" . dirname(__FILE__) . "/cert.crt";

ext/openssl/tests/006.phpt renamed to ext/openssl/tests/openssl_pkey_new_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
openssl_pkey_new() with an empty sub-array arg generates a malformed resource
2+
openssl_pkey_new() tests
33
--SKIPIF--
44
<?php if (!extension_loaded("openssl")) print "skip"; ?>
55
--FILE--

ext/openssl/tests/014.phpt renamed to ext/openssl/tests/openssl_private_encrypt_basic.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ $data = "Testing openssl_private_encrypt()";
88
$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
99
$pubkey = "file://" . dirname(__FILE__) . "/public.key";
1010
$wrong = "wrong";
11+
1112
class test {
12-
function __toString() {
13-
return "test";
14-
}
13+
function __toString() {
14+
return "test";
15+
}
1516
}
1617
$obj = new test;
1718

ext/openssl/tests/015.phpt renamed to ext/openssl/tests/openssl_public_encrypt_basic.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ $data = "Testing openssl_public_encrypt()";
88
$privkey = "file://" . dirname(__FILE__) . "/private_rsa_1024.key";
99
$pubkey = "file://" . dirname(__FILE__) . "/public.key";
1010
$wrong = "wrong";
11+
1112
class test {
12-
function __toString() {
13-
return "test";
14-
}
13+
function __toString() {
14+
return "test";
15+
}
1516
}
1617
$obj = new test;
1718

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
openssl_seal() tests
3+
--SKIPIF--
4+
<?php if (!extension_loaded("openssl")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
// simple tests
8+
$a = 1;
9+
$b = array(1);
10+
$c = array(1);
11+
$d = array(1);
12+
13+
var_dump(openssl_seal($a, $b, $c, $d));
14+
var_dump(openssl_seal($a, $a, $a, array()));
15+
var_dump(openssl_seal($c, $c, $c, 1));
16+
var_dump(openssl_seal($b, $b, $b, ""));
17+
18+
// tests with cert
19+
$data = "openssl_open() test";
20+
$pub_key = "file://" . dirname(__FILE__) . "/public.key";
21+
$wrong = "wrong";
22+
23+
var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key))); // no output
24+
var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $pub_key))); // no output
25+
var_dump(openssl_seal($data, $sealed, $ekeys, array($pub_key, $wrong)));
26+
var_dump(openssl_seal($data, $sealed, $ekeys, $pub_key));
27+
var_dump(openssl_seal($data, $sealed, $ekeys, array()));
28+
var_dump(openssl_seal($data, $sealed, $ekeys, array($wrong)));
29+
30+
echo "Done\n";
31+
?>
32+
--EXPECTF--
33+
Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d
34+
bool(false)
35+
36+
Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
37+
bool(false)
38+
39+
Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
40+
NULL
41+
42+
Warning: openssl_seal() expects parameter 1 to be string, array given in %s on line %d
43+
NULL
44+
int(19)
45+
int(19)
46+
47+
Warning: openssl_seal(): not a public key (2th member of pubkeys) in %s on line %d
48+
bool(false)
49+
50+
Warning: openssl_seal() expects parameter 4 to be array, string given in %s on line %d
51+
NULL
52+
53+
Warning: openssl_seal(): Fourth argument to openssl_seal() must be a non-empty array in %s on line %d
54+
bool(false)
55+
56+
Warning: openssl_seal(): not a public key (1th member of pubkeys) in %s on line %d
57+
bool(false)
58+
Done

ext/openssl/tests/008.phpt renamed to ext/openssl/tests/openssl_x509_export_basic.phpt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ var_dump(openssl_x509_export($d, $output4)); // read cert from a resource
2020
var_dump(openssl_x509_export($e, $output5)); // read an array, fails
2121

2222
$outfilename = tempnam("/tmp", "ssl");
23-
if ($outfilename === false)
24-
die("failed to get a temporary filename!");
23+
if ($outfilename === false) {
24+
die("failed to get a temporary filename!");
25+
}
2526

2627
echo "---\n";
2728

@@ -34,7 +35,7 @@ echo "---\n";
3435

3536
var_dump($exists = file_exists($outfilename));
3637
if ($exists) {
37-
@unlink($outfilename);
38+
@unlink($outfilename);
3839
}
3940
echo "---\n";
4041

ext/openssl/tests/007.phpt renamed to ext/openssl/tests/openssl_x509_read_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
openssl_x509_read() and openssl_x509_free() tests
2+
openssl_x509_read() tests with testing openssl_x509_free as well
33
--SKIPIF--
44
<?php if (!extension_loaded("openssl")) print "skip"; ?>
55
--FILE--

0 commit comments

Comments
 (0)