mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-25 07:37:08 +00:00
Refactore all test to be independent
This commit is contained in:
parent
3bb4d28798
commit
4aabe3c966
26 changed files with 306 additions and 108 deletions
21
tests/gnupg_oo_deletekey.phpt
Normal file
21
tests/gnupg_oo_deletekey.phpt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
--TEST--
|
||||||
|
delete a key from the keyring
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
|
$gpg = new gnupg();
|
||||||
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
|
$ret = $gpg->deletekey($fingerprint,true);
|
||||||
|
var_dump($ret);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(true)
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -4,18 +4,24 @@ encrypt and decrypt a text
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
$gpg = new gnupg();
|
gnupgt::import_key();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
|
||||||
$gpg -> addencryptkey($fingerprint);
|
|
||||||
$enc = $gpg -> encrypt($plaintext);
|
|
||||||
$gpg = NULL;
|
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> adddecryptkey($fingerprint, $passphrase);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$ret = $gpg -> decrypt ($enc);
|
$gpg->addencryptkey($fingerprint);
|
||||||
|
$enc = $gpg->encrypt($plaintext);
|
||||||
|
|
||||||
|
$gpg = new gnupg();
|
||||||
|
$gpg->adddecryptkey($fingerprint, $passphrase);
|
||||||
|
$ret = $gpg->decrypt($enc);
|
||||||
|
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
||||||
|
|
|
@ -4,19 +4,19 @@ encryptsign and decryptverify a text
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
$gpg = new gnupg();
|
gnupgt::import_key();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
|
||||||
$gpg -> addencryptkey($fingerprint);
|
$gpg = new gnupg();
|
||||||
$gpg -> addsignkey($fingerprint, $passphrase);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$enc = $gpg -> encryptsign($plaintext);
|
$gpg->addencryptkey($fingerprint);
|
||||||
|
$gpg->addsignkey($fingerprint, $passphrase);
|
||||||
|
$enc = $gpg->encryptsign($plaintext);
|
||||||
|
|
||||||
$gpg = NULL;
|
|
||||||
$plaintext = false;
|
$plaintext = false;
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> adddecryptkey($fingerprint, $passphrase);
|
$gpg->adddecryptkey($fingerprint, $passphrase);
|
||||||
$ret = $gpg -> decryptverify ($enc, $plaintext);
|
$ret = $gpg->decryptverify ($enc, $plaintext);
|
||||||
|
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
var_dump($plaintext);
|
var_dump($plaintext);
|
||||||
|
@ -38,3 +38,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -4,15 +4,16 @@ export a key
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$ret = $gpg -> export($fingerprint);
|
$ret = $gpg->export($fingerprint);
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
|
string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
Version: GnuPG v1
|
|
||||||
|
|
||||||
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
|
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
|
||||||
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
|
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
|
||||||
|
@ -36,3 +37,8 @@ drhhPQJw1AY6GEpSbK0JtACeJuewK8C1wO1l5OYkGzFpb4VgquI=
|
||||||
=twR+
|
=twR+
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
"
|
"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,15 +1,15 @@
|
||||||
--TEST--n
|
--TEST--
|
||||||
import a new key into the keyring
|
import a new key into the keyring
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
@unlink (dirname(__FILE__)."/pubring.gpg");
|
gnupgt::delete_key();
|
||||||
@unlink (dirname(__FILE__)."/secring.gpg");
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$ret = $gpg -> import($testkey);
|
$ret = $gpg->import($testkey);
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -33,3 +33,8 @@ array(9) {
|
||||||
["fingerprint"]=>
|
["fingerprint"]=>
|
||||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||||
}
|
}
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -4,10 +4,12 @@ get keyinfo
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$ret = $gpg -> keyinfo($fingerprint);
|
$ret = $gpg->keyinfo($fingerprint);
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -99,3 +101,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
--TEST--n
|
--TEST--
|
||||||
list signatures
|
list signatures
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$ret = $gpg -> listsignatures($fingerprint);
|
$ret = $gpg->listsignatures($fingerprint);
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
@ -35,3 +37,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -4,18 +4,20 @@ sign a text with sigmode SIG_MODE_CLEAR
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$gpg -> setsignmode(gnupg::SIG_MODE_CLEAR);
|
$gpg->setsignmode(gnupg::SIG_MODE_CLEAR);
|
||||||
$gpg -> addsignkey($fingerprint, $passphrase);
|
$gpg->addsignkey($fingerprint, $passphrase);
|
||||||
$ret = $gpg -> sign($plaintext);
|
$ret = $gpg->sign($plaintext);
|
||||||
|
|
||||||
$gpg = NULL;
|
$gpg = NULL;
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$tmp = false;
|
$tmp = false;
|
||||||
$ret = $gpg -> verify($ret, false, $tmp);
|
$ret = $gpg->verify($ret, false, $tmp);
|
||||||
|
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
var_dump($tmp);
|
var_dump($tmp);
|
||||||
|
@ -38,3 +40,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
string(8) "foo bar
|
string(8) "foo bar
|
||||||
"
|
"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -4,18 +4,20 @@ sign a text with mode SIG_MODE_DETACH
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$gpg -> setsignmode(gnupg::SIG_MODE_DETACH);
|
$gpg->setsignmode(gnupg::SIG_MODE_DETACH);
|
||||||
$gpg -> addsignkey($fingerprint, $passphrase);
|
$gpg->addsignkey($fingerprint, $passphrase);
|
||||||
$ret = $gpg -> sign($plaintext);
|
$ret = $gpg->sign($plaintext);
|
||||||
|
|
||||||
$gpg = NULL;
|
$gpg = NULL;
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$tmp = false;
|
$tmp = false;
|
||||||
$ret = $gpg -> verify($plaintext, $ret);
|
$ret = $gpg->verify($plaintext, $ret);
|
||||||
|
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
var_dump($plaintext);
|
var_dump($plaintext);
|
||||||
|
@ -37,3 +39,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,22 +1,24 @@
|
||||||
--TEST--n
|
--TEST--
|
||||||
sign a text with mode SIG_MODE_DETACH and without armored output
|
sign a text with mode SIG_MODE_DETACH and without armored output
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$gpg -> setarmor(0);
|
$gpg->setarmor(0);
|
||||||
$gpg -> setsignmode(gnupg::SIG_MODE_DETACH);
|
$gpg->setsignmode(gnupg::SIG_MODE_DETACH);
|
||||||
$gpg -> addsignkey($fingerprint, $passphrase);
|
$gpg->addsignkey($fingerprint, $passphrase);
|
||||||
$ret = $gpg -> sign($plaintext);
|
$ret = $gpg->sign($plaintext);
|
||||||
|
|
||||||
$gpg = NULL;
|
$gpg = NULL;
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$tmp = false;
|
$tmp = false;
|
||||||
$ret = $gpg -> verify($plaintext, $ret);
|
$ret = $gpg->verify($plaintext, $ret);
|
||||||
|
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
var_dump($plaintext);
|
var_dump($plaintext);
|
||||||
|
@ -38,3 +40,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,22 +1,24 @@
|
||||||
--TEST--n
|
--TEST--
|
||||||
sign a text with mode SIG_MODE_NORMAL
|
sign a text with mode SIG_MODE_NORMAL
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
$gpg -> setsignmode(gnupg::SIG_MODE_NORMAL);
|
$gpg->setsignmode(gnupg::SIG_MODE_NORMAL);
|
||||||
$gpg -> addsignkey($fingerprint, $passphrase);
|
$gpg->addsignkey($fingerprint, $passphrase);
|
||||||
$ret = $gpg -> sign($plaintext);
|
$ret = $gpg->sign($plaintext);
|
||||||
|
|
||||||
$gpg = NULL;
|
$gpg = NULL;
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
$tmp = false;
|
$tmp = false;
|
||||||
$plaintext = false;
|
$plaintext = false;
|
||||||
$ret = $gpg -> verify($ret, false, $plaintext);
|
$ret = $gpg->verify($ret, false, $plaintext);
|
||||||
|
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
var_dump($plaintext);
|
var_dump($plaintext);
|
||||||
|
@ -38,3 +40,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,23 +1,23 @@
|
||||||
--TEST--n
|
--TEST--
|
||||||
sign a text with mode SIG_MODE_NORMAL and without armored output
|
sign a text with mode SIG_MODE_NORMAL and without armored output
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
$gpg = new gnupg();
|
gnupgt::import_key();
|
||||||
$gpg -> seterrormode(gnupg::ERROR_WARNING);
|
|
||||||
$gpg -> setarmor(0);
|
|
||||||
$gpg -> setsignmode(gnupg::SIG_MODE_NORMAL);
|
|
||||||
$gpg -> addsignkey($fingerprint, $passphrase);
|
|
||||||
$ret = $gpg -> sign($plaintext);
|
|
||||||
|
|
||||||
$gpg = NULL;
|
|
||||||
|
|
||||||
$gpg = new gnupg();
|
$gpg = new gnupg();
|
||||||
//$ret = $gpg -> verify($plaintext, $ret);
|
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||||
|
$gpg->setarmor(0);
|
||||||
|
$gpg->setsignmode(gnupg::SIG_MODE_NORMAL);
|
||||||
|
$gpg->addsignkey($fingerprint, $passphrase);
|
||||||
|
$ret = $gpg->sign($plaintext);
|
||||||
|
|
||||||
|
$gpg = new gnupg();
|
||||||
|
//$ret = $gpg->verify($plaintext, $ret);
|
||||||
$plaintext = false;
|
$plaintext = false;
|
||||||
$ret = $gpg -> verify($ret, false, $plaintext);
|
$ret = $gpg->verify($ret, false, $plaintext);
|
||||||
|
|
||||||
var_dump($ret);
|
var_dump($ret);
|
||||||
var_dump($plaintext);
|
var_dump($plaintext);
|
||||||
|
@ -39,3 +39,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,14 +0,0 @@
|
||||||
--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)
|
|
|
@ -1,10 +1,12 @@
|
||||||
--TEST--n
|
--TEST--
|
||||||
import a new key into the keyring
|
import a new key into the keyring
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
@unlink (dirname(__FILE__)."/pubring.gpg");
|
gnupgt::delete_key();
|
||||||
@unlink (dirname(__FILE__)."/secring.gpg");
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
$ret = gnupg_import($gpg, $testkey);
|
$ret = gnupg_import($gpg, $testkey);
|
||||||
|
@ -31,3 +33,8 @@ array(9) {
|
||||||
["fingerprint"]=>
|
["fingerprint"]=>
|
||||||
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
|
||||||
}
|
}
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
delete a key from the keyring
|
delete a key from the keyring
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
$ret = gnupg_deletekey($gpg, $fingerprint,true);
|
$ret = gnupg_deletekey($gpg, $fingerprint,true);
|
||||||
|
@ -10,3 +14,8 @@ var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
bool(true)
|
bool(true)
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
encrypt and decrypt a text
|
encrypt and decrypt a text
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
gnupg_addencryptkey($gpg, $fingerprint);
|
gnupg_addencryptkey($gpg, $fingerprint);
|
||||||
|
@ -18,3 +22,8 @@ var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
encryptsign and decryptverify a text
|
encryptsign and decryptverify a text
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
gnupg_addencryptkey($gpg, $fingerprint);
|
gnupg_addencryptkey($gpg, $fingerprint);
|
||||||
|
@ -36,3 +40,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
export a key
|
export a key
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
$ret = gnupg_export($gpg, $fingerprint);
|
$ret = gnupg_export($gpg, $fingerprint);
|
||||||
|
@ -10,7 +14,6 @@ var_dump($ret);
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
|
string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||||
Version: GnuPG v1
|
|
||||||
|
|
||||||
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
|
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
|
||||||
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
|
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
|
||||||
|
@ -34,3 +37,8 @@ drhhPQJw1AY6GEpSbK0JtACeJuewK8C1wO1l5OYkGzFpb4VgquI=
|
||||||
=twR+
|
=twR+
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
-----END PGP PUBLIC KEY BLOCK-----
|
||||||
"
|
"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
get keyinfo
|
get keyinfo
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
$ret = gnupg_keyinfo($gpg, $fingerprint);
|
$ret = gnupg_keyinfo($gpg, $fingerprint);
|
||||||
|
@ -97,3 +101,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
list signatures
|
list signatures
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
$ret = gnupg_listsignatures($gpg, $fingerprint);
|
$ret = gnupg_listsignatures($gpg, $fingerprint);
|
||||||
|
@ -33,3 +37,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,16 +1,18 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
sign a text with sigmode SIG_MODE_CLEAR
|
sign a text with sigmode SIG_MODE_CLEAR
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_CLEAR);
|
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_CLEAR);
|
||||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||||
$ret = gnupg_sign($gpg, $plaintext);
|
$ret = gnupg_sign($gpg, $plaintext);
|
||||||
|
|
||||||
$gpg = NULL;
|
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
$tmp = false;
|
$tmp = false;
|
||||||
$ret = gnupg_verify($gpg, $ret, false, $tmp);
|
$ret = gnupg_verify($gpg, $ret, false, $tmp);
|
||||||
|
@ -36,3 +38,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
string(8) "foo bar
|
string(8) "foo bar
|
||||||
"
|
"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,16 +1,18 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
sign a text with mode SIG_MODE_DETACH
|
sign a text with mode SIG_MODE_DETACH
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH);
|
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH);
|
||||||
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
gnupg_addsignkey($gpg, $fingerprint, $passphrase);
|
||||||
$ret = gnupg_sign($gpg, $plaintext);
|
$ret = gnupg_sign($gpg, $plaintext);
|
||||||
|
|
||||||
$gpg = NULL;
|
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
$tmp = false;
|
$tmp = false;
|
||||||
$ret = gnupg_verify($gpg,$plaintext, $ret);
|
$ret = gnupg_verify($gpg,$plaintext, $ret);
|
||||||
|
@ -35,3 +37,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
sign a text with mode SIG_MODE_DETACH and without armored output
|
sign a text with mode SIG_MODE_DETACH and without armored output
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
gnupg_setarmor($gpg, 0);
|
gnupg_setarmor($gpg, 0);
|
||||||
|
@ -36,3 +40,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
sign a text with mode SIG_MODE_NORMAL
|
sign a text with mode SIG_MODE_NORMAL
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL);
|
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL);
|
||||||
|
@ -36,3 +40,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
|
@ -1,8 +1,12 @@
|
||||||
--TEST--n
|
--TEST--n
|
||||||
sign a text with mode SIG_MODE_NORMAL and without armored output
|
sign a text with mode SIG_MODE_NORMAL and without armored output
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once(dirname(__FILE__)."/vars.inc");
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::import_key();
|
||||||
|
|
||||||
$gpg = gnupg_init();
|
$gpg = gnupg_init();
|
||||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||||
gnupg_setarmor($gpg, 0);
|
gnupg_setarmor($gpg, 0);
|
||||||
|
@ -36,3 +40,8 @@ array(1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string(7) "foo bar"
|
string(7) "foo bar"
|
||||||
|
--CLEAN--
|
||||||
|
<?php
|
||||||
|
require_once "gnupgt.inc";
|
||||||
|
gnupgt::delete_key();
|
||||||
|
?>
|
21
tests/gnupgt.inc
Normal file
21
tests/gnupgt.inc
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once __DIR__ . "/vars.inc";
|
||||||
|
|
||||||
|
class gnupgt {
|
||||||
|
static function import_key()
|
||||||
|
{
|
||||||
|
global $testkey;
|
||||||
|
|
||||||
|
self::delete_key();
|
||||||
|
|
||||||
|
$gpg = new gnupg();
|
||||||
|
$gpg->import($testkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function delete_key()
|
||||||
|
{
|
||||||
|
@unlink(__DIR__ . "/pubring.gpg");
|
||||||
|
@unlink(__DIR__ . "/secring.gpg");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue