Commit graph

10528 commits

Author SHA1 Message Date
Vitor Mattos
9274075bf8
chore: update dependencies and handler
Update composer.json and Pkcs12Handler changes from refactoring.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:53:02 -03:00
Vitor Mattos
4d23cd91aa
chore(test): remove old PDF fixtures
Delete PDFs from root fixtures directory.
Files now organized in tests/php/fixtures/pdfs/ with catalog.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:52:53 -03:00
Vitor Mattos
7bc88482a8
feat(test): add PdfFixtureCatalog for real signed PDFs
Create catalog system for managing real-world signed PDFs:
- PdfFixtureCatalog class with YAML-based metadata
- Filter by DocMDP level, TSA, signature tool, count
- Provides expected validation results for tests
- Includes PdfFixture wrapper for easy access
- Store real PDFs in tests/php/fixtures/pdfs/ directory

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:52:45 -03:00
Vitor Mattos
3f26b2bc24
test: reduce verbosity in Pkcs12HandlerTest
Clean up test code by:
- Removing verbose docblocks and obvious comments
- Simplifying assertion messages
- Deleting 2 redundant tests (extraction and validation)
- Reducing file size from 180 to 46 lines (74% reduction)

All 21 tests still pass with maintained coverage.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:52:35 -03:00
Vitor Mattos
04f393b9a6
refactor(test): migrate API controller tests to PdfGenerator
Replace PdfFixtureTrait with PdfGenerator in API tests:
- FileControllerTest
- FileElementControllerTest
- IdDocsControllerTest
- NotifyControllerTest
- RequestSignatureControllerTest
- SignFileControllerTest

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:52:25 -03:00
Vitor Mattos
819eca3ab1
refactor(test): migrate Unit tests to use PdfGenerator
Replace PdfFixtureTrait usage with PdfGenerator static methods:
- Remove 'use PdfFixtureTrait' statements
- Add 'use OCA\Libresign\Tests\Fixtures\PdfGenerator' imports
- Change trait method calls to static PdfGenerator:: calls
- Fix incorrect PdfGenerator::createMock() to $this->createMock()

Affected test files:
- DocMdpHandlerTest
- FileServiceTest (3 createMock fixes)
- SignFileServiceTest (20+ createMock fixes)
- PdfParseServiceTest
- PdfSignatureDetectionServiceTest
- RequestSignatureServiceTest
- ValidateHelperTest
- AEnvironmentPageAwareControllerTest

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:52:16 -03:00
Vitor Mattos
a7de549cdf
refactor(test): remove PdfFixtureTrait
Delete trait after migrating all methods to PdfGenerator.
The trait pattern was unnecessary for stateless utility methods.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:52:05 -03:00
Vitor Mattos
6f8d4111cc
feat(test): create PdfGenerator class with static methods
Consolidate PDF fixture generation into a single static class:
- Migrate all methods from PdfFixtureTrait to PdfGenerator
- Convert trait methods to public static methods
- Maintain all existing functionality
- Includes 20+ methods for ISO 32000-1 edge case testing

This improves code organization and eliminates trait usage.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:49:35 -03:00
Vitor Mattos
54b16f7f5e
Merge pull request #6194 from LibreSign/refactor/change-icon-color
refactor: change icon color
2025-12-15 15:41:39 -03:00
Vitor Mattos
fac0ce33a6
refactor: change icon color
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-15 15:28:53 -03:00
Vitor Mattos
792690ac88
Merge pull request #6191 from LibreSign/fix/fallback-to-initial-value
fix: fallback to initial value
2025-12-15 14:14:48 -03:00
Crisciany Souza
fbe2760a87 fix: fallback to initial value
Signed-off-by: Crisciany Souza <crisciany.souza@librecode.coop>
2025-12-15 12:17:22 -04:00
Nextcloud bot
cac3094c63
fix(l10n): Update translations from Transifex
Signed-off-by: Nextcloud bot <bot@nextcloud.com>
2025-12-15 02:22:35 +00:00
Vitor Mattos
f89ec9bf05
Merge pull request #6187 from LibreSign/feat/docmdp-per-file
feat: docmdp per file
2025-12-14 16:46:25 -03:00
Vitor Mattos
50b66c4f79
fix: unit tests
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
3beca7f23e
chore: add docblock of openapi.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
d23ae7b51c
fix: cs
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
114b4eabd1
test: fix unit tests for DocMDP per-file feature
- Add docmdpLevel to LibresignValidateFile schema in ResponseDefinitions
- Add DocMdpConfigService mock to RequestSignatureServiceTest
- Fix constructor parameter order in RequestSignatureServiceTest
- Mock validateDocMdpAllowsSignatures in SignFileServiceTest
- Mock getDocmdpLevelEnum to return NOT_CERTIFIED in test scenarios
- Fixes OpenAPI schema validation errors
- Fixes ArgumentCountError in RequestSignatureService tests
- Fixes enum mocking issues in SignFileService tests

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
4073b0c224
chore: bump version
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
5689200ba3
feat: show warning when DocMDP prevents adding signers
- Add NcNoteCard warning message for DocMDP level 1
- Add showDocMdpWarning computed property
- Warning only shows when button is hidden
- Prevents UI flash during state transitions
- Uses consistent error message with backend

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
99e2c0258a
feat: block adding signers when DocMDP level 1 is set
- Add isDocMdpNoChangesAllowed() method to files store
- Update canAddSigner() to check DocMDP level 1 with existing signers
- Only blocks after first signer is added (not before)
- Encapsulates logic in reusable method

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
c43159c777
feat: include docmdpLevel in API responses
- Add docmdp_level to SELECT and GROUP BY in SignRequestMapper
- Format docmdpLevel as integer in API response
- Add docmdpLevel to FileService::loadLibreSignData()
- Ensures frontend receives per-file DocMDP configuration

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
8acb7f8576
feat: validate DocMDP per file before signing
- Update validateDocMdpAllowsSignatures() to check file's docmdpLevel first
- Falls back to PDF extraction for legacy files (level 0)
- Throws consistent error message for DocMDP level 1
- Prevents adding signatures to certified documents with no changes allowed

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
cff28b6ceb
feat: save DocMDP level from global config to file on creation
- Add DocMdpConfigService dependency to RequestSignatureService
- Create setDocMdpLevelFromGlobalConfig() method
- Save admin DocMDP configuration to file entity on creation
- Allows per-file DocMDP configuration instead of only global

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
3a026f5c10
feat: add docmdp_level column to libresign_file table
- Add migration to create docmdp_level column (SMALLINT, default 0)
- Add docmdpLevel property to File entity with getters/setters
- Add getDocmdpLevelEnum() and setDocmdpLevelEnum() methods
- DocMDP levels: 0=not certified, 1=no changes, 2=form fill, 3=annotations

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 16:38:34 -03:00
Vitor Mattos
7a542b3a88
Merge pull request #6184 from LibreSign/refactor/extract-status-services
refactor: extract status services
2025-12-14 14:02:58 -03:00
Vitor Mattos
3d9652487c
test: update SequentialSigningServiceTest after IAppConfig removal
Removed IAppConfig mock from test setup to match updated
service constructor signature.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 14:00:30 -03:00
Vitor Mattos
d5e3cae60c
refactor: remove unused IAppConfig dependency from SequentialSigningService
IAppConfig was injected but never used in any method.
Removed dependency to clean up constructor.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 14:00:30 -03:00
Vitor Mattos
30c4612419
fix: cs
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 13:53:52 -03:00
Vitor Mattos
911af0d300
test: update RequestSignatureService tests for new architecture
Updated tests to inject FileStatusService and SignRequestStatusService
mocks. Added specific tests validating parallel and ordered flow
behavior with correct parameter ordering for determineInitialStatus.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 13:53:33 -03:00
Vitor Mattos
dfe40d40a9
test: add comprehensive tests for SignRequestStatusService
Created test suite with 53 tests validating business rules for sign
request status determination. Covers notification scenarios, status
updates, and initial status calculation based on file status, signer
status, signing order, and flow type. Uses PHP 8 DataProvider
attributes for parameterized testing.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 13:53:24 -03:00
Vitor Mattos
60bcd04419
test: add comprehensive tests for FileStatusService
Created test suite with 23 tests covering all file status upgrade
scenarios and notification validation. Uses PHP 8 DataProvider
attributes for parameterized testing.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 13:53:16 -03:00
Vitor Mattos
a22fef141b
refactor: extract status logic from RequestSignatureService
Injected FileStatusService and SignRequestStatusService to delegate
all status-related operations. Removed status determination methods
and notification validation logic, delegating to specialized services.
Updated method calls to use appropriate service methods.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 13:53:09 -03:00
Vitor Mattos
d74ffe257d
feat: add SignRequestStatusService for sign request status logic
Created dedicated service to manage sign request status determination
and validation. Implements shouldNotifySignRequest, canNotifySignRequest,
updateStatusIfAllowed, determineInitialStatus, and private helper methods
for status calculation based on file status, signer status, signing order,
and flow type (parallel/sequential).

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 13:53:02 -03:00
Vitor Mattos
ecc8a6a2f1
feat: add FileStatusService for file status operations
Created dedicated service to handle file status management.
Includes updateFileStatusIfUpgrade to upgrade file status and
canNotifySigners to validate if file status allows notifications.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 13:52:53 -03:00
Vitor Mattos
e784c39bcb
Merge pull request #6181 from LibreSign/feat/cancel-signature-request-notification
feat: cancel signature request notification
2025-12-14 13:00:39 -03:00
Vitor Mattos
21aee754ad
test: add missing IEventDispatcher parameter to RequestSignatureServiceTest
The RequestSignatureService constructor was updated to require 18 parameters
including IEventDispatcher, but the test was only passing 17 parameters.
This commit adds the missing mock dependency to fix all failing tests.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-14 12:51:34 -03:00
Nextcloud bot
95a26cb929
fix(l10n): Update translations from Transifex
Signed-off-by: Nextcloud bot <bot@nextcloud.com>
2025-12-14 02:16:55 +00:00
Vitor Mattos
9349178f67
fix: cs
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:24:36 -03:00
Vitor Mattos
65d0f90086
refactor: extract cancellation event logic to dedicated method
Extracts the SignRequestCanceledEvent dispatching logic from
unassociateToUser into a dedicated dispatchCancellationEventIfNeeded
method for better code organization and single responsibility.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:22:59 -03:00
Vitor Mattos
05f609537a
chore: rollback to default value
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:20:01 -03:00
Vitor Mattos
f4f03eed71
fix: cs
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:18:31 -03:00
Vitor Mattos
0cf44f0865
fix: standardize notification defaults to false
Changes default values for email and push notifications to false
in LibresignActivitySettings, ensuring all LibreSign activity types
follow the same pattern and respect user opt-in preference.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:17:59 -03:00
Vitor Mattos
650d26e2af
test: add integration tests for signature request cancellation
Adds Behat tests covering three scenarios:
1. Deleting pending request sends cancellation notification
2. Deleting draft request does not send notification
3. Deletion removes signer from file list

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:17:17 -03:00
Vitor Mattos
dacf038220
feat: register SignRequestCanceled activity type in info.xml
Adds the SignRequestCanceled setting and provider to the
activity section of info.xml, making it available in the
Nextcloud activity system.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:17:00 -03:00
Vitor Mattos
29b887a098
feat: register SignRequestCanceledEvent listeners in Application
Registers all three listeners (Notification, Mail, and Activity)
for the SignRequestCanceledEvent in the application bootstrap.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:16:43 -03:00
Vitor Mattos
f06e664ec1
feat: handle SignRequestCanceledEvent in Activity Listener
Registers the cancellation event in the activity stream,
allowing users to see signature request cancellations
in their activity history.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:16:30 -03:00
Vitor Mattos
a09013e0a8
feat: handle SignRequestCanceledEvent in MailNotifyListener
Implements email notification for canceled signature requests.
Sends email to users informing them that their signature
request has been canceled.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:16:16 -03:00
Vitor Mattos
c863c72313
feat: add notification message for canceled signature requests
Implements the notification message formatting in Notifier
to display cancellation notifications with proper subject
and message text.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:16:03 -03:00
Vitor Mattos
6009a86f73
feat: handle SignRequestCanceledEvent in NotificationListener
Implements the notification handler for canceled signature requests.
Sends in-app notifications to users when their signature request
is canceled, respecting user activity settings preferences.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
2025-12-13 17:15:50 -03:00