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)