Skip to content

Commit 44ca686

Browse files
committed
chore: create ValidateServiceTest file
Signed-off-by: Crisciany Souza <[email protected]>
1 parent 934d6e9 commit 44ca686

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
6+
* SPDX-License-Identifier: AGPL-3.0-or-later
7+
*/
8+
9+
namespace OCA\Libresign\Tests\Unit\Service;
10+
11+
use OCA\Libresign\AppInfo\Application;
12+
use OCA\Libresign\Service\Certificate\RulesService;
13+
use OCA\Libresign\Service\Certificate\ValidateService;
14+
use OCP\IL10N;
15+
use OCP\L10N\IFactory as IL10NFactory;
16+
use PHPUnit\Framework\Attributes\DataProvider;
17+
18+
class ValidateServiceTest extends \OCA\Libresign\Tests\Unit\TestCase {
19+
20+
private IL10N $l10n;
21+
22+
public function setUp(): void {
23+
$this->l10n = \OCP\Server::get(IL10NFactory::class)->get(Application::APP_ID);
24+
}
25+
26+
public function getService(): RulesService {
27+
return new RulesService(
28+
$this->l10n,
29+
);
30+
}
31+
32+
public function testValidateWithValidInput(): void {
33+
$service = new ValidateService($this->getService(), $this->l10n);
34+
$service->validate('CN', 'John Doe');
35+
}
36+
37+
public function testValidateWithInvalidInput(): void {
38+
$service = new ValidateService($this->getService(), $this->l10n);
39+
$this->expectException(\InvalidArgumentException::class);
40+
$this->expectExceptionMessage("Parameter 'CN' should be betweeen 1 and 64.");
41+
$service->validate('CN', str_repeat('a', 65));
42+
}
43+
}

0 commit comments

Comments
 (0)