- Add reset() method to AppConfigOverwrite that clears overWrite and deleted arrays and returns self
- Integrate reset() directly into getMockAppConfig() to ensure clean state on every call
- All tests now automatically get clean AppConfig state without explicit reset calls
- Prevents state pollution across test suites by resetting at the source
- Simplifies test code by removing need for separate reset wrapper method
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
The CA ID (libresign-ca-id:...) in OrganizationalUnit should only be
filtered out when the certificate is not generated (isSetupOk() returns
false). When the certificate is successfully generated, the CA ID must
be preserved in the API response.
This ensures:
- Generated certificates: CA ID is visible (expected behavior)
- Failed/not generated: CA ID is filtered to prevent stale data in form
Integration tests validated:
- features/account/signature.feature:2 (OpenSSL)
- features/account/signature.feature:23 (CFSSL)
- features/admin/certificate_openssl.feature:2
- features/admin/certificate_openssl.feature:35
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Prevent test state pollution by ensuring config_path is deleted
in setUp(). This fixes failures in OpenSslHandlerTest where the
temporary config path from AEngineHandlerTest was persisting
through the shared appConfig mock, causing tests that expect
properly formatted PKI directory names to fail.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Filter configPath from API response when certificate is not generated to prevent
form pre-population with outdated generation numbers that cause validation errors.
Filter CA ID (libresign-ca-id:*) from OrganizationalUnit field to prevent users
from submitting stale generation values that conflict with certificate validation.
Refactor toArray() method by extracting logic into dedicated methods:
- getConfigPathForApi(): Returns empty string for non-generated certificates
- removeCaIdFromOrganizationalUnit(): Filters CA IDs from OU arrays
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
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>
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>
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>
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>
Removed IAppConfig mock from test setup to match updated
service constructor signature.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
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>
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>
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>
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>
Added two unit tests to validate status determination logic:
1. testParallelFlowIgnoresSignerDraftStatusWhenFileIsAbleToSign:
Validates that in parallel flow, all signers are set to ABLE_TO_SIGN
when file status is ABLE_TO_SIGN, ignoring individual DRAFT status
sent by frontend.
2. testOrderedFlowRespectsSigningOrderWhenFileIsAbleToSign:
Validates that in ordered flow, only the first signer (order 1)
gets ABLE_TO_SIGN status, while subsequent signers remain DRAFT
until their turn.
Also updated getService() method to accept optional
SequentialSigningService parameter for testing different flows.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add comprehensive unit tests for the signature flow implementation.
- SequentialSigningServiceTest: Test flow detection and order assignment
- FileTest: Test enum conversion methods in File entity
- RequestSignatureServiceTest: Fix constructor to include IAppConfig mock
Tests validate the core logic without focusing on coverage metrics.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Move database value constants from File entity to SignatureFlow enum
where they belong as the single source of truth.
- Add SignatureFlow::NUMERIC_PARALLEL and NUMERIC_ORDERED_NUMERIC
- Remove circular dependency between File and SignatureFlow
- Update all references to use enum constants
- Use descriptive names instead of abbreviations
This follows single responsibility principle: the enum owns its
database representation.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Split the sequential signing test into two separate scenarios to better
validate the DRAFT status filtering behavior:
1. First scenario: Tests that signer1 can see and sign the document
(simpler flow without multiple user switches)
2. Second scenario: Tests that signer2 does NOT see the document when
their sign_request is in DRAFT status
This avoids multiple user context switches in the same scenario which
was causing authentication issues in the Behat tests, and better isolates
the behavior we want to validate.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
The FileService now includes status and statusText fields in the signer
data structure when processing signed files outside LibreSign. This
update adjusts the test expectations to match the actual behavior.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add test cases for Portuguese text with accents to verify that the
multibyte-safe wordwrap implementation correctly handles text with
diacritical marks and other Unicode characters in signature images.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Update Behat test to use correct endpoint URL and parameter name:
- Changed from '/api/v1/admin/signature-flow' to '/api/v1/admin/signature-flow/config'
- Changed parameter from 'flow' to 'mode'
This aligns with the actual AdminController endpoint implementation.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add __call callbacks to SignRequest mocks in both tests to properly return
fileId and signingOrder values. Without these callbacks, the mocks were
returning null when these magic methods were called, causing
SequentialSigningService::releaseNextOrder() to fail with a TypeError.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Add getFileId and getSigningOrder to __call callback mocks
- Return 1 for both methods in tests
- Fixes TypeError when releaseNextOrder is called with null fileId
- All 12 affected tests now pass
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Add SequentialSigningService mock in RequestSignatureServiceTest
- Add SequentialSigningService mock in SignFileServiceTest
- Update constructor calls in both test files to include new dependency
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Test parallel signing: all signers can sign immediately
- Test sequential signing: order enforced, status transitions validated
- Verify status 422 when signer attempts to sign out of order
- Verify status changes from DRAFT to ABLE_TO_SIGN after previous signer completes
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add comprehensive test coverage for configureIdentifyMethodsForEngine
including edge cases and data provider patterns.
Tests validate that 'none' engine correctly configures only account
identification with minimal configuration.
Related to #5145
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add Behat integration tests to validate engine switch detection.
Tests verify that switching between OpenSSL and CFSSL certificate
engines without proper configuration is correctly detected and
reported.
Scenarios tested:
- Set OpenSSL engine, configure it, then switch to unconfigured CFSSL
- Delete engine configuration and verify error state
Fixes#5272
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Create ConfigureCheckServiceTest with namespace-based function mocking
to test checkImagick() behavior. Uses DataProvider to test both scenarios:
extension loaded and not loaded. Mock allows testing independently of
actual Imagick installation state.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Added PdfSignatureDetectionService as a new dependency in the
SignFileService constructor. Updated all test setup code to create
and inject a mock of this service.
This maintains test isolation while allowing the service to use the
new signature detection logic.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Changed createMinimalPdf() and createPdfWithDocMdp() from protected
to public visibility. This simplifies test code by allowing direct
usage without wrapper methods or complex workarounds.
The methods are already designed for test usage only and making them
public improves usability in data providers and static contexts.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This service provides a dedicated, testable way to detect if a PDF
already contains signatures. It encapsulates the signature detection
logic that was previously scattered across multiple handlers.
The service creates a memory resource from PDF content and uses the
SignEngineFactory to check for existing certificate chains. It handles
exceptions gracefully and returns false for any detection failures.
Tests use real PDF fixtures (signed and unsigned) instead of mocks,
providing better confidence in the detection logic.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Tests now only check for exception type, not message, for DocMDP-related logic.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>