Skip to content

Commit

Permalink
Extend openssl_pkcs7_* tests to cover resource cert
Browse files Browse the repository at this point in the history
  • Loading branch information
bukka committed Oct 30, 2017
1 parent 55d9241 commit 5487988
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ext/openssl/tests/openssl_pkcs7_decrypt_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $empty = "";

openssl_pkcs7_encrypt($infile, $encrypted, $single_cert, $headers);
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $privkey));
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, openssl_x509_read($single_cert), $privkey));
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $single_cert, $wrong));
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, $wrong, $privkey));
var_dump(openssl_pkcs7_decrypt($encrypted, $outfile, null, $privkey));
Expand All @@ -42,6 +43,7 @@ if (file_exists($outfile)) {
?>
--EXPECTF--
bool(true)
bool(true)

Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d
bool(false)
Expand Down
4 changes: 4 additions & 0 deletions ext/openssl/tests/openssl_pkcs7_encrypt_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ $wrong = "wrong";
$empty = "";

var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $headers));
var_dump(openssl_pkcs7_encrypt($infile, $outfile, openssl_x509_read($single_cert), $headers));
var_dump(openssl_pkcs7_decrypt($outfile, $outfile2, $single_cert, $privkey));
var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $assoc_headers));
var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $empty_headers));
Expand All @@ -33,6 +34,7 @@ var_dump(openssl_pkcs7_encrypt($infile, $outfile, $wrong, $headers));
var_dump(openssl_pkcs7_encrypt($infile, $outfile, $empty, $headers));
var_dump(openssl_pkcs7_encrypt($infile, $outfile, $single_cert, $empty));
var_dump(openssl_pkcs7_encrypt($infile, $outfile, $multi_certs, $headers));
var_dump(openssl_pkcs7_encrypt($infile, $outfile, array_map('openssl_x509_read', $multi_certs) , $headers));

if (file_exists($outfile)) {
echo "true\n";
Expand All @@ -48,6 +50,7 @@ bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

Warning: openssl_pkcs7_encrypt() expects parameter 4 to be array, string given in %s on line %d
bool(false)
Expand All @@ -60,5 +63,6 @@ bool(false)
Warning: openssl_pkcs7_encrypt() expects parameter 4 to be array, string given in %s on line %d
bool(false)
bool(true)
bool(true)
true
true
2 changes: 2 additions & 0 deletions ext/openssl/tests/openssl_pkcs7_sign_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $empty_headers = array();
$wrong = "wrong";
$empty = "";

var_dump(openssl_pkcs7_sign($infile, $outfile, openssl_x509_read($single_cert), $privkey, $headers));
var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $headers));
var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $assoc_headers));
var_dump(openssl_pkcs7_sign($infile, $outfile, $single_cert, $privkey, $empty_headers));
Expand All @@ -39,6 +40,7 @@ if (file_exists($outfile)) {
bool(true)
bool(true)
bool(true)
bool(true)

Warning: openssl_pkcs7_sign() expects parameter 5 to be array, string given in %s on line %d
NULL
Expand Down

0 comments on commit 5487988

Please sign in to comment.