From: Henrique do Nascimento Angelo Date: Fri, 18 Jul 2008 23:52:01 +0000 (+0000) Subject: New tests X-Git-Tag: php-5.3.0alpha1~279 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=158239004e3ab8aecf05b9a96868c571566572e4;p=php New tests --- diff --git a/ext/openssl/tests/007.phpt b/ext/openssl/tests/007.phpt new file mode 100644 index 0000000000..0a74bd3411 --- /dev/null +++ b/ext/openssl/tests/007.phpt @@ -0,0 +1,60 @@ +--TEST-- +openssl_x509_read() and openssl_x509_free() tests +--SKIPIF-- + +--FILE-- + +--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) diff --git a/ext/openssl/tests/008.phpt b/ext/openssl/tests/008.phpt new file mode 100644 index 0000000000..8963864ee5 --- /dev/null +++ b/ext/openssl/tests/008.phpt @@ -0,0 +1,74 @@ +--TEST-- +openssl_x509_export() and openssl_x509_export_to_file() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(true) + +Warning: openssl_x509_export(): cannot get cert from parameter 1 in %s on line %d +bool(false) +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) +int(0) +int(%d) diff --git a/ext/openssl/tests/009.phpt b/ext/openssl/tests/009.phpt new file mode 100644 index 0000000000..a7156dd8d0 --- /dev/null +++ b/ext/openssl/tests/009.phpt @@ -0,0 +1,29 @@ +--TEST-- +openssl_x509_check_private_key() tests +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(true) +bool(false) +bool(false) +bool(false) +bool(true) diff --git a/ext/openssl/tests/011.phpt b/ext/openssl/tests/011.phpt new file mode 100644 index 0000000000..927360900e --- /dev/null +++ b/ext/openssl/tests/011.phpt @@ -0,0 +1,21 @@ +--TEST-- +openssl_encrypt() and openssl_decrypt() tests +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(45) "openssl_encrypt() and openssl_decrypt() tests" +string(45) "openssl_encrypt() and openssl_decrypt() tests" + diff --git a/ext/openssl/tests/013.phpt b/ext/openssl/tests/013.phpt new file mode 100644 index 0000000000..91bb73dab3 --- /dev/null +++ b/ext/openssl/tests/013.phpt @@ -0,0 +1,28 @@ +--TEST-- +openssl_open() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(19) "openssl_open() test" + +Warning: openssl_open(): unable to coerce parameter 4 into a private key in %s on line %d +NULL +string(19) "openssl_open() test" +NULL diff --git a/ext/openssl/tests/014.phpt b/ext/openssl/tests/014.phpt new file mode 100644 index 0000000000..6123964ee5 --- /dev/null +++ b/ext/openssl/tests/014.phpt @@ -0,0 +1,38 @@ +--TEST-- +openssl_private_encrypt() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d +bool(false) + +Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d +bool(false) + +Warning: openssl_private_encrypt(): key param is not a valid private key in %s on line %d +bool(false) +bool(true) +string(4) "test" diff --git a/ext/openssl/tests/015.phpt b/ext/openssl/tests/015.phpt new file mode 100644 index 0000000000..a89121de10 --- /dev/null +++ b/ext/openssl/tests/015.phpt @@ -0,0 +1,39 @@ +--TEST-- +openssl_public_encrypt() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d +bool(false) + +Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d +bool(false) + +Warning: openssl_public_encrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +bool(true) +string(4) "test" + diff --git a/ext/openssl/tests/016.phpt b/ext/openssl/tests/016.phpt new file mode 100644 index 0000000000..2d772e7a36 --- /dev/null +++ b/ext/openssl/tests/016.phpt @@ -0,0 +1,48 @@ +--TEST-- +openssl_public_decrypt() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +string(32) "Testing openssl_public_decrypt()" + +Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +NULL +bool(false) +NULL + +Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +NULL + +Warning: openssl_public_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_public_decrypt(): key parameter is not a valid public key in %s on line %d +bool(false) +NULL +bool(true) +string(32) "Testing openssl_public_decrypt()" diff --git a/ext/openssl/tests/017.phpt b/ext/openssl/tests/017.phpt new file mode 100644 index 0000000000..65a7cd1025 --- /dev/null +++ b/ext/openssl/tests/017.phpt @@ -0,0 +1,40 @@ +--TEST-- +openssl_private_decrypt() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) +string(32) "Testing openssl_public_decrypt()" + +Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d +bool(false) +NULL +bool(false) +NULL + +Warning: openssl_private_decrypt(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_private_decrypt(): key parameter is not a valid private key in %s on line %d +bool(false) +NULL +bool(true) +string(32) "Testing openssl_public_decrypt()" diff --git a/ext/openssl/tests/018.phpt b/ext/openssl/tests/018.phpt new file mode 100644 index 0000000000..230c0a89db --- /dev/null +++ b/ext/openssl/tests/018.phpt @@ -0,0 +1,22 @@ +--TEST-- +openssl_sign() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: openssl_sign(): supplied key param cannot be coerced into a private key in %s on line %d +bool(false) + +Warning: openssl_sign() expects parameter 1 to be string, array given in %s on line %d +NULL diff --git a/ext/openssl/tests/019.phpt b/ext/openssl/tests/019.phpt new file mode 100644 index 0000000000..c1f186c335 --- /dev/null +++ b/ext/openssl/tests/019.phpt @@ -0,0 +1,28 @@ +--TEST-- +openssl_verify() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +int(1) + +Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d +bool(false) + +Warning: openssl_verify(): supplied key param cannot be coerced into a public key in %s on line %d +bool(false) +int(0) +int(0) diff --git a/ext/openssl/tests/021.phpt b/ext/openssl/tests/021.phpt new file mode 100644 index 0000000000..00e2158f8d --- /dev/null +++ b/ext/openssl/tests/021.phpt @@ -0,0 +1,77 @@ +--TEST-- +openssl_csr_sign() tests +--SKIPIF-- + +--FILE-- + "BR", + "stateOrProvinceName" => "Rio Grande do Sul", + "localityName" => "Porto Alegre", + "commonName" => "Henrique do N. Angelo", + "emailAddress" => "hnangelo@php.net" + ); + +$args = array( + "digest_alg" => "sha1", + "private_key_bits" => 2048, + "private_key_type" => OPENSSL_KEYTYPE_DSA, + "encrypt_key" => true + ); + +$privkey = openssl_pkey_new(); +$csr = openssl_csr_new($dn, $privkey, $args); +var_dump(openssl_csr_sign($csr, null, $privkey, 365, $args)); +var_dump(openssl_csr_sign($csr, null, $privkey, 365)); +var_dump(openssl_csr_sign($csr, $cert, $priv, 365)); +var_dump(openssl_csr_sign($csr, $wrong, $privkey, 365)); +var_dump(openssl_csr_sign($csr, null, $wrong, 365)); +var_dump(openssl_csr_sign($csr, null, $privkey, $wrong)); +var_dump(openssl_csr_sign($csr, null, $privkey, 365, $wrong)); +var_dump(openssl_csr_sign($wrong, null, $privkey, 365)); +var_dump(openssl_csr_sign(array(), null, $privkey, 365)); +var_dump(openssl_csr_sign($csr, array(), $privkey, 365)); +var_dump(openssl_csr_sign($csr, null, array(), 365)); +var_dump(openssl_csr_sign($csr, null, $privkey, array())); +var_dump(openssl_csr_sign($csr, null, $privkey, 365, array())); +?> +--EXPECTF-- +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (OpenSSL X.509) +resource(%d) of type (OpenSSL X.509) + +Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d +bool(false) + +Warning: openssl_csr_sign() expects parameter 4 to be long, string given in %s on line %d +NULL + +Warning: openssl_csr_sign() expects parameter 5 to be array, string given in %s on line %d +NULL + +Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): cannot get CSR from parameter 1 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): cannot get cert from parameter 2 in %s on line %d +bool(false) + +Warning: openssl_csr_sign(): key array must be of the form array(0 => key, 1 => phrase) in %s on line %d + +Warning: openssl_csr_sign(): cannot get private key from parameter 3 in %s on line %d +bool(false) + +Warning: openssl_csr_sign() expects parameter 4 to be long, array given in %s on line %d +NULL +resource(%d) of type (OpenSSL X.509) + diff --git a/ext/openssl/tests/022.phpt b/ext/openssl/tests/022.phpt new file mode 100644 index 0000000000..cbdebece8d --- /dev/null +++ b/ext/openssl/tests/022.phpt @@ -0,0 +1,45 @@ +--TEST-- +openssl_csr_export() tests +--SKIPIF-- + +--FILE-- + "BR", + "stateOrProvinceName" => "Rio Grande do Sul", + "localityName" => "Porto Alegre", + "commonName" => "Henrique do N. Angelo", + "emailAddress" => "hnangelo@php.net" + ); + +$args = array( + "digest_alg" => "sha1", + "private_key_bits" => 2048, + "private_key_type" => OPENSSL_KEYTYPE_DSA, + "encrypt_key" => true + ); + +$privkey = openssl_pkey_new(); +$csr = openssl_csr_new($dn, $privkey, $args); +var_dump(openssl_csr_export($csr, $output)); +var_dump(openssl_csr_export($wrong, $output)); +var_dump(openssl_csr_export($privkey, $output)); +var_dump(openssl_csr_export(array(), $output)); +var_dump(openssl_csr_export($csr, $output, false)); +?> +--EXPECTF-- +bool(true) + +Warning: openssl_csr_export() expects parameter 1 to be resource, string given in %s on line %d +NULL + +Warning: openssl_csr_export(): supplied resource is not a valid OpenSSL X.509 CSR resource in %s on line %d + +Warning: openssl_csr_export(): cannot get CSR from parameter 1 in %s on line %d +bool(false) + +Warning: openssl_csr_export() expects parameter 1 to be resource, array given in %s on line %d +NULL +bool(true) diff --git a/ext/openssl/tests/024.phpt b/ext/openssl/tests/024.phpt new file mode 100644 index 0000000000..0a61840de3 --- /dev/null +++ b/ext/openssl/tests/024.phpt @@ -0,0 +1,64 @@ +--TEST-- +openssl_pkcs7_decrypt() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(true) + +Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d +bool(false) +bool(false) +bool(false) +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to coerce parameter 3 to x509 cert in %s on line %d +bool(false) + +Warning: openssl_pkcs7_decrypt(): unable to get private key in %s on line %d +bool(false) +true +true diff --git a/ext/openssl/tests/openssl_decrypt_error.phpt b/ext/openssl/tests/openssl_decrypt_error.phpt new file mode 100644 index 0000000000..ea9cce2f0a --- /dev/null +++ b/ext/openssl/tests/openssl_decrypt_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +openssl_decrypt() error tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +bool(false) + +Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d +bool(false) +bool(false) + +Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d +bool(false) + +Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d +bool(false) + +Warning: openssl_decrypt(): Unknown cipher algorithm in %s on line %d +bool(false) + +Warning: openssl_decrypt() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: openssl_decrypt() expects parameter 2 to be string, array given in %s on line %d +NULL + +Warning: openssl_decrypt() expects parameter 3 to be string, array given in %s on line %d +NULL diff --git a/ext/openssl/tests/openssl_digest_basic.phpt b/ext/openssl/tests/openssl_digest_basic.phpt new file mode 100644 index 0000000000..a924c06877 --- /dev/null +++ b/ext/openssl/tests/openssl_digest_basic.phpt @@ -0,0 +1,16 @@ +--TEST-- +openssl_digest() basic test +--SKIPIF-- + +--FILE-- + +--EXPECT-- +string(32) "f0045b6c41d9ec835cb8948c7fec4955" +string(40) "aa6e750fef05c2414c18860ad31f2c35e79bf3dc" diff --git a/ext/openssl/tests/openssl_encrypt_error.phpt b/ext/openssl/tests/openssl_encrypt_error.phpt new file mode 100644 index 0000000000..7376f48708 --- /dev/null +++ b/ext/openssl/tests/openssl_encrypt_error.phpt @@ -0,0 +1,43 @@ +--TEST-- +openssl_encrypt() error tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Warning: openssl_encrypt(): Unknown cipher algorithm in %s on line %d +bool(false) + +Warning: openssl_encrypt() expects parameter 1 to be string, object given in %s on line %d +NULL + +Warning: openssl_encrypt() expects parameter 2 to be string, object given in %s on line %d +NULL + +Warning: openssl_encrypt() expects parameter 3 to be string, object given in %s on line %d +NULL + +Warning: openssl_encrypt() expects parameter 1 to be string, array given in %s on line %d +NULL + +Warning: openssl_encrypt() expects parameter 2 to be string, array given in %s on line %d +NULL + +Warning: openssl_encrypt() expects parameter 3 to be string, array given in %s on line %d +NULL + diff --git a/ext/openssl/tests/openssl_x509_parse_basic.phpt b/ext/openssl/tests/openssl_x509_parse_basic.phpt new file mode 100644 index 0000000000..5484bfe58d --- /dev/null +++ b/ext/openssl/tests/openssl_x509_parse_basic.phpt @@ -0,0 +1,274 @@ +--TEST-- +openssl_x509_parse() basic test +--SKIPIF-- + +--FILE-- + +--EXPECT-- +array(12) { + ["name"]=> + string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" + ["subject"]=> + array(5) { + ["C"]=> + string(2) "BR" + ["ST"]=> + string(17) "Rio Grande do Sul" + ["L"]=> + string(12) "Porto Alegre" + ["CN"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["hash"]=> + string(8) "088c65c2" + ["issuer"]=> + array(5) { + ["C"]=> + string(2) "BR" + ["ST"]=> + string(17) "Rio Grande do Sul" + ["L"]=> + string(12) "Porto Alegre" + ["CN"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["version"]=> + int(2) + ["serialNumber"]=> + string(20) "12593567369101004962" + ["validFrom"]=> + string(13) "080630102843Z" + ["validTo"]=> + string(13) "080730102843Z" + ["validFrom_time_t"]=> + int(1214821723) + ["validTo_time_t"]=> + int(1217413723) + ["purposes"]=> + array(8) { + [1]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(9) "sslclient" + } + [2]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(9) "sslserver" + } + [3]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "nssslserver" + } + [4]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(9) "smimesign" + } + [5]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(12) "smimeencrypt" + } + [6]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(7) "crlsign" + } + [7]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(3) "any" + } + [8]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(10) "ocsphelper" + } + } + ["extensions"]=> + array(3) { + ["subjectKeyIdentifier"]=> + string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" + ["authorityKeyIdentifier"]=> + string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D +DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net +serial:AE:C5:56:CC:72:37:50:A2 +" + ["basicConstraints"]=> + string(7) "CA:TRUE" + } +} +array(12) { + ["name"]=> + string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net" + ["subject"]=> + array(5) { + ["countryName"]=> + string(2) "BR" + ["stateOrProvinceName"]=> + string(17) "Rio Grande do Sul" + ["localityName"]=> + string(12) "Porto Alegre" + ["commonName"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["hash"]=> + string(8) "088c65c2" + ["issuer"]=> + array(5) { + ["countryName"]=> + string(2) "BR" + ["stateOrProvinceName"]=> + string(17) "Rio Grande do Sul" + ["localityName"]=> + string(12) "Porto Alegre" + ["commonName"]=> + string(21) "Henrique do N. Angelo" + ["emailAddress"]=> + string(16) "hnangelo@php.net" + } + ["version"]=> + int(2) + ["serialNumber"]=> + string(20) "12593567369101004962" + ["validFrom"]=> + string(13) "080630102843Z" + ["validTo"]=> + string(13) "080730102843Z" + ["validFrom_time_t"]=> + int(1214821723) + ["validTo_time_t"]=> + int(1217413723) + ["purposes"]=> + array(8) { + [1]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(10) "SSL client" + } + [2]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(10) "SSL server" + } + [3]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(19) "Netscape SSL server" + } + [4]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(14) "S/MIME signing" + } + [5]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(17) "S/MIME encryption" + } + [6]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "CRL signing" + } + [7]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "Any Purpose" + } + [8]=> + array(3) { + [0]=> + bool(true) + [1]=> + bool(true) + [2]=> + string(11) "OCSP helper" + } + } + ["extensions"]=> + array(3) { + ["subjectKeyIdentifier"]=> + string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D" + ["authorityKeyIdentifier"]=> + string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D +DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net +serial:AE:C5:56:CC:72:37:50:A2 +" + ["basicConstraints"]=> + string(7) "CA:TRUE" + } +}