mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2026-02-04 13:21:34 +00:00
more tests
removed examples
This commit is contained in:
parent
f98e3c57e4
commit
ba4ad8960b
33 changed files with 478 additions and 121 deletions
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
import a new key into the keyring
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--
|
||||
encrypt and decrypt a text
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--
|
||||
encryptsign and decryptverify a text
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--
|
||||
export a key
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
get keyinfo
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
list signatures
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with sigmode SIG_MODE_CLEAR
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH and without armored output
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL and without armored output
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
14
tests/gnupg_oo_zzz_deletekey.phpt
Normal file
14
tests/gnupg_oo_zzz_deletekey.phpt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
--TEST--n
|
||||
delete a key from the keyring
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = new gnupg();
|
||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
||||
$ret = $gpg -> deletekey($fingerprint,true);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
33
tests/gnupg_res_0001_import.phpt
Normal file
33
tests/gnupg_res_0001_import.phpt
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
--TEST--n
|
||||
import a new key into the keyring
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
@unlink (dirname(__FILE__)."/pubring.gpg");
|
||||
@unlink (dirname(__FILE__)."/secring.gpg");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_import($gpg, $testkey);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--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"
|
||||
}
|
||||
20
tests/gnupg_res_encrypt.phpt
Normal file
20
tests/gnupg_res_encrypt.phpt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
--TEST--
|
||||
encrypt and decrypt a text
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_addencryptkey($gpg, $fingerprint);
|
||||
$enc = gnupg_encrypt($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
gnupg_adddecryptkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_decrypt ($gpg, $enc);
|
||||
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(7) "foo bar"
|
||||
38
tests/gnupg_res_encryptsign.phpt
Normal file
38
tests/gnupg_res_encryptsign.phpt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
--TEST--
|
||||
encryptsign and decryptverify a text
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_addencryptkey($gpg, $fingerprint);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$enc = gnupg_encryptsign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
$plaintext = false;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
gnupg_adddecryptkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_decryptverify ($gpg, $enc, $plaintext);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--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"
|
||||
36
tests/gnupg_res_export.phpt
Normal file
36
tests/gnupg_res_export.phpt
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
--TEST--
|
||||
export a key
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_export($gpg, $fingerprint);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(1336) "-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v1.4.3 (GNU/Linux)
|
||||
|
||||
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
|
||||
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
|
||||
/samjTHLR+VKZ031B5/8p5Y49yvkkEyBkF1G85yeIXK0WZorKBPncRKuUwCgxOi/
|
||||
IEa+ZuqHlmlDF2LTRIBOfrkEAK+WLRMWUD0bqj1TYwnxwPWiuns32/ZXLWuPfb5o
|
||||
crNt7x5LSe7wJhjyIiFhiU0qR33X/FrT2umzOxlRYfINXT9DUHDocxxbED6fxAHw
|
||||
X2IDd5tWXgCkSBHn2yAneNY6ycPdS3RvqJGlYFg7cOc0kz4urjqRt9fIagzpZQtL
|
||||
fXHfBACl3EWgvLhVBo5ExZbrtlOA2q0x9UGhhNaSkeBWBr2qDeZErQjMTO0+viaN
|
||||
/SX0zxeWtM3z06rkUHd1DKORDRM5R7shBTv9/Quojn0gbYbOem+e1mlCe27TRxcP
|
||||
yeIKk00PqbVuff9QlK9GqKEWGzsEXCmxZ160Dul3CGlf/vQZHbQkdGVzdGtleSAo
|
||||
dGVzdGtleSkgPHRlc3RAZXhhbXBsZS5uZXQ+iF4EExECAB4FAkNQAKwCGwMGCwkI
|
||||
BwMCAxUCAwMWAgECHgECF4AACgkQLpbxQbPdKy58pwCcDz9qEBEVt1gcKCwNay0f
|
||||
m4vLqCkAn1P0KV1giECUVXBuZ5YUndDB1QqtuQENBENQAK0QBACNXzJQG4NHUJqL
|
||||
PImezbl+ii+93MjMo8LpSlv9Np5ruWIKtxuqmVEe4k+r1DDmSl8hppifpRtx2hef
|
||||
bDTl8Tdf5MNGvf5JE3AHYUehZ+ldjgYCOZ53fJDgKV65ZidQSGGXsRcyE7SHgMQ6
|
||||
rTL92PA2IQmkcf9xkg6xM2h55UusMwADBQP9EGQ0BAdWRUtA21/cR6F+t97KZnVS
|
||||
et225UYv8azv8p8cK4R1lrZXChFadK9Kt+/My4HAx7J7zd1IPuKQ0QniuvuLT3Mw
|
||||
z19B7FGXaJenwTw0P1ihtmSPq9GAOkOA4ZPhHLl9OFwIeAZzjfshRfvm0haO3vwl
|
||||
xdjhwxyJ/a/JEF2ISQQYEQIACQUCQ1AArQIbDAAKCRAulvFBs90rLrBkAJ9tScp6
|
||||
drhhPQJw1AY6GEpSbK0JtACeJuewK8C1wO1l5OYkGzFpb4VgquI=
|
||||
=twR+
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
"
|
||||
97
tests/gnupg_res_keyinfo.phpt
Normal file
97
tests/gnupg_res_keyinfo.phpt
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
--TEST--n
|
||||
get keyinfo
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_keyinfo($gpg, $fingerprint);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--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) <test@example.net>"
|
||||
["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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
tests/gnupg_res_listsignatures.phpt
Normal file
35
tests/gnupg_res_listsignatures.phpt
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
--TEST--n
|
||||
list signatures
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_listsignatures($gpg, $fingerprint);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
["testkey (testkey) <test@example.net>"]=>
|
||||
array(1) {
|
||||
["2E96F141B3DD2B2E"]=>
|
||||
array(8) {
|
||||
["uid"]=>
|
||||
string(36) "testkey (testkey) <test@example.net>"
|
||||
["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)
|
||||
}
|
||||
}
|
||||
}
|
||||
38
tests/gnupg_res_sign_clear.phpt
Normal file
38
tests/gnupg_res_sign_clear.phpt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with sigmode SIG_MODE_CLEAR
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_CLEAR);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$ret = gnupg_verify($gpg, $ret, false, $tmp);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($tmp);
|
||||
?>
|
||||
--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
|
||||
"
|
||||
37
tests/gnupg_res_sign_detach.phpt
Normal file
37
tests/gnupg_res_sign_detach.phpt
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$ret = gnupg_verify($gpg,$plaintext, $ret);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--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"
|
||||
38
tests/gnupg_res_sign_detach_nonarmor.phpt
Normal file
38
tests/gnupg_res_sign_detach_nonarmor.phpt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_DETACH and without armored output
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setarmor($gpg, 0);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$ret = gnupg_verify($gpg, $plaintext, $ret);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--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"
|
||||
38
tests/gnupg_res_sign_normal.phpt
Normal file
38
tests/gnupg_res_sign_normal.phpt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg,$plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$tmp = false;
|
||||
$plaintext = false;
|
||||
$ret = gnupg_verify($gpg, $ret, false, $plaintext);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--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"
|
||||
38
tests/gnupg_res_sign_normal_noarmor.phpt
Normal file
38
tests/gnupg_res_sign_normal_noarmor.phpt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
--TEST--n
|
||||
sign a text with mode SIG_MODE_NORMAL and without armored output
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
gnupg_setarmor($gpg, 0);
|
||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL);
|
||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||
$ret = gnupg_sign($gpg, $plaintext);
|
||||
|
||||
$gpg = NULL;
|
||||
|
||||
$gpg = gnupg_init();
|
||||
$plaintext = false;
|
||||
$ret = gnupg_verify($gpg, $ret, false, $plaintext);
|
||||
|
||||
var_dump($ret);
|
||||
var_dump($plaintext);
|
||||
?>
|
||||
--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"
|
||||
12
tests/gnupg_res_zzz_deletekey.phpt
Normal file
12
tests/gnupg_res_zzz_deletekey.phpt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
--TEST--n
|
||||
delete a key from the keyring
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(dirname(__FILE__)."/vars.inc");
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
$ret = gnupg_deletekey($gpg, $fingerprint,true);
|
||||
var_dump($ret);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
Loading…
Add table
Add a link
Reference in a new issue