TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
KeypairTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Rsaauth\Tests\Unit;
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 
23 {
27  protected $subject = null;
28 
29  protected function setUp()
30  {
31  $this->subject = new Keypair();
32  }
33 
37  public function classIsSingleton()
38  {
39  $this->assertInstanceOf(
40  \TYPO3\CMS\Core\SingletonInterface::class,
41  $this->subject
42  );
43  }
44 
49  {
50  $this->assertSame(
51  0,
52  $this->subject->getExponent()
53  );
54  }
55 
59  public function setExponentSetsExponent()
60  {
61  $this->subject->setExponent(123456);
62 
63  $this->assertSame(
64  123456,
65  $this->subject->getExponent()
66  );
67  }
68 
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 
110  {
111  $this->expectException(\BadMethodCallException::class);
112  $this->expectExceptionCode(1296062831);
113  $this->subject->setPrivateKey('foo');
114  $this->subject->setPrivateKey('foo');
115  }
116 
121  {
122  $this->assertSame(
123  0,
124  $this->subject->getPublicKeyModulus()
125  );
126  }
127 
132  {
133  $this->subject->setPublicKey(123456);
134 
135  $this->assertSame(
136  123456,
137  $this->subject->getPublicKeyModulus()
138  );
139  }
140 
146  {
147  $this->expectException(\BadMethodCallException::class);
148  $this->expectExceptionCode(1296062832);
149  $this->subject->setPublicKey(123456);
150  $this->subject->setPublicKey(123456);
151  }
152 
157  {
158  $this->subject->setExponent(1861234);
159  $this->subject->setPrivateKey('lkjasbe');
160  $this->subject->setPublicKey(745786268712);
161 
162  $this->assertTrue(
163  $this->subject->isReady()
164  );
165  }
166 
171  {
172  $this->assertFalse(
173  $this->subject->isReady()
174  );
175  }
176 
181  {
182  $this->subject->setExponent(1861234);
183  $this->subject->setPrivateKey('lkjasbe');
184 
185  $this->assertFalse(
186  $this->subject->isReady()
187  );
188  }
189 
194  {
195  $this->subject->setExponent(1861234);
196  $this->subject->setPublicKey(745786268712);
197 
198  $this->assertFalse(
199  $this->subject->isReady()
200  );
201  }
202 
207  {
208  $this->subject->setPrivateKey('lkjasbe');
209  $this->subject->setPublicKey(745786268712);
210 
211  $this->assertFalse(
212  $this->subject->isReady()
213  );
214  }
215 }