‪TYPO3CMS  9.5
KeypairTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪KeypairTest extends UnitTestCase
24 {
28  protected ‪$subject;
29 
30  protected function ‪setUp()
31  {
32  $this->subject = new ‪Keypair();
33  }
34 
38  public function ‪classIsSingleton()
39  {
40  $this->assertInstanceOf(
41  \‪TYPO3\CMS\Core\SingletonInterface::class,
42  $this->subject
43  );
44  }
45 
49  public function ‪getExponentInitiallyReturnsZero()
50  {
51  $this->assertSame(
52  0,
53  $this->subject->getExponent()
54  );
55  }
56 
60  public function ‪setExponentSetsExponent()
61  {
62  $this->subject->setExponent(123456);
63 
64  $this->assertSame(
65  123456,
66  $this->subject->getExponent()
67  );
68  }
69 
74  {
75  $this->expectException(\BadMethodCallException::class);
76  $this->expectExceptionCode(1296062830);
77  $this->subject->setExponent(123456);
78  $this->subject->setExponent(123456);
79  }
80 
85  {
86  $this->assertSame(
87  '',
88  $this->subject->getPrivateKey()
89  );
90  }
91 
95  public function ‪setPrivateKeySetsPrivateKey()
96  {
97  $this->subject->setPrivateKey('foo bar');
98 
99  $this->assertSame(
100  'foo bar',
101  $this->subject->getPrivateKey()
102  );
103  }
104 
109  {
110  $this->expectException(\BadMethodCallException::class);
111  $this->expectExceptionCode(1296062831);
112  $this->subject->setPrivateKey('foo');
113  $this->subject->setPrivateKey('foo');
114  }
115 
120  {
121  $this->assertSame(
122  0,
123  $this->subject->getPublicKeyModulus()
124  );
125  }
126 
130  public function ‪setPublicKeySetsPublicKeyModulus()
131  {
132  $this->subject->setPublicKey(123456);
133 
134  $this->assertSame(
135  123456,
136  $this->subject->getPublicKeyModulus()
137  );
138  }
139 
144  {
145  $this->expectException(\BadMethodCallException::class);
146  $this->expectExceptionCode(1296062832);
147  $this->subject->setPublicKey(123456);
148  $this->subject->setPublicKey(123456);
149  }
150 
155  {
156  $this->subject->setExponent(1861234);
157  $this->subject->setPrivateKey('lkjasbe');
158  $this->subject->setPublicKey(745786268712);
159 
160  $this->assertTrue(
161  $this->subject->isReady()
162  );
163  }
164 
168  public function ‪isReadyForNothingSetReturnsFalse()
169  {
170  $this->assertFalse(
171  $this->subject->isReady()
172  );
173  }
174 
179  {
180  $this->subject->setExponent(1861234);
181  $this->subject->setPrivateKey('lkjasbe');
182 
183  $this->assertFalse(
184  $this->subject->isReady()
185  );
186  }
187 
192  {
193  $this->subject->setExponent(1861234);
194  $this->subject->setPublicKey(745786268712);
195 
196  $this->assertFalse(
197  $this->subject->isReady()
198  );
199  }
200 
205  {
206  $this->subject->setPrivateKey('lkjasbe');
207  $this->subject->setPublicKey(745786268712);
208 
209  $this->assertFalse(
210  $this->subject->isReady()
211  );
212  }
213 }
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\setExponentCalledTwoTimesThrowsException
‪setExponentCalledTwoTimesThrowsException()
Definition: KeypairTest.php:72
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\isReadyForExponentSetAndPrivateKeySetAndPublicKeyModulusSetReturnsTrue
‪isReadyForExponentSetAndPrivateKeySetAndPublicKeyModulusSetReturnsTrue()
Definition: KeypairTest.php:153
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\setPrivateKeyCalledTwoTimesThrowsException
‪setPrivateKeyCalledTwoTimesThrowsException()
Definition: KeypairTest.php:107
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\$subject
‪Keypair $subject
Definition: KeypairTest.php:27
‪TYPO3
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\getPublicKeyModulusInitiallyReturnsZero
‪getPublicKeyModulusInitiallyReturnsZero()
Definition: KeypairTest.php:118
‪TYPO3\CMS\Rsaauth\Tests\Unit
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\isReadyForExponentSetAndPrivateKeySetAndPublicKeyModulusMissingReturnsFalse
‪isReadyForExponentSetAndPrivateKeySetAndPublicKeyModulusMissingReturnsFalse()
Definition: KeypairTest.php:177
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\setPublicKeySetsPublicKeyModulus
‪setPublicKeySetsPublicKeyModulus()
Definition: KeypairTest.php:129
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\classIsSingleton
‪classIsSingleton()
Definition: KeypairTest.php:37
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\isReadyForExponentSetAndPrivateMissingSetAndPublicKeyModulusSetReturnsFalse
‪isReadyForExponentSetAndPrivateMissingSetAndPublicKeyModulusSetReturnsFalse()
Definition: KeypairTest.php:190
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\getPrivateKeyInitiallyReturnsEmptyString
‪getPrivateKeyInitiallyReturnsEmptyString()
Definition: KeypairTest.php:83
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\isReadyForNothingSetReturnsFalse
‪isReadyForNothingSetReturnsFalse()
Definition: KeypairTest.php:167
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\setPublicKeyCalledTwoTimesThrowsException
‪setPublicKeyCalledTwoTimesThrowsException()
Definition: KeypairTest.php:142
‪TYPO3\CMS\Rsaauth\Keypair
Definition: Keypair.php:22
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\getExponentInitiallyReturnsZero
‪getExponentInitiallyReturnsZero()
Definition: KeypairTest.php:48
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\isReadyForExponentMissingAndPrivateKeySetAndPublicKeyModulusSetReturnsFalse
‪isReadyForExponentMissingAndPrivateKeySetAndPublicKeyModulusSetReturnsFalse()
Definition: KeypairTest.php:203
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest
Definition: KeypairTest.php:24
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\setPrivateKeySetsPrivateKey
‪setPrivateKeySetsPrivateKey()
Definition: KeypairTest.php:94
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\setUp
‪setUp()
Definition: KeypairTest.php:29
‪TYPO3\CMS\Rsaauth\Tests\Unit\KeypairTest\setExponentSetsExponent
‪setExponentSetsExponent()
Definition: KeypairTest.php:59