TYPO3 CMS  TYPO3_7-6
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 
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 
75  {
76  $this->subject->setExponent(123456);
77  $this->subject->setExponent(123456);
78  }
79 
84  {
85  $this->assertSame(
86  '',
87  $this->subject->getPrivateKey()
88  );
89  }
90 
94  public function setPrivateKeySetsPrivateKey()
95  {
96  $this->subject->setPrivateKey('foo bar');
97 
98  $this->assertSame(
99  'foo bar',
100  $this->subject->getPrivateKey()
101  );
102  }
103 
110  {
111  $this->subject->setPrivateKey('foo');
112  $this->subject->setPrivateKey('foo');
113  }
114 
119  {
120  $this->assertSame(
121  0,
122  $this->subject->getPublicKeyModulus()
123  );
124  }
125 
130  {
131  $this->subject->setPublicKey(123456);
132 
133  $this->assertSame(
134  123456,
135  $this->subject->getPublicKeyModulus()
136  );
137  }
138 
145  {
146  $this->subject->setPublicKey(123456);
147  $this->subject->setPublicKey(123456);
148  }
149 
154  {
155  $this->subject->setExponent(1861234);
156  $this->subject->setPrivateKey('lkjasbe');
157  $this->subject->setPublicKey(745786268712);
158 
159  $this->assertTrue(
160  $this->subject->isReady()
161  );
162  }
163 
168  {
169  $this->assertFalse(
170  $this->subject->isReady()
171  );
172  }
173 
178  {
179  $this->subject->setExponent(1861234);
180  $this->subject->setPrivateKey('lkjasbe');
181 
182  $this->assertFalse(
183  $this->subject->isReady()
184  );
185  }
186 
191  {
192  $this->subject->setExponent(1861234);
193  $this->subject->setPublicKey(745786268712);
194 
195  $this->assertFalse(
196  $this->subject->isReady()
197  );
198  }
199 
204  {
205  $this->subject->setPrivateKey('lkjasbe');
206  $this->subject->setPublicKey(745786268712);
207 
208  $this->assertFalse(
209  $this->subject->isReady()
210  );
211  }
212 }