File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
tests/php/Unit/Service/Certificate Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments