mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-24 15:27:08 +00:00
Test secret_only param in keyinfo
This commit is contained in:
parent
d93d6ea80d
commit
7c040788ad
3 changed files with 65 additions and 103 deletions
|
@ -9,57 +9,10 @@ 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, true);
|
||||||
gnupgt::check_array(false, $ret, 0, 'disabled');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'expired');
|
gnupgt::check_keyinfo($gpg->keyinfo($fingerprint), false);
|
||||||
gnupgt::check_array(false, $ret, 0, 'revoked');
|
gnupgt::check_keyinfo($gpg->keyinfo($fingerprint, true), true);
|
||||||
gnupgt::check_array(false, $ret, 0, 'is_secret');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'can_sign');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'can_encrypt');
|
|
||||||
// uid
|
|
||||||
gnupgt::check_array('testkey', $ret, 0, 'uids', 0, 'name');
|
|
||||||
gnupgt::check_array('testkey', $ret, 0, 'uids', 0, 'comment');
|
|
||||||
gnupgt::check_array('test@example.net', $ret, 0, 'uids', 0, 'email');
|
|
||||||
gnupgt::check_array('testkey (testkey) <test@example.net>', $ret, 0, 'uids', 0, 'uid');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'uids', 0, 'revoked');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'uids', 0, 'invalid');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'uids', 0, 'invalid');
|
|
||||||
// subkey 1
|
|
||||||
gnupgt::check_array("64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E", $ret, 0, 'subkeys', 0, 'fingerprint');
|
|
||||||
gnupgt::check_array("2E96F141B3DD2B2E", $ret, 0, 'subkeys', 0, 'keyid');
|
|
||||||
gnupgt::check_array(1129316524, $ret, 0, 'subkeys', 0, 'timestamp');
|
|
||||||
gnupgt::check_array(0, $ret, 0, 'subkeys', 0, 'expires');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'is_secret');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'can_encrypt');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'subkeys', 0, 'can_sign');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'disabled');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'expired');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'revoked');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'subkeys', 0, 'can_certify');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'can_authenticate');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'is_qualified');
|
|
||||||
gnupgt::check_array_from_version('1.9.0', false, $ret, 0, 'subkeys', 0, 'is_de_vs');
|
|
||||||
gnupgt::check_array(GNUPG_PK_DSA, $ret, 0, 'subkeys', 0, 'pubkey_algo');
|
|
||||||
gnupgt::check_array(1024, $ret, 0, 'subkeys', 0, 'length');
|
|
||||||
gnupgt::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 0, 'is_cardkey');
|
|
||||||
// subkey 2
|
|
||||||
gnupgt::check_array("A3437D3651E27CF9864198F0BFE8D07DDACDEAC8", $ret, 0, 'subkeys', 1, 'fingerprint');
|
|
||||||
gnupgt::check_array("BFE8D07DDACDEAC8", $ret, 0, 'subkeys', 1, 'keyid');
|
|
||||||
gnupgt::check_array(1129316525, $ret, 0, 'subkeys', 1, 'timestamp');
|
|
||||||
gnupgt::check_array(0, $ret, 0, 'subkeys', 1, 'expires');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'is_secret');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'subkeys', 1, 'can_encrypt');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'can_sign');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'disabled');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'expired');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'revoked');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'can_certify');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'can_authenticate');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'is_qualified');
|
|
||||||
gnupgt::check_array_from_version('1.9.0', false, $ret, 0, 'subkeys', 1, 'is_de_vs');
|
|
||||||
gnupgt::check_array(GNUPG_PK_ELG_E, $ret, 0, 'subkeys', 1, 'pubkey_algo');
|
|
||||||
gnupgt::check_array(1024, $ret, 0, 'subkeys', 1, 'length');
|
|
||||||
gnupgt::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 1, 'is_cardkey');
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -10,58 +10,8 @@ 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);
|
||||||
|
gnupgt::check_keyinfo(gnupg_keyinfo($gpg, $fingerprint), false);
|
||||||
|
gnupgt::check_keyinfo(gnupg_keyinfo($gpg, $fingerprint, true), true);
|
||||||
gnupgt::check_array(false, $ret, 0, 'disabled');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'expired');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'revoked');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'is_secret');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'can_sign');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'can_encrypt');
|
|
||||||
// uid
|
|
||||||
gnupgt::check_array('testkey', $ret, 0, 'uids', 0, 'name');
|
|
||||||
gnupgt::check_array('testkey', $ret, 0, 'uids', 0, 'comment');
|
|
||||||
gnupgt::check_array('test@example.net', $ret, 0, 'uids', 0, 'email');
|
|
||||||
gnupgt::check_array('testkey (testkey) <test@example.net>', $ret, 0, 'uids', 0, 'uid');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'uids', 0, 'revoked');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'uids', 0, 'invalid');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'uids', 0, 'invalid');
|
|
||||||
// subkey 1
|
|
||||||
gnupgt::check_array("64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E", $ret, 0, 'subkeys', 0, 'fingerprint');
|
|
||||||
gnupgt::check_array("2E96F141B3DD2B2E", $ret, 0, 'subkeys', 0, 'keyid');
|
|
||||||
gnupgt::check_array(1129316524, $ret, 0, 'subkeys', 0, 'timestamp');
|
|
||||||
gnupgt::check_array(0, $ret, 0, 'subkeys', 0, 'expires');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'is_secret');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'can_encrypt');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'subkeys', 0, 'can_sign');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'disabled');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'expired');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'revoked');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'subkeys', 0, 'can_certify');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'can_authenticate');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 0, 'is_qualified');
|
|
||||||
gnupgt::check_array_from_version('1.9.0', false, $ret, 0, 'subkeys', 0, 'is_de_vs');
|
|
||||||
gnupgt::check_array(GNUPG_PK_DSA, $ret, 0, 'subkeys', 0, 'pubkey_algo');
|
|
||||||
gnupgt::check_array(1024, $ret, 0, 'subkeys', 0, 'length');
|
|
||||||
gnupgt::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 0, 'is_cardkey');
|
|
||||||
// subkey 2
|
|
||||||
gnupgt::check_array("A3437D3651E27CF9864198F0BFE8D07DDACDEAC8", $ret, 0, 'subkeys', 1, 'fingerprint');
|
|
||||||
gnupgt::check_array("BFE8D07DDACDEAC8", $ret, 0, 'subkeys', 1, 'keyid');
|
|
||||||
gnupgt::check_array(1129316525, $ret, 0, 'subkeys', 1, 'timestamp');
|
|
||||||
gnupgt::check_array(0, $ret, 0, 'subkeys', 1, 'expires');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'is_secret');
|
|
||||||
gnupgt::check_array(true, $ret, 0, 'subkeys', 1, 'can_encrypt');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'can_sign');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'disabled');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'expired');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'revoked');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'can_certify');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'can_authenticate');
|
|
||||||
gnupgt::check_array(false, $ret, 0, 'subkeys', 1, 'is_qualified');
|
|
||||||
gnupgt::check_array_from_version('1.9.0', false, $ret, 0, 'subkeys', 1, 'is_de_vs');
|
|
||||||
gnupgt::check_array(GNUPG_PK_ELG_E, $ret, 0, 'subkeys', 1, 'pubkey_algo');
|
|
||||||
gnupgt::check_array(1024, $ret, 0, 'subkeys', 1, 'length');
|
|
||||||
gnupgt::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 1, 'is_cardkey');
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -99,4 +99,63 @@ class gnupgt {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
return call_user_func_array('gnupgt::check_array', array_splice($args, 1));
|
return call_user_func_array('gnupgt::check_array', array_splice($args, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check keyinfo for var key
|
||||||
|
*
|
||||||
|
* @param $ret
|
||||||
|
* @param $secret_only
|
||||||
|
*/
|
||||||
|
static public function check_keyinfo($ret, $secret_only) {
|
||||||
|
self::check_array(false, $ret, 0, 'disabled');
|
||||||
|
self::check_array(false, $ret, 0, 'expired');
|
||||||
|
self::check_array(false, $ret, 0, 'revoked');
|
||||||
|
self::check_array($secret_only, $ret, 0, 'is_secret');
|
||||||
|
self::check_array(true, $ret, 0, 'can_sign');
|
||||||
|
self::check_array(true, $ret, 0, 'can_encrypt');
|
||||||
|
// uid
|
||||||
|
self::check_array('testkey', $ret, 0, 'uids', 0, 'name');
|
||||||
|
self::check_array('testkey', $ret, 0, 'uids', 0, 'comment');
|
||||||
|
self::check_array('test@example.net', $ret, 0, 'uids', 0, 'email');
|
||||||
|
self::check_array('testkey (testkey) <test@example.net>', $ret, 0, 'uids', 0, 'uid');
|
||||||
|
self::check_array(false, $ret, 0, 'uids', 0, 'revoked');
|
||||||
|
self::check_array(false, $ret, 0, 'uids', 0, 'invalid');
|
||||||
|
self::check_array(false, $ret, 0, 'uids', 0, 'invalid');
|
||||||
|
// subkey 1
|
||||||
|
self::check_array("64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E", $ret, 0, 'subkeys', 0, 'fingerprint');
|
||||||
|
self::check_array("2E96F141B3DD2B2E", $ret, 0, 'subkeys', 0, 'keyid');
|
||||||
|
self::check_array(1129316524, $ret, 0, 'subkeys', 0, 'timestamp');
|
||||||
|
self::check_array(0, $ret, 0, 'subkeys', 0, 'expires');
|
||||||
|
self::check_array($secret_only, $ret, 0, 'subkeys', 0, 'is_secret');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 0, 'can_encrypt');
|
||||||
|
self::check_array(true, $ret, 0, 'subkeys', 0, 'can_sign');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 0, 'disabled');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 0, 'expired');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 0, 'revoked');
|
||||||
|
self::check_array(true, $ret, 0, 'subkeys', 0, 'can_certify');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 0, 'can_authenticate');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 0, 'is_qualified');
|
||||||
|
self::check_array_from_version('1.9.0', false, $ret, 0, 'subkeys', 0, 'is_de_vs');
|
||||||
|
self::check_array(GNUPG_PK_DSA, $ret, 0, 'subkeys', 0, 'pubkey_algo');
|
||||||
|
self::check_array(1024, $ret, 0, 'subkeys', 0, 'length');
|
||||||
|
self::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 0, 'is_cardkey');
|
||||||
|
// subkey 2
|
||||||
|
self::check_array("A3437D3651E27CF9864198F0BFE8D07DDACDEAC8", $ret, 0, 'subkeys', 1, 'fingerprint');
|
||||||
|
self::check_array("BFE8D07DDACDEAC8", $ret, 0, 'subkeys', 1, 'keyid');
|
||||||
|
self::check_array(1129316525, $ret, 0, 'subkeys', 1, 'timestamp');
|
||||||
|
self::check_array(0, $ret, 0, 'subkeys', 1, 'expires');
|
||||||
|
self::check_array($secret_only, $ret, 0, 'subkeys', 1, 'is_secret');
|
||||||
|
self::check_array(true, $ret, 0, 'subkeys', 1, 'can_encrypt');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 1, 'can_sign');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 1, 'disabled');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 1, 'expired');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 1, 'revoked');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 1, 'can_certify');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 1, 'can_authenticate');
|
||||||
|
self::check_array(false, $ret, 0, 'subkeys', 1, 'is_qualified');
|
||||||
|
self::check_array_from_version('1.9.0', false, $ret, 0, 'subkeys', 1, 'is_de_vs');
|
||||||
|
self::check_array(GNUPG_PK_ELG_E, $ret, 0, 'subkeys', 1, 'pubkey_algo');
|
||||||
|
self::check_array(1024, $ret, 0, 'subkeys', 1, 'length');
|
||||||
|
self::check_array_from_version('1.7.0', false, $ret, 0, 'subkeys', 1, 'is_cardkey');
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue