Skip to content

Commit 4170714

Browse files
committed
fix: remove complex test to mock
Signed-off-by: Vitor Mattos <[email protected]>
1 parent 7299150 commit 4170714

1 file changed

Lines changed: 0 additions & 216 deletions

File tree

tests/php/Unit/Service/FileServiceTest.php

Lines changed: 0 additions & 216 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function is_uploaded_file($filename) {
2121
use bovigo\vfs\vfsStream;
2222
use InvalidArgumentException;
2323
use OCA\Libresign\AppInfo\Application;
24-
use OCA\Libresign\Db\File;
2524
use OCA\Libresign\Db\FileElementMapper;
2625
use OCA\Libresign\Db\FileMapper;
2726
use OCA\Libresign\Db\IdDocsMapper;
@@ -276,221 +275,6 @@ function (self $self, FileService $service): void {
276275
},
277276
[]
278277
],
279-
'not signed file' => [
280-
function (self $self, FileService $service): void {
281-
if (version_compare(PHP_VERSION, '8.4.0', '>=')) {
282-
/**
283-
* @todo Check why this test fails on PHP 8.4 and fix it
284-
*/
285-
$self->markTestSkipped('Skipping test for not signed file due to environment limitations with PHP >= 8.4.');
286-
}
287-
$notSigned = tempnam(sys_get_temp_dir(), 'not_signed');
288-
copy(realpath(__DIR__ . '/../../fixtures/pdfs/small_valid.pdf'), $notSigned);
289-
$service
290-
->setFileFromRequest([
291-
'tmp_name' => $notSigned,
292-
'error' => 0,
293-
'size' => 0,
294-
'name' => 'small_valid.pdf',
295-
]);
296-
},
297-
[
298-
'status' => File::STATUS_NOT_LIBRESIGN_FILE,
299-
'size' => filesize(__DIR__ . '/../../fixtures/pdfs/small_valid.pdf'),
300-
'hash' => hash_file('sha256', __DIR__ . '/../../fixtures/pdfs/small_valid.pdf'),
301-
'pdfVersion' => '1.6',
302-
'totalPages' => 1,
303-
'name' => 'small_valid.pdf',
304-
]
305-
],
306-
'signed file outside LibreSign' => [
307-
function (self $self, FileService $service): void {
308-
if (version_compare(PHP_VERSION, '8.4.0', '>=')) {
309-
/**
310-
* @todo Check why this test fails on PHP 8.4 and fix it
311-
*/
312-
$self->markTestSkipped('Skipping test for not signed file due to environment limitations with PHP >= 8.4.');
313-
}
314-
$notSigned = tempnam(sys_get_temp_dir(), 'not_signed');
315-
copy(realpath(__DIR__ . '/../../fixtures/pdfs/small_valid-signed.pdf'), $notSigned);
316-
$service
317-
->setFileFromRequest([
318-
'tmp_name' => $notSigned,
319-
'error' => 0,
320-
'size' => 0,
321-
'name' => 'small_valid.pdf',
322-
]);
323-
},
324-
[
325-
'status' => File::STATUS_NOT_LIBRESIGN_FILE,
326-
'size' => filesize(__DIR__ . '/../../fixtures/pdfs/small_valid-signed.pdf'),
327-
'hash' => hash_file('sha256', __DIR__ . '/../../fixtures/pdfs/small_valid-signed.pdf'),
328-
'pdfVersion' => '1.6',
329-
'totalPages' => 1,
330-
'name' => 'small_valid.pdf',
331-
]
332-
],
333-
'signed file outside LibreSign and display signers' => [
334-
function (self $self, FileService $service): void {
335-
if (version_compare(PHP_VERSION, '8.4.0', '>=')) {
336-
/**
337-
* @todo Check why this test fails on PHP 8.4 and fix it
338-
*/
339-
$self->markTestSkipped('Skipping test for not signed file due to environment limitations with PHP >= 8.4.');
340-
}
341-
$self->userManager->method('get')->willReturn(null);
342-
$self->userManager->method('getByEmail')->willReturn([]);
343-
$notSigned = tempnam(sys_get_temp_dir(), 'not_signed');
344-
copy(realpath(__DIR__ . '/../../fixtures/pdfs/small_valid-signed.pdf'), $notSigned);
345-
$service
346-
->setFileFromRequest([
347-
'tmp_name' => $notSigned,
348-
'error' => 0,
349-
'size' => 0,
350-
'name' => 'small_valid.pdf',
351-
])
352-
->showSigners();
353-
},
354-
[
355-
'status' => File::STATUS_NOT_LIBRESIGN_FILE,
356-
'size' => filesize(__DIR__ . '/../../fixtures/pdfs/small_valid-signed.pdf'),
357-
'hash' => hash_file('sha256', __DIR__ . '/../../fixtures/pdfs/small_valid-signed.pdf'),
358-
'pdfVersion' => '1.6',
359-
'totalPages' => 1,
360-
'name' => 'small_valid.pdf',
361-
'signers' => [
362-
[
363-
'displayName' => '/C=BR/ST=State of Company/L=City Name/O=Organization/OU=Organization Unit/CN=account:admin, admin',
364-
'subject' => [
365-
'C' => 'BR',
366-
'ST' => 'State of Company',
367-
'L' => 'City Name',
368-
'O' => 'Organization',
369-
'OU' => 'Organization Unit',
370-
'CN' => ['account:admin', 'admin'],
371-
],
372-
'valid_from' => '2025-10-20T13:26:00+00:00',
373-
'valid_to' => '2026-10-20T13:26:00+00:00',
374-
'signed' => '2025-10-20T13:31:43+00:00',
375-
'uid' => 'email:[email protected]',
376-
'signature_validation' => [
377-
'id' => 1,
378-
'label' => 'Signature is valid.',
379-
],
380-
'name' => '/C=BR/ST=State of Company/L=City Name/O=Organization/OU=Organization Unit/CN=account:admin, admin',
381-
'hash' => '4a5a1475',
382-
'issuer' => [
383-
'C' => 'BR',
384-
'ST' => 'State of Company',
385-
'L' => 'City Name',
386-
'O' => 'Organization',
387-
'OU' => 'Organization Unit',
388-
'CN' => 'Common Name',
389-
],
390-
'version' => 2,
391-
'serialNumber' => '0x4700D96F34F501CF0EA141E75F20643844393FFF',
392-
'serialNumberHex' => '4700D96F34F501CF0EA141E75F20643844393FFF',
393-
'validFrom' => '251020132600Z',
394-
'validTo' => '261020132600Z',
395-
'validFrom_time_t' => 1760966760,
396-
'validTo_time_t' => 1792502760,
397-
'signatureTypeSN' => 'RSA-SHA256',
398-
'signatureTypeLN' => 'sha256WithRSAEncryption',
399-
'signatureTypeNID' => 668,
400-
'purposes' => [
401-
1 => [true, false, 'sslclient'],
402-
2 => [false, false, 'sslserver'],
403-
3 => [false, false, 'nssslserver'],
404-
4 => [true, false, 'smimesign'],
405-
5 => [true, false, 'smimeencrypt'],
406-
6 => [false, false, 'crlsign'],
407-
7 => [true, true, 'any'],
408-
8 => [true, false, 'ocsphelper'],
409-
9 => [false, false, 'timestampsign'],
410-
],
411-
'extensions' => [
412-
'subjectAltName' => 'email:[email protected]',
413-
'basicConstraints' => 'CA:FALSE',
414-
'keyUsage' => 'Digital Signature, Non Repudiation, Key Encipherment',
415-
'extendedKeyUsage' => 'TLS Web Client Authentication, E-mail Protection',
416-
'subjectKeyIdentifier' => '76:21:81:44:79:1F:DC:85:E0:24:A1:1D:AA:8C:43:5B:0B:45:F9:48',
417-
'authorityKeyIdentifier' => '9D:6C:97:12:5D:29:8B:6D:C3:63:C0:0C:DF:28:99:18:81:17:61:69',
418-
],
419-
'isLibreSignRootCA' => false,
420-
'signingTime' => [
421-
'date' => '2025-10-20 13:31:43.000000',
422-
'timezone_type' => 1,
423-
'timezone' => '+00:00',
424-
],
425-
'chain' => [
426-
0 => [
427-
'name' => '/C=BR/ST=State of Company/L=City Name/O=Organization/OU=Organization Unit/CN=account:admin, admin',
428-
'subject' => [
429-
'C' => 'BR',
430-
'ST' => 'State of Company',
431-
'L' => 'City Name',
432-
'O' => 'Organization',
433-
'OU' => 'Organization Unit',
434-
'CN' => ['account:admin', 'admin'],
435-
],
436-
'hash' => '4a5a1475',
437-
'issuer' => [
438-
'C' => 'BR',
439-
'ST' => 'State of Company',
440-
'L' => 'City Name',
441-
'O' => 'Organization',
442-
'OU' => 'Organization Unit',
443-
'CN' => 'Common Name',
444-
],
445-
'version' => 2,
446-
'serialNumber' => '0x4700D96F34F501CF0EA141E75F20643844393FFF',
447-
'serialNumberHex' => '4700D96F34F501CF0EA141E75F20643844393FFF',
448-
'validFrom' => '251020132600Z',
449-
'validTo' => '261020132600Z',
450-
'validFrom_time_t' => 1760966760,
451-
'validTo_time_t' => 1792502760,
452-
'signatureTypeSN' => 'RSA-SHA256',
453-
'signatureTypeLN' => 'sha256WithRSAEncryption',
454-
'signatureTypeNID' => 668,
455-
'purposes' => [
456-
1 => [true, false, 'sslclient'],
457-
2 => [false, false, 'sslserver'],
458-
3 => [false, false, 'nssslserver'],
459-
4 => [true, false, 'smimesign'],
460-
5 => [true, false, 'smimeencrypt'],
461-
6 => [false, false, 'crlsign'],
462-
7 => [true, true, 'any'],
463-
8 => [true, false, 'ocsphelper'],
464-
9 => [false, false, 'timestampsign'],
465-
],
466-
'extensions' => [
467-
'keyUsage' => 'Digital Signature, Non Repudiation, Key Encipherment',
468-
'extendedKeyUsage' => 'TLS Web Client Authentication, E-mail Protection',
469-
'basicConstraints' => 'CA:FALSE',
470-
'subjectKeyIdentifier' => '76:21:81:44:79:1F:DC:85:E0:24:A1:1D:AA:8C:43:5B:0B:45:F9:48',
471-
'authorityKeyIdentifier' => '9D:6C:97:12:5D:29:8B:6D:C3:63:C0:0C:DF:28:99:18:81:17:61:69',
472-
'subjectAltName' => 'email:[email protected]',
473-
],
474-
'signature_validation' => [
475-
'id' => 1,
476-
'label' => 'Signature is valid.',
477-
],
478-
'isLibreSignRootCA' => false,
479-
'valid_from' => '2025-10-20T13:26:00+00:00',
480-
'valid_to' => '2026-10-20T13:26:00+00:00',
481-
'displayName' => '/C=BR/ST=State of Company/L=City Name/O=Organization/OU=Organization Unit/CN=account:admin, admin',
482-
'crl_validation' => 'missing',
483-
'crl_urls' => [],
484-
],
485-
],
486-
'crl_validation' => 'missing',
487-
'crl_urls' => [],
488-
'status' => 2,
489-
'statusText' => 'Signed',
490-
],
491-
],
492-
],
493-
],
494278
];
495279
}
496280

0 commit comments

Comments
 (0)