From ba4ad8960b7c5b2538b44f1f28a84af3f23a90cf Mon Sep 17 00:00:00 2001 From: Thilo Raufeisen Date: Fri, 3 Nov 2006 12:39:53 +0000 Subject: [PATCH] more tests removed examples --- examples/clearsign.php | 7 -- examples/decrypt.php | 29 ------ examples/encrypt.php | 7 -- examples/encryptsign.php | 14 --- examples/export.php | 5 - examples/keyinfo.php | 6 -- examples/keylistiterator.php | 8 -- examples/main.php | 9 -- examples/verify.php | 24 ----- ...port_oo.phpt => gnupg_oo_0001_import.phpt} | 2 + ..._encrypt_oo.phpt => gnupg_oo_encrypt.phpt} | 2 + ...sign_oo.phpt => gnupg_oo_encryptsign.phpt} | 2 + ...pg_export_oo.phpt => gnupg_oo_export.phpt} | 2 + ..._keyinfo_oo.phpt => gnupg_oo_keyinfo.phpt} | 2 + ...s_oo.phpt => gnupg_oo_listsignatures.phpt} | 2 + ...clear_oo.phpt => gnupg_oo_sign_clear.phpt} | 2 + ...tach_oo.phpt => gnupg_oo_sign_detach.phpt} | 2 + ...hpt => gnupg_oo_sign_detach_nonarmor.phpt} | 2 + ..._normal.phpt => gnupg_oo_sign_normal.phpt} | 2 + ...phpt => gnupg_oo_sign_normal_noarmor.phpt} | 2 + tests/gnupg_oo_zzz_deletekey.phpt | 14 +++ tests/gnupg_res_0001_import.phpt | 33 +++++++ tests/gnupg_res_encrypt.phpt | 20 ++++ tests/gnupg_res_encryptsign.phpt | 38 ++++++++ .../import.php => tests/gnupg_res_export.phpt | 30 +++--- tests/gnupg_res_keyinfo.phpt | 97 +++++++++++++++++++ tests/gnupg_res_listsignatures.phpt | 35 +++++++ tests/gnupg_res_sign_clear.phpt | 38 ++++++++ tests/gnupg_res_sign_detach.phpt | 37 +++++++ tests/gnupg_res_sign_detach_nonarmor.phpt | 38 ++++++++ tests/gnupg_res_sign_normal.phpt | 38 ++++++++ tests/gnupg_res_sign_normal_noarmor.phpt | 38 ++++++++ tests/gnupg_res_zzz_deletekey.phpt | 12 +++ 33 files changed, 478 insertions(+), 121 deletions(-) delete mode 100644 examples/clearsign.php delete mode 100644 examples/decrypt.php delete mode 100644 examples/encrypt.php delete mode 100644 examples/encryptsign.php delete mode 100644 examples/export.php delete mode 100644 examples/keyinfo.php delete mode 100644 examples/keylistiterator.php delete mode 100644 examples/main.php delete mode 100644 examples/verify.php rename tests/{0001_gnupg_import_oo.phpt => gnupg_oo_0001_import.phpt} (91%) rename tests/{gnupg_encrypt_oo.phpt => gnupg_oo_encrypt.phpt} (86%) rename tests/{gnupg_encryptsign_oo.phpt => gnupg_oo_encryptsign.phpt} (92%) rename tests/{gnupg_export_oo.phpt => gnupg_oo_export.phpt} (96%) rename tests/{gnupg_keyinfo_oo.phpt => gnupg_oo_keyinfo.phpt} (97%) rename tests/{gnupg_listsignatures_oo.phpt => gnupg_oo_listsignatures.phpt} (92%) rename tests/{gnupg_sign_clear_oo.phpt => gnupg_oo_sign_clear.phpt} (92%) rename tests/{gnupg_sign_detach_oo.phpt => gnupg_oo_sign_detach.phpt} (92%) rename tests/{gnupg_sign_detach_nonarmor.phpt => gnupg_oo_sign_detach_nonarmor.phpt} (92%) rename tests/{gnupg_sign_normal.phpt => gnupg_oo_sign_normal.phpt} (92%) rename tests/{gnupg_sign_normal_nonarmor.phpt => gnupg_oo_sign_normal_noarmor.phpt} (93%) create mode 100644 tests/gnupg_oo_zzz_deletekey.phpt create mode 100644 tests/gnupg_res_0001_import.phpt create mode 100644 tests/gnupg_res_encrypt.phpt create mode 100644 tests/gnupg_res_encryptsign.phpt rename examples/import.php => tests/gnupg_res_export.phpt (64%) create mode 100644 tests/gnupg_res_keyinfo.phpt create mode 100644 tests/gnupg_res_listsignatures.phpt create mode 100644 tests/gnupg_res_sign_clear.phpt create mode 100644 tests/gnupg_res_sign_detach.phpt create mode 100644 tests/gnupg_res_sign_detach_nonarmor.phpt create mode 100644 tests/gnupg_res_sign_normal.phpt create mode 100644 tests/gnupg_res_sign_normal_noarmor.phpt create mode 100644 tests/gnupg_res_zzz_deletekey.phpt diff --git a/examples/clearsign.php b/examples/clearsign.php deleted file mode 100644 index 37e3dff..0000000 --- a/examples/clearsign.php +++ /dev/null @@ -1,7 +0,0 @@ - addSignKey ($fingerprint,$passphrase); -$text = $gnupg -> sign ($mailtext); -echo $text; -?> diff --git a/examples/decrypt.php b/examples/decrypt.php deleted file mode 100644 index 2ac8857..0000000 --- a/examples/decrypt.php +++ /dev/null @@ -1,29 +0,0 @@ - addDecryptKey ($fingerprint,$passphrase); -$plaintext = $gnupg -> decrypt ($mailtext); - -echo "\n".$plaintext."\n"; -?> diff --git a/examples/encrypt.php b/examples/encrypt.php deleted file mode 100644 index aa160be..0000000 --- a/examples/encrypt.php +++ /dev/null @@ -1,7 +0,0 @@ - addEncryptKey ($fingerprint); -$text = $gnupg -> encrypt ($mailtext); -echo $text; -?> diff --git a/examples/encryptsign.php b/examples/encryptsign.php deleted file mode 100644 index 5b13a81..0000000 --- a/examples/encryptsign.php +++ /dev/null @@ -1,14 +0,0 @@ - addSignKey ($fingerprint,$passphrase); -$gnupg -> addEncryptKey ($fingerprint); -$text = $gnupg -> encryptsign ($mailtext); -echo $text; -echo "\n-------------------------\n"; -$plaintext = false; -$gnupg -> addDecryptKey ($fingerprint,$passphrase); -$retval = $gnupg -> decryptverify ($text,$plaintext); -print_r($retval); -print_r($plaintext); -?> diff --git a/examples/export.php b/examples/export.php deleted file mode 100644 index 299ad39..0000000 --- a/examples/export.php +++ /dev/null @@ -1,5 +0,0 @@ - export($fingerprint); -print_r($result); -?> diff --git a/examples/keyinfo.php b/examples/keyinfo.php deleted file mode 100644 index bde2a76..0000000 --- a/examples/keyinfo.php +++ /dev/null @@ -1,6 +0,0 @@ - keyinfo ($fingerprint); -print_r($keyinfo) -?> diff --git a/examples/keylistiterator.php b/examples/keylistiterator.php deleted file mode 100644 index 145577f..0000000 --- a/examples/keylistiterator.php +++ /dev/null @@ -1,8 +0,0 @@ - $value){ - echo $key." -> ".$value."\n"; -} -?> diff --git a/examples/main.php b/examples/main.php deleted file mode 100644 index 3da6cb5..0000000 --- a/examples/main.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/examples/verify.php b/examples/verify.php deleted file mode 100644 index 93249ef..0000000 --- a/examples/verify.php +++ /dev/null @@ -1,24 +0,0 @@ - verify ($mailtext,false,$plaintext); - -print_r($info); -echo "\n".$plaintext."\n"; -?> diff --git a/tests/0001_gnupg_import_oo.phpt b/tests/gnupg_oo_0001_import.phpt similarity index 91% rename from tests/0001_gnupg_import_oo.phpt rename to tests/gnupg_oo_0001_import.phpt index 01946d5..2c866d0 100644 --- a/tests/0001_gnupg_import_oo.phpt +++ b/tests/gnupg_oo_0001_import.phpt @@ -1,5 +1,7 @@ --TEST--n import a new key into the keyring +--SKIPIF-- + --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- --FILE-- +--FILE-- + seterrormode(gnupg::ERROR_WARNING); +$ret = $gpg -> deletekey($fingerprint,true); +var_dump($ret); +?> +--EXPECT-- +bool(true) diff --git a/tests/gnupg_res_0001_import.phpt b/tests/gnupg_res_0001_import.phpt new file mode 100644 index 0000000..7eb5160 --- /dev/null +++ b/tests/gnupg_res_0001_import.phpt @@ -0,0 +1,33 @@ +--TEST--n +import a new key into the keyring +--FILE-- + +--EXPECT-- +array(9) { + ["imported"]=> + int(1) + ["unchanged"]=> + int(0) + ["newuserids"]=> + int(0) + ["newsubkeys"]=> + int(0) + ["secretimported"]=> + int(1) + ["secretunchanged"]=> + int(0) + ["newsignatures"]=> + int(0) + ["skippedkeys"]=> + int(0) + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" +} diff --git a/tests/gnupg_res_encrypt.phpt b/tests/gnupg_res_encrypt.phpt new file mode 100644 index 0000000..f8fc809 --- /dev/null +++ b/tests/gnupg_res_encrypt.phpt @@ -0,0 +1,20 @@ +--TEST-- +encrypt and decrypt a text +--FILE-- + +--EXPECTF-- +string(7) "foo bar" diff --git a/tests/gnupg_res_encryptsign.phpt b/tests/gnupg_res_encryptsign.phpt new file mode 100644 index 0000000..553c4d1 --- /dev/null +++ b/tests/gnupg_res_encryptsign.phpt @@ -0,0 +1,38 @@ +--TEST-- +encryptsign and decryptverify a text +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + array(5) { + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" + ["validity"]=> + int(0) + ["timestamp"]=> + int(%d) + ["status"]=> + int(0) + ["summary"]=> + int(0) + } +} +string(7) "foo bar" diff --git a/examples/import.php b/tests/gnupg_res_export.phpt similarity index 64% rename from examples/import.php rename to tests/gnupg_res_export.phpt index 6675792..7fc14cf 100644 --- a/examples/import.php +++ b/tests/gnupg_res_export.phpt @@ -1,7 +1,16 @@ +--TEST-- +export a key +--FILE-- +--EXPECTF-- +string(1336) "-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.3 (GNU/Linux) mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3 afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z @@ -13,18 +22,15 @@ fXHfBACl3EWgvLhVBo5ExZbrtlOA2q0x9UGhhNaSkeBWBr2qDeZErQjMTO0+viaN /SX0zxeWtM3z06rkUHd1DKORDRM5R7shBTv9/Quojn0gbYbOem+e1mlCe27TRxcP yeIKk00PqbVuff9QlK9GqKEWGzsEXCmxZ160Dul3CGlf/vQZHbQkdGVzdGtleSAo dGVzdGtleSkgPHRlc3RAZXhhbXBsZS5uZXQ+iF4EExECAB4FAkNQAKwCGwMGCwkI -BwMCAxUCAwMWAgECHgECF4AACgkQLpbxQbPdKy58pwCfWttBa4bojGc+oVQbmx43 -lMMTuP8An3INHAxsm0DkdhfergYi2f6BNMPmuQENBENQAK0QBACNXzJQG4NHUJqL +BwMCAxUCAwMWAgECHgECF4AACgkQLpbxQbPdKy58pwCcDz9qEBEVt1gcKCwNay0f +m4vLqCkAn1P0KV1giECUVXBuZ5YUndDB1QqtuQENBENQAK0QBACNXzJQG4NHUJqL PImezbl+ii+93MjMo8LpSlv9Np5ruWIKtxuqmVEe4k+r1DDmSl8hppifpRtx2hef bDTl8Tdf5MNGvf5JE3AHYUehZ+ldjgYCOZ53fJDgKV65ZidQSGGXsRcyE7SHgMQ6 rTL92PA2IQmkcf9xkg6xM2h55UusMwADBQP9EGQ0BAdWRUtA21/cR6F+t97KZnVS et225UYv8azv8p8cK4R1lrZXChFadK9Kt+/My4HAx7J7zd1IPuKQ0QniuvuLT3Mw z19B7FGXaJenwTw0P1ihtmSPq9GAOkOA4ZPhHLl9OFwIeAZzjfshRfvm0haO3vwl -xdjhwxyJ/a/JEF2ISQQYEQIACQUCQ1AArQIbDAAKCRAulvFBs90rLrBkAJ9rzjkU -UZk4JQ9uw4sme5lJxDBYKQCgwW+pIlvGpU8C4CYSrTK/ySUNUnE= -=ah4i +xdjhwxyJ/a/JEF2ISQQYEQIACQUCQ1AArQIbDAAKCRAulvFBs90rLrBkAJ9tScp6 +drhhPQJw1AY6GEpSbK0JtACeJuewK8C1wO1l5OYkGzFpb4VgquI= +=twR+ -----END PGP PUBLIC KEY BLOCK----- -'; -$result = $gnupg -> import($testkey); -print_r($result); -?> +" diff --git a/tests/gnupg_res_keyinfo.phpt b/tests/gnupg_res_keyinfo.phpt new file mode 100644 index 0000000..5fc4020 --- /dev/null +++ b/tests/gnupg_res_keyinfo.phpt @@ -0,0 +1,97 @@ +--TEST--n +get keyinfo +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + array(8) { + ["disabled"]=> + bool(false) + ["expired"]=> + bool(false) + ["revoked"]=> + bool(false) + ["is_secret"]=> + bool(false) + ["can_sign"]=> + bool(true) + ["can_encrypt"]=> + bool(true) + ["uids"]=> + array(1) { + [0]=> + array(6) { + ["name"]=> + string(7) "testkey" + ["comment"]=> + string(7) "testkey" + ["email"]=> + string(16) "test@example.net" + ["uid"]=> + string(36) "testkey (testkey) " + ["revoked"]=> + bool(false) + ["invalid"]=> + bool(false) + } + } + ["subkeys"]=> + array(2) { + [0]=> + array(11) { + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" + ["keyid"]=> + string(16) "2E96F141B3DD2B2E" + ["timestamp"]=> + int(1129316524) + ["expires"]=> + int(0) + ["is_secret"]=> + bool(false) + ["invalid"]=> + bool(false) + ["can_encrypt"]=> + bool(false) + ["can_sign"]=> + bool(true) + ["disabled"]=> + bool(false) + ["expired"]=> + bool(false) + ["revoked"]=> + bool(false) + } + [1]=> + array(10) { + ["keyid"]=> + string(16) "BFE8D07DDACDEAC8" + ["timestamp"]=> + int(1129316525) + ["expires"]=> + int(0) + ["is_secret"]=> + bool(false) + ["invalid"]=> + bool(false) + ["can_encrypt"]=> + bool(true) + ["can_sign"]=> + bool(false) + ["disabled"]=> + bool(false) + ["expired"]=> + bool(false) + ["revoked"]=> + bool(false) + } + } + } +} diff --git a/tests/gnupg_res_listsignatures.phpt b/tests/gnupg_res_listsignatures.phpt new file mode 100644 index 0000000..af11391 --- /dev/null +++ b/tests/gnupg_res_listsignatures.phpt @@ -0,0 +1,35 @@ +--TEST--n +list signatures +--FILE-- + +--EXPECT-- +array(1) { + ["testkey (testkey) "]=> + array(1) { + ["2E96F141B3DD2B2E"]=> + array(8) { + ["uid"]=> + string(36) "testkey (testkey) " + ["name"]=> + string(7) "testkey" + ["email"]=> + string(16) "test@example.net" + ["comment"]=> + string(7) "testkey" + ["expires"]=> + int(0) + ["revoked"]=> + bool(false) + ["expired"]=> + bool(false) + ["invalid"]=> + bool(false) + } + } +} diff --git a/tests/gnupg_res_sign_clear.phpt b/tests/gnupg_res_sign_clear.phpt new file mode 100644 index 0000000..6314c36 --- /dev/null +++ b/tests/gnupg_res_sign_clear.phpt @@ -0,0 +1,38 @@ +--TEST--n +sign a text with sigmode SIG_MODE_CLEAR +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + array(5) { + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" + ["validity"]=> + int(0) + ["timestamp"]=> + int(%d) + ["status"]=> + int(0) + ["summary"]=> + int(0) + } +} +string(8) "foo bar +" diff --git a/tests/gnupg_res_sign_detach.phpt b/tests/gnupg_res_sign_detach.phpt new file mode 100644 index 0000000..6583ef7 --- /dev/null +++ b/tests/gnupg_res_sign_detach.phpt @@ -0,0 +1,37 @@ +--TEST--n +sign a text with mode SIG_MODE_DETACH +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + array(5) { + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" + ["validity"]=> + int(0) + ["timestamp"]=> + int(%d) + ["status"]=> + int(0) + ["summary"]=> + int(0) + } +} +string(7) "foo bar" diff --git a/tests/gnupg_res_sign_detach_nonarmor.phpt b/tests/gnupg_res_sign_detach_nonarmor.phpt new file mode 100644 index 0000000..0055a5a --- /dev/null +++ b/tests/gnupg_res_sign_detach_nonarmor.phpt @@ -0,0 +1,38 @@ +--TEST--n +sign a text with mode SIG_MODE_DETACH and without armored output +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + array(5) { + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" + ["validity"]=> + int(0) + ["timestamp"]=> + int(%d) + ["status"]=> + int(0) + ["summary"]=> + int(0) + } +} +string(7) "foo bar" diff --git a/tests/gnupg_res_sign_normal.phpt b/tests/gnupg_res_sign_normal.phpt new file mode 100644 index 0000000..8333ff7 --- /dev/null +++ b/tests/gnupg_res_sign_normal.phpt @@ -0,0 +1,38 @@ +--TEST--n +sign a text with mode SIG_MODE_NORMAL +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + array(5) { + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" + ["validity"]=> + int(0) + ["timestamp"]=> + int(%d) + ["status"]=> + int(0) + ["summary"]=> + int(0) + } +} +string(7) "foo bar" diff --git a/tests/gnupg_res_sign_normal_noarmor.phpt b/tests/gnupg_res_sign_normal_noarmor.phpt new file mode 100644 index 0000000..324eef8 --- /dev/null +++ b/tests/gnupg_res_sign_normal_noarmor.phpt @@ -0,0 +1,38 @@ +--TEST--n +sign a text with mode SIG_MODE_NORMAL and without armored output +--FILE-- + +--EXPECTF-- +array(1) { + [0]=> + array(5) { + ["fingerprint"]=> + string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" + ["validity"]=> + int(0) + ["timestamp"]=> + int(%d) + ["status"]=> + int(0) + ["summary"]=> + int(0) + } +} +string(7) "foo bar" diff --git a/tests/gnupg_res_zzz_deletekey.phpt b/tests/gnupg_res_zzz_deletekey.phpt new file mode 100644 index 0000000..460a2d0 --- /dev/null +++ b/tests/gnupg_res_zzz_deletekey.phpt @@ -0,0 +1,12 @@ +--TEST--n +delete a key from the keyring +--FILE-- + +--EXPECT-- +bool(true)