annotate vendor/pear/crypt_gpg/tests/KeyGeneratorTest.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1 <?php
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
5 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
6 * Key generation tests for the Crypt_GPG package.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
7 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
8 * These tests require the PHPUnit 3.6 or greater package to be installed.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 * PHPUnit is installable using PEAR. See the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 * {@link http://www.phpunit.de/manual/3.6/en/installation.html manual}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 * for detailed installation instructions.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
12 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
13 * To run these tests, use:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14 * <code>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
15 * $ phpunit KeyGeneratorTestCase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16 * </code>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 * LICENSE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 * This library is free software; you can redistribute it and/or modify
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 * it under the terms of the GNU Lesser General Public License as
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22 * published by the Free Software Foundation; either version 2.1 of the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
23 * License, or (at your option) any later version.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 * This library is distributed in the hope that it will be useful,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 * Lesser General Public License for more details.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 * You should have received a copy of the GNU Lesser General Public
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 * License along with this library; if not, see
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32 * <http://www.gnu.org/licenses/>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
35 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
37 * @copyright 2005-2011 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
38 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
39 * @version CVS: $Id: GetKeysTestCase.php 274158 2009-01-22 06:33:54Z gauthierm $
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
40 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
41 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
42
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
43 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44 * Base test case.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46 require_once 'TestCase.php';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
47
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
48 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
49 * The Crypt_GPG class to test
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
50 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 require_once 'Crypt/GPG/KeyGenerator.php';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
53 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
54 * Tests key generation of Crypt_GPG.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
56 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
57 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59 * @copyright 2005-2011 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
60 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
61 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
62 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 class KeyGeneratorTestCase extends Crypt_GPG_TestCase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
64 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 // helper methods
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
66 // {{{ assertKeyEquals()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
67
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 protected function assertKeyEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 Crypt_GPG_Key $key1,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
70 Crypt_GPG_Key $key2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
71 ) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
72 $userIds1 = $key1->getUserIds();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
73 $userIds2 = $key2->getUserIds();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
74 $userId1 = $userIds1[0];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
75 $userId2 = $userIds2[0];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
76 $subKeys1 = $key1->getSubKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
77 $subKeys2 = $key2->getSubKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
78 $subKeyA1 = $subKeys1[0];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
79 $subKeyB1 = $subKeys1[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
80 $subKeyA2 = $subKeys2[0];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
81 $subKeyB2 = $subKeys2[1];
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
82
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
84 $userId1->getName(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
85 $userId2->getName(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
86 'User id names do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
90 $userId1->getEmail(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
91 $userId2->getEmail(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 'User id email addresses do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
95 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96 $userId1->getComment(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97 $userId2->getComment(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
98 'User id comments do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
99 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
100
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
101 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
102 $subKeyA1->getAlgorithm(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103 $subKeyA2->getAlgorithm(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
104 'Primary key algorithms do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
105 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 $subKeyA1->getLength(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109 $subKeyA2->getLength(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
110 'Primary key lengths do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
111 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
113 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
114 $subKeyA1->getExpirationDate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
115 $subKeyA2->getExpirationDate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
116 'Primary key expiration dates do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
118
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
120 $subKeyA1->canSign(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
121 $subKeyA2->canSign(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 'Primary key signing abilities do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
123 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
124
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
125 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
126 $subKeyA1->canEncrypt(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
127 $subKeyA2->canEncrypt(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 'Primary key encrypting abilities do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
132 $subKeyA1->hasPrivate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
133 $subKeyA2->hasPrivate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
134 'Primary key private keys do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
135 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
137 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138 $subKeyB1->getAlgorithm(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139 $subKeyB2->getAlgorithm(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 'Secondary key algorithms do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 $subKeyB1->getLength(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145 $subKeyB2->getLength(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 'Secondary key lengths do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
148
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
149 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 $subKeyB1->getExpirationDate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151 $subKeyB2->getExpirationDate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152 'Secondary key expiration dates do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
155 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 $subKeyB1->canSign(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 $subKeyB2->canSign(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158 'Secondary key signing abilities do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162 $subKeyB1->canEncrypt(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163 $subKeyB2->canEncrypt(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 'Secondary key encrypting abilities do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168 $subKeyB1->hasPrivate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169 $subKeyB2->hasPrivate(),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 'Secondary key private keys do not match.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
174 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
175 // {{{ setUp()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
176
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
177 public function setUp()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
178 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
179 parent::setUp();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
180 $this->generator = new Crypt_GPG_KeyGenerator($this->getOptions());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 // mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
186 // {{{ testSetExpirationDate_zero()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 public function testSetExpirationDate_zero()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 $expectedDate = 0;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194 $this->generator->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197 $expectedDate,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 'expirationDate',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 'Setting expiration date to zero failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
201 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 // {{{ testSetExpirationDate_integer()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
207 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
210 public function testSetExpirationDate_integer()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
211 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212 $expectedDate = 2000000000;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
213 $this->generator->setExpirationDate(2000000000);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
215 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
216 $expectedDate,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
217 'expirationDate',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
218 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 'Setting expiration date by integer failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
220 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
221 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
222
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
223 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
224 // {{{ testSetExpirationDate_string()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
227 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
228 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
229 public function testSetExpirationDate_string()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
230 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
231 date_default_timezone_set('UTC');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
232
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 $expectedDate = 2000000000;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
234 $this->generator->setExpirationDate('2033-05-18T03:33:20');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
237 $expectedDate,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
238 'expirationDate',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240 'Setting expiration date by string failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
243
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
244 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
245 // {{{ testSetExpirationDate_invalid_format()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
246
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
249 * @expectedException InvalidArgumentException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
250 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251 public function testSetExpirationDate_invalid_format()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
253 date_default_timezone_set('UTC');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255 $this->generator->setExpirationDate('this is not a date');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
257
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
258 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
259 // {{{ testSetExpirationDate_too_early_date()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 * @expectedException InvalidArgumentException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
264 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
265 public function testSetExpirationDate_too_early_date()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
266 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
267 $this->generator->setExpirationDate(1301088055);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
268 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
269
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
270 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
271 // {{{ testSetExpirationDate_today()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
272
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
273 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
274 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
275 * @expectedException InvalidArgumentException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
276 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277 public function testSetExpirationDate_today()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279 $this->generator->setExpirationDate(time());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
283 // {{{ testSetExpirationDate_too_late_date()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
284
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
285 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287 * @expectedException InvalidArgumentException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289 public function testSetExpirationDate_too_late_date()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
290 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
291 $this->generator->setExpirationDate(2147483648);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
292 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
293
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
295 // {{{ testSetPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
296
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
299 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
300 public function testSetPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
301 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 $expectedPassphrase = 'test1';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303 $this->generator->setPassphrase('test1');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 $expectedPassphrase,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307 'passphrase',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 'Setting passphrase failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
313 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
314 // {{{ testSetKeyParams_algorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
316 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
317 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 public function testSetKeyParams_algorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 $expectedAlgorithm = Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
322 $expectedSize = 1024;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
323 $expectedUsage = Crypt_GPG_SubKey::USAGE_SIGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
324 | Crypt_GPG_SubKey::USAGE_CERTIFY;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
325
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 $this->generator->setKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327 Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
329
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
330 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 $expectedAlgorithm,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332 'keyAlgorithm',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334 'Setting key algorithm failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338 $expectedSize,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339 'keySize',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
340 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
341 'Setting key algorithm changed key size.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
343
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
344 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
345 $expectedUsage,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 'keyUsage',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 'Setting key algorithm changed key usage.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 // {{{ testSetKeyParams_algorithm_and_size()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358 public function testSetKeyParams_algorithm_and_size()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
359 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
360 $expectedAlgorithm = Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
361 $expectedSize = 512;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
362 $expectedUsage = Crypt_GPG_SubKey::USAGE_SIGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
363 | Crypt_GPG_SubKey::USAGE_CERTIFY;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
364
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
365 $this->generator->setKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
366 Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
367 512
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
371 $expectedAlgorithm,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
372 'keyAlgorithm',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
373 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374 'Setting key algorithm failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
375 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
376
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
377 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
378 $expectedSize,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
379 'keySize',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
380 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
381 'Setting key size failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
382 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
383
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
384 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
385 $expectedUsage,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
386 'keyUsage',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
387 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
388 'Setting key algorithm and size changed key usage.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
389 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
390 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
391
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
392 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
393 // {{{ testSetKeyParams_algorithm_size_and_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
394
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
395 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
396 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
397 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
398 public function testSetKeyParams_algorithm_size_and_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
399 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
400 $expectedAlgorithm = Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
401 $expectedSize = 512;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
402 $expectedUsage = Crypt_GPG_SubKey::USAGE_SIGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
403 | Crypt_GPG_SubKey::USAGE_CERTIFY
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
404 | Crypt_GPG_SubKey::USAGE_ENCRYPT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
405
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
406 $this->generator->setKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
407 Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
408 512,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
409 Crypt_GPG_SubKey::USAGE_SIGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
410 | Crypt_GPG_SubKey::USAGE_CERTIFY
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
411 | Crypt_GPG_SubKey::USAGE_ENCRYPT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
412 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
413
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
414 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
415 $expectedAlgorithm,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
416 'keyAlgorithm',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
417 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
418 'Setting key algorithm failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
419 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
420
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
421 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
422 $expectedSize,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
423 'keySize',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
424 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
425 'Setting key size failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
426 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
427
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
428 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
429 $expectedUsage,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
430 'keyUsage',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
431 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
432 'Setting key usage failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
433 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
434 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
435
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
436 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
437 // {{{ testSetKeyParams_invalid_algorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
438
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
439 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
440 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
441 * @expectedException Crypt_GPG_InvalidKeyParamsException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
442 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
443 public function testSetKeyParams_invalid_algorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
444 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
445 $this->generator->setKeyParams(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
446 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
447
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
448 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
449 // {{{ testSetKeyParams_invalid_dsa_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
450
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
451 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
452 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
453 * @expectedException Crypt_GPG_InvalidKeyParamsException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
454 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
455 public function testSetKeyParams_invalid_dsa_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
456 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
457 $this->generator->setKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
458 Crypt_GPG_SubKey::ALGORITHM_DSA,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
459 2048,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
460 Crypt_GPG_SubKey::USAGE_ENCRYPT | Crypt_GPG_SubKey::USAGE_CERTIFY
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
461 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
462 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
463
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
464 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
465 // {{{ testSetSubKeyParams_algorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
466
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
467 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
468 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
469 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
470 public function testSetSubKeyParams_algorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
471 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
472 $expectedAlgorithm = Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
473 $expectedSize = 2048;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
474 $expectedUsage = Crypt_GPG_SubKey::USAGE_ENCRYPT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
475
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
476 $this->generator->setSubKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
477 Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
478 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
479
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
480 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
481 $expectedAlgorithm,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
482 'subKeyAlgorithm',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
483 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
484 'Setting sub-key algorithm failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
485 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
486
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
487 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
488 $expectedSize,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
489 'subKeySize',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
490 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
491 'Setting sub-key algorithm changed key size.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495 $expectedUsage,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
496 'subKeyUsage',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
497 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
498 'Setting sub-key algorithm changed key usage.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
499 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
502 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503 // {{{ testSetSubKeyParams_algorithm_and_size()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
504
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
506 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
507 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
508 public function testSetSubKeyParams_algorithm_and_size()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
509 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
510 $expectedAlgorithm = Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
511 $expectedSize = 1024;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
512 $expectedUsage = Crypt_GPG_SubKey::USAGE_ENCRYPT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
513
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
514 $this->generator->setSubKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
515 Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
516 1024
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
517 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
518
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
519 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
520 $expectedAlgorithm,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
521 'subKeyAlgorithm',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
522 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
523 'Setting sub-key algorithm failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
524 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
525
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
526 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
527 $expectedSize,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
528 'subKeySize',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
529 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
530 'Setting sub-key size failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
531 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
532
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
533 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
534 $expectedUsage,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535 'subKeyUsage',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
536 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
537 'Setting sub-key algorithm and size changed key usage.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
538 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
540
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
541 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
542 // {{{ testSetSubKeyParams_algorithm_size_and_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
543
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
545 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
546 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
547 public function testSetSubKeyParams_algorithm_size_and_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
548 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
549 $expectedAlgorithm = Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
550 $expectedSize = 1024;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
551 $expectedUsage = Crypt_GPG_SubKey::USAGE_SIGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
552 | Crypt_GPG_SubKey::USAGE_ENCRYPT;
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
553
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
554 $this->generator->setSubKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
555 Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
556 1024,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
557 Crypt_GPG_SubKey::USAGE_SIGN
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
558 | Crypt_GPG_SubKey::USAGE_ENCRYPT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
559 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
560
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
561 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
562 $expectedAlgorithm,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
563 'subKeyAlgorithm',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
564 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
565 'Setting sub-key algorithm failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
566 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
567
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
568 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
569 $expectedSize,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
570 'subKeySize',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
571 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
572 'Setting sub-key size failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
573 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
574
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
575 $this->assertAttributeEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
576 $expectedUsage,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
577 'subKeyUsage',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
578 $this->generator,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
579 'Setting sub-key usage failed.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
580 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
581 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
582
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
583 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
584 // {{{ testSetSubKeyParams_invalid_elgamal_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
585
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
586 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
587 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
588 * @expectedException Crypt_GPG_InvalidKeyParamsException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
589 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
590 public function testSetSubKeyParams_invalid_elgamal_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
591 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
592 $this->generator->setSubKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
593 Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
594 2048,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
595 Crypt_GPG_SubKey::USAGE_SIGN | Crypt_GPG_SubKey::USAGE_ENCRYPT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
596 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
597 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
598
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
599 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
600 // {{{ testSetSubKeyParams_invalid_dsa_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
601
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
602 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
603 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
604 * @expectedException Crypt_GPG_InvalidKeyParamsException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
605 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
606 public function testSetSubKeyParams_invalid_dsa_usage()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
607 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
608 $this->generator->setSubKeyParams(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
609 Crypt_GPG_SubKey::ALGORITHM_DSA,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
610 2048,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
611 Crypt_GPG_SubKey::USAGE_SIGN | Crypt_GPG_SubKey::USAGE_ENCRYPT
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
612 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
613 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
614
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
615 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
616
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
617 // generate key tests
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
618 // {{{ testGenerateKeyWithName()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
619
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
620 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
621 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
622 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
623 public function testGenerateKeyWithName()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
624 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
625 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
626 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
627 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
628 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
629 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
630 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
631 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
632
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
633 // {{{ generate-test@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
634 $expectedKey = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
635
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
636 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
637 $userId->setName('Test Keypair');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
638 $expectedKey->addUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
639
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
640 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
641 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_DSA);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
642 $subKey->setLength(1024);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
643 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
644 $subKey->setCanSign(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
645 $subKey->setCanEncrypt(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
646 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
647 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
648
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
649 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
650 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
651 $subKey->setLength(2048);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
652 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
653 $subKey->setCanSign(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
654 $subKey->setCanEncrypt(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
655 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
656 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
657 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
658
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
659 $key = $this->generator->generateKey('Test Keypair');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
660
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
661 $this->assertKeyEquals($expectedKey, $key);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
662 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
663
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
664 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
665 // {{{ testGenerateKeyWithNameAndEmail()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
666
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
667 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
668 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
669 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
670 public function testGenerateKeyWithNameAndEmail()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
671 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
672 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
673 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
674 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
675 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
676 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
677 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
678 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
679
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
680 // {{{ generate-test@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
681 $expectedKey = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
682
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
683 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
684 $userId->setName('Test Keypair');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
685 $userId->setEmail('generate-test@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
686 $expectedKey->addUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
687
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
688 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
689 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_DSA);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
690 $subKey->setLength(1024);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
691 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
692 $subKey->setCanSign(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
693 $subKey->setCanEncrypt(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
694 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
695 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
696
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
697 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
698 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
699 $subKey->setLength(2048);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
700 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
701 $subKey->setCanSign(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
702 $subKey->setCanEncrypt(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
703 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
704 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
705 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
706
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
707 $key = $this->generator->generateKey(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
708 'Test Keypair',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
709 'generate-test@example.com'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
710 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
711
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
712 $this->assertKeyEquals($expectedKey, $key);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
713 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
714
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
715 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
716 // {{{ testGenerateKeyWithNameEmailAndComment()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
717
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
718 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
719 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
720 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
721 public function testGenerateKeyWithNameEmailAndComment()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
722 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
723 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
724 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
725 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
726 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
727 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
728 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
729 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
730
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
731 // {{{ generate-test@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
732 $expectedKey = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
733
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
734 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
735 $userId->setName('Test Keypair');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
736 $userId->setComment('do not use this key');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
737 $userId->setEmail('generate-test@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
738 $expectedKey->addUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
739
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
740 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
741 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_DSA);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
742 $subKey->setLength(1024);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
743 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
744 $subKey->setCanSign(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
745 $subKey->setCanEncrypt(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
746 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
747 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
748
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
749 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
750 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
751 $subKey->setLength(2048);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
752 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
753 $subKey->setCanSign(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
754 $subKey->setCanEncrypt(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
755 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
756 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
757 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
758
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
759 $key = $this->generator->generateKey(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
760 'Test Keypair',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
761 'generate-test@example.com',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
762 'do not use this key'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
763 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
764
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
765 $this->assertKeyEquals($expectedKey, $key);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
766 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
767
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
768 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
769 // {{{ testGenerateKeyWithUserId()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
770
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
771 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
772 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
773 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
774 public function testGenerateKeyWithUserId()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
775 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
776 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
777 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
778 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
779 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
780 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
781 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
782 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
783
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
784 // {{{ generate-test@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
785 $expectedKey = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
786
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
787 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
788 $userId->setName('Test Keypair');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
789 $userId->setEmail('generate-test@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
790 $expectedKey->addUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
791
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
792 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
793 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_DSA);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
794 $subKey->setLength(1024);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
795 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
796 $subKey->setCanSign(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
797 $subKey->setCanEncrypt(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
798 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
799 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
800
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
801 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
802 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
803 $subKey->setLength(2048);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
804 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
805 $subKey->setCanSign(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
806 $subKey->setCanEncrypt(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
807 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
808 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
809 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
810
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
811 $key = $this->generator->generateKey(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
812 new Crypt_GPG_UserId(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
813 'Test Keypair <generate-test@example.com>'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
814 )
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
815 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
816
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
817 $this->assertKeyEquals($expectedKey, $key);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
818 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
819
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
820 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
821 // {{{ testGenerateKeyWithPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
822
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
823 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
824 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
825 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
826 public function testGenerateKeyWithPassphrase()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
827 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
828 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
829 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
830 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
831 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
832 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
833 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
834 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
835
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
836 // {{{ generate-test@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
837 $expectedKey = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
838
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
839 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
840 $userId->setName('Test Keypair');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
841 $userId->setEmail('generate-test@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
842 $expectedKey->addUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
843
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
844 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
845 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_DSA);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
846 $subKey->setLength(1024);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
847 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
848 $subKey->setCanSign(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
849 $subKey->setCanEncrypt(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
850 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
851 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
852
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
853 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
854 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
855 $subKey->setLength(2048);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
856 $subKey->setExpirationDate(0);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
857 $subKey->setCanSign(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
858 $subKey->setCanEncrypt(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
859 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
860 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
861 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
862
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
863 $key = $this->generator->setPassphrase('test1')->generateKey(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
864 new Crypt_GPG_UserId(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
865 'Test Keypair <generate-test@example.com>'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
866 )
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
867 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
868
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
869 $this->assertKeyEquals($expectedKey, $key);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
870 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
871
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
872 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
873 // {{{ testGenerateKeyWithExpirationDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
874
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
875 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
876 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
877 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
878 public function testGenerateKeyWithExpirationDate()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
879 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
880 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
881 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
882 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
883 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
884 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
885 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
886 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
887
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
888 // {{{ generate-test@example.com
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
889 $expectedKey = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
890
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
891 $userId = new Crypt_GPG_UserId();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
892 $userId->setName('Test Keypair');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
893 $userId->setEmail('generate-test@example.com');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
894 $expectedKey->addUserId($userId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
895
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
896 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
897 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_DSA);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
898 $subKey->setLength(1024);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
899 $subKey->setExpirationDate(1999998000); // truncated to day
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
900 $subKey->setCanSign(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
901 $subKey->setCanEncrypt(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
902 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
903 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
904
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
905 $subKey = new Crypt_GPG_SubKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
906 $subKey->setAlgorithm(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
907 $subKey->setLength(2048);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
908 $subKey->setExpirationDate(1999998000); // truncated to day
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
909 $subKey->setCanSign(false);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
910 $subKey->setCanEncrypt(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
911 $subKey->setHasPrivate(true);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
912 $expectedKey->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
913 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
914
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
915 $key = $this->generator->setExpirationDate(2000000000)->generateKey(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
916 new Crypt_GPG_UserId(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
917 'Test Keypair <generate-test@example.com>'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
918 )
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
919 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
920
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
921 // @TODO: I've got difference in expiration dates here
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
922
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
923 $this->assertKeyEquals($expectedKey, $key);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
924 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
925
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
926 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
927 // {{{ testGenerateKeyWithInvalidPrimaryKeyAlgorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
928
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
929 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
930 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
931 * @expectedException Crypt_GPG_InvalidKeyParamsException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
932 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
933 public function testGenerateKeyWithInvalidPrimaryKeyAlgorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
934 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
935 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
936 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
937 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
938 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
939 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
940 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
941 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
942
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
943 $key = $this->generator
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
944 ->setKeyParams(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
945 ->generateKey(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
946 new Crypt_GPG_UserId(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
947 'Test Keypair <generate-test@example.com>'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
948 )
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
949 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
950 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
951
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
952 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
953 // {{{ testGenerateKeyWithInvalidSubKeyAlgorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
954
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
955 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
956 * @group generate-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
957 * @expectedException Crypt_GPG_InvalidKeyParamsException
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
958 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
959 public function testGenerateKeyWithInvalidSubKeyAlgorithm()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
960 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
961 if (!$this->config['enable-key-generation']) {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
962 $this->markTestSkipped(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
963 'Key generation tests are disabled. To run key generation '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
964 . 'tests, enable them in the test configuration. See the '
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
965 . 'configuration in \'config.php.dist\' for an exampe.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
966 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
967 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
968
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
969 $key = $this->generator
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
970 ->setSubKeyParams(Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC_SGN)
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
971 ->generateKey(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
972 new Crypt_GPG_UserId(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
973 'Test Keypair <generate-test@example.com>'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
974 )
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
975 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
976 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
977
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
978 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
979 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
980
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
981 ?>