mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-12-22 18:01:40 +00:00
Fix tests with gpg2
This commit is contained in:
parent
a32dc2f988
commit
75a9b387ea
4 changed files with 45 additions and 11 deletions
|
@ -5,7 +5,7 @@ import a new key into the keyring
|
|||
--FILE--
|
||||
<?php
|
||||
require_once "gnupgt.inc";
|
||||
gnupgt::delete_key();
|
||||
gnupgt::reset_key();
|
||||
|
||||
$gpg = new gnupg();
|
||||
$gpg->seterrormode(gnupg::ERROR_WARNING);
|
||||
|
|
|
@ -5,7 +5,7 @@ import a new key into the keyring
|
|||
--FILE--
|
||||
<?php
|
||||
require_once "gnupgt.inc";
|
||||
gnupgt::delete_key();
|
||||
gnupgt::reset_key();
|
||||
|
||||
$gpg = gnupg_init();
|
||||
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
|
||||
|
|
|
@ -10,7 +10,7 @@ class gnupgt {
|
|||
{
|
||||
global $testkey;
|
||||
|
||||
self::delete_key();
|
||||
self::reset_key();
|
||||
|
||||
$gpg = new gnupg();
|
||||
$gpg->import($testkey);
|
||||
|
@ -21,21 +21,55 @@ class gnupgt {
|
|||
*/
|
||||
static public function delete_key()
|
||||
{
|
||||
@unlink(__DIR__ . "/pubring.gpg");
|
||||
@unlink(__DIR__ . "/secring.gpg");
|
||||
@unlink(__DIR__ . "/pubring.kbx");
|
||||
@unlink(__DIR__ . "/random_seed");
|
||||
@unlink(__DIR__ . "/sshcontrol");
|
||||
@unlink(__DIR__ . "/trustdb.gpg");
|
||||
$privKeyDir = __DIR__ . '/private-keys-v1.d';
|
||||
$homeDir = self::get_home_dir();
|
||||
if (!is_dir($homeDir)) {
|
||||
return;
|
||||
}
|
||||
@unlink("$homeDir/pubring.gpg");
|
||||
@unlink("$homeDir/secring.gpg");
|
||||
@unlink("$homeDir/pubring.kbx");
|
||||
@unlink("$homeDir/pubring.kbx~");
|
||||
@unlink("$homeDir/random_seed");
|
||||
@unlink("$homeDir/sshcontrol");
|
||||
@unlink("$homeDir/trustdb.gpg");
|
||||
$privKeyDir = self::get_priv_key_dir();
|
||||
if (is_dir($privKeyDir)) {
|
||||
foreach (glob($privKeyDir . '/*.key') as $key) {
|
||||
unlink($key);
|
||||
}
|
||||
rmdir($privKeyDir);
|
||||
}
|
||||
rmdir($homeDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize key directory.
|
||||
*/
|
||||
static public function init_key_dir()
|
||||
{
|
||||
mkdir(self::get_home_dir());
|
||||
mkdir(self::get_priv_key_dir(), 0700);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset all keys.
|
||||
*/
|
||||
static public function reset_key()
|
||||
{
|
||||
self::delete_key();
|
||||
self::init_key_dir();
|
||||
}
|
||||
|
||||
static private function get_home_dir()
|
||||
{
|
||||
return __DIR__ . '/home';
|
||||
}
|
||||
|
||||
static private function get_priv_key_dir()
|
||||
{
|
||||
return self::get_home_dir() . '/private-keys-v1.d';
|
||||
}
|
||||
|
||||
/**
|
||||
* Print error message and return false.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
putenv("GNUPGHOME=".dirname(__FILE__));
|
||||
putenv("GNUPGHOME=".dirname(__FILE__) . '/home');
|
||||
error_reporting (E_ALL);
|
||||
$fingerprint = "2DF0DD02DC9B70B7F64F572E669E775E0A6284B3";
|
||||
$passphrase = "blabla";
|
||||
|
|
Loading…
Reference in a new issue