comparison vendor/pear/crypt_gpg/tests/GetFingerprintTest.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Fingerprint retrieval tests for the Crypt_GPG package.
7 *
8 * These tests require the PHPUnit 3.6 or greater package to be installed.
9 * PHPUnit is installable using PEAR. See the
10 * {@link http://www.phpunit.de/manual/3.6/en/installation.html manual}
11 * for detailed installation instructions.
12 *
13 * To run these tests, use:
14 * <code>
15 * $ phpunit GetFingerprintTestCase
16 * </code>
17 *
18 * LICENSE:
19 *
20 * This library is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as
22 * published by the Free Software Foundation; either version 2.1 of the
23 * License, or (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, see
32 * <http://www.gnu.org/licenses/>
33 *
34 * @category Encryption
35 * @package Crypt_GPG
36 * @author Michael Gauthier <mike@silverorange.com>
37 * @copyright 2005-2008 silverorange
38 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
39 * @version CVS: $Id$
40 * @link http://pear.php.net/package/Crypt_GPG
41 */
42
43 /**
44 * Base test case.
45 */
46 require_once 'TestCase.php';
47
48 /**
49 * Tests fingerprint retrieval of Crypt_GPG.
50 *
51 * @category Encryption
52 * @package Crypt_GPG
53 * @author Michael Gauthier <mike@silverorange.com>
54 * @copyright 2005-2008 silverorange
55 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
56 * @link http://pear.php.net/package/Crypt_GPG
57 */
58 class GetFingerprintTestCase extends Crypt_GPG_TestCase
59 {
60 // {{{ testGetFingerprint()
61
62 /**
63 * @group get-fingerprint
64 */
65 public function testGetFingerprint()
66 {
67 $keyId = 'public-only@example.com';
68 $expectedFingerprint = 'F83118CB6F5892DC1C3E936DABA81EF54E8C0DEB';
69 $fingerprint = $this->gpg->getFingerprint($keyId);
70 $this->assertEquals($expectedFingerprint, $fingerprint);
71 }
72
73 // }}}
74 // {{{ testGetFingerprintNull()
75
76 /**
77 * @group get-fingerprint
78 */
79 public function testGetFingerprintNull()
80 {
81 $keyId = 'non-existent-key@example.com';
82 $fingerprint = $this->gpg->getFingerprint($keyId);
83 $this->assertNull($fingerprint);
84 }
85
86 // }}}
87 // {{{ testGetFingerprintX509()
88
89 /**
90 * @group get-fingerprint
91 */
92 public function testGetFingerprintX509()
93 {
94 $keyId = 'public-only@example.com';
95 $expectedFingerprint =
96 'F8:31:18:CB:6F:58:92:DC:1C:3E:93:6D:AB:A8:1E:F5:4E:8C:0D:EB';
97
98 $fingerprint = $this->gpg->getFingerprint($keyId,
99 Crypt_GPG::FORMAT_X509);
100
101 $this->assertEquals($expectedFingerprint, $fingerprint);
102 }
103
104 // }}}
105 // {{{ testGetFingerprintCanonical()
106
107 /**
108 * @group get-fingerprint
109 */
110 public function testGetFingerprintCanonical()
111 {
112 $keyId = 'public-only@example.com';
113 $expectedFingerprint =
114 'F831 18CB 6F58 92DC 1C3E 936D ABA8 1EF5 4E8C 0DEB';
115
116 $fingerprint = $this->gpg->getFingerprint($keyId,
117 Crypt_GPG::FORMAT_CANONICAL);
118
119 $this->assertEquals($expectedFingerprint, $fingerprint);
120 }
121
122 // }}}
123 }
124
125 ?>