|
8 | 8 |
|
9 | 9 | use OCA\Libresign\Exception\EmptyCertificateException; |
10 | 10 | use OCA\Libresign\Exception\InvalidPasswordException; |
| 11 | +use OCA\Libresign\Exception\LibresignException; |
11 | 12 | use OCA\Libresign\Handler\CertificateEngine\OpenSslHandler; |
12 | 13 | use OCA\Libresign\Service\CertificatePolicyService; |
13 | 14 | use OCP\Files\AppData\IAppDataFactory; |
@@ -72,6 +73,35 @@ public function testInvalidPassword(): void { |
72 | 73 | $signerInstance->readCertificate($certificateContent, 'invalid password'); |
73 | 74 | } |
74 | 75 |
|
| 76 | + public function testMaxLengthOfDistinguishedNamesWithSuccess(): void { |
| 77 | + // Create root cert |
| 78 | + $rootInstance = $this->getInstance(); |
| 79 | + $rootInstance->generateRootCert('', []); |
| 80 | + |
| 81 | + // Create signer cert |
| 82 | + $signerInstance = $this->getInstance(); |
| 83 | + $longName = str_repeat('a', 64); |
| 84 | + $signerInstance->setCommonName($longName); |
| 85 | + $signerInstance->setPassword('123456'); |
| 86 | + $certificateContent = $signerInstance->generateCertificate(); |
| 87 | + $parsed = $signerInstance->readCertificate($certificateContent, '123456'); |
| 88 | + $this->assertEquals($longName, $parsed['subject']['CN']); |
| 89 | + } |
| 90 | + |
| 91 | + public function testBiggerThanMaxLengthOfDistinguishedNamesWithError(): void { |
| 92 | + // Create root cert |
| 93 | + $rootInstance = $this->getInstance(); |
| 94 | + $rootInstance->generateRootCert('', []); |
| 95 | + |
| 96 | + // Create signer cert |
| 97 | + $signerInstance = $this->getInstance(); |
| 98 | + $longName = str_repeat('a', 65); |
| 99 | + $signerInstance->setCommonName($longName); |
| 100 | + $signerInstance->setPassword('123456'); |
| 101 | + $this->expectException(LibresignException::class); |
| 102 | + $signerInstance->generateCertificate(); |
| 103 | + } |
| 104 | + |
75 | 105 | /** |
76 | 106 | * @dataProvider dataReadCertificate |
77 | 107 | */ |
|
0 commit comments