diff --git a/tests/integration/composer.json b/tests/integration/composer.json index cd4decd319..201f459066 100644 --- a/tests/integration/composer.json +++ b/tests/integration/composer.json @@ -7,7 +7,8 @@ "php-http/guzzle7-adapter": "^1.0", "php-http/message": "^1.16", "libresign/nextcloud-behat": "^1.4", - "libresign/mailpit-behat-extension": "^0.1.1" + "libresign/mailpit-behat-extension": "^0.1.1", + "libresign/behat-tsa-extension": "^0.1.0" }, "config": { "allow-plugins": { diff --git a/tests/integration/composer.lock b/tests/integration/composer.lock index 20b27a2588..411f958ad6 100644 --- a/tests/integration/composer.lock +++ b/tests/integration/composer.lock @@ -947,6 +947,60 @@ }, "time": "2024-10-31T18:50:11+00:00" }, + { + "name": "libresign/behat-tsa-extension", + "version": "v0.1.1", + "source": { + "type": "git", + "url": "https://github.com/LibreSign/behat-tsa-extension.git", + "reference": "3023dee644115db79545790f9b8c6d9e51c5a38d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/LibreSign/behat-tsa-extension/zipball/3023dee644115db79545790f9b8c6d9e51c5a38d", + "reference": "3023dee644115db79545790f9b8c6d9e51c5a38d", + "shasum": "" + }, + "require": { + "behat/behat": "^3.13", + "php": "^8.2", + "symfony/config": "^7.0", + "symfony/dependency-injection": "^7.0", + "symfony/event-dispatcher": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "LibreSign\\Behat\\TsaExtension\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "AGPL-3.0-or-later" + ], + "authors": [ + { + "name": "LibreSign Team", + "email": "hello@libresign.coop" + } + ], + "description": "Behat extension that boots a local RFC3161 TSA server for deterministic integration tests", + "keywords": [ + "Behat", + "libresign", + "nextcloud", + "rfc3161", + "tsa" + ], + "support": { + "issues": "https://github.com/LibreSign/behat-tsa-extension/issues", + "source": "https://github.com/LibreSign/behat-tsa-extension/tree/v0.1.1" + }, + "time": "2026-04-04T00:59:59+00:00" + }, { "name": "libresign/mailpit-behat-extension", "version": "v0.1.1", diff --git a/tests/integration/config/behat.yml b/tests/integration/config/behat.yml index 9c2943ec03..6fb644805f 100644 --- a/tests/integration/config/behat.yml +++ b/tests/integration/config/behat.yml @@ -20,3 +20,4 @@ default: jarnaiz\JUnitFormatter\JUnitFormatterExtension: filename: report.xml outputDir: '%paths.base%/../output/' + LibreSign\Behat\TsaExtension\ServiceContainer\TsaExtension: ~ diff --git a/tests/integration/features/admin/tsa.feature b/tests/integration/features/admin/tsa.feature index 617f8d5297..24a9e27e1f 100644 --- a/tests/integration/features/admin/tsa.feature +++ b/tests/integration/features/admin/tsa.feature @@ -4,8 +4,8 @@ Feature: TSA Administration - Core Configuration Given as user "admin" When sending "post" to ocs "/apps/libresign/api/v1/admin/tsa" - | tsa_url | https://freetsa.org/tsr | - | tsa_policy | 1.2.3.4.1 | + | tsa_url | | + | tsa_policy_oid | 1.2.3.4.1 | | tsa_auth_type | none | Then the response should have a status code 200 And the response should be a JSON array with the following mandatory values @@ -16,7 +16,7 @@ Feature: TSA Administration - Core Configuration Then the response should have a status code 200 And the response should be a JSON array with the following mandatory values | key | value | - | (jq).ocs.data.data | https://freetsa.org/tsr | + | (jq).ocs.data.data | | When sending "delete" to ocs "/apps/libresign/api/v1/admin/tsa" Then the response should have a status code 200 diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 68f4500a11..0ab8bf026d 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -49,6 +49,7 @@ protected function beforeRequest(string $fullUrl, array $options): array { protected function parseText(string $text): string { $fields = $this->fields; $fields['BASE_URL'] = $this->baseUrl . '/index.php'; + $fields['TSA_URL'] = getenv('LIBRESIGN_TSA_URL') ?: 'https://freetsa.org/tsr'; foreach ($fields as $key => $value) { $patterns[] = '/<' . $key . '>/'; $replacements[] = $value; diff --git a/tests/integration/features/sign/signed.feature b/tests/integration/features/sign/signed.feature index 72f3e98ca5..4f0fec660c 100644 --- a/tests/integration/features/sign/signed.feature +++ b/tests/integration/features/sign/signed.feature @@ -9,7 +9,11 @@ Feature: signed And run the command "libresign:configure:openssl --cn=Common\ Name --c=BR --o=Organization --st=State\ of\ Company --l=City\ Name --ou=Organization\ Unit" with result code 0 And run the command "config:app:set libresign add_footer --value=true --type=boolean" with result code 0 And run the command "config:app:set libresign write_qrcode_on_footer --value=true --type=boolean" with result code 0 - And run the command "config:app:set libresign tsa_url --value=https://freetsa.org/tsr --type=string" with result code 0 + And sending "post" to ocs "/apps/libresign/api/v1/admin/tsa" + | tsa_url | | + | tsa_policy_oid | 1.2.3.4.1 | + | tsa_auth_type | none | + And the response should have a status code 200 And sending "post" to ocs "/apps/provisioning_api/api/v1/config/apps/libresign/identify_methods" | value | (string)[{"name":"account","enabled":true,"mandatory":true,"signatureMethods":{"password":{"name":"password","enabled":true}},"signatureMethodEnabled":"password"}] | And the response should have a status code 200 diff --git a/tests/integration/features/sign/tsa.feature b/tests/integration/features/sign/tsa.feature index 01d5ea3383..4ceb4ce7ee 100644 --- a/tests/integration/features/sign/tsa.feature +++ b/tests/integration/features/sign/tsa.feature @@ -10,8 +10,11 @@ Feature: TSA Integration - End-to-End Workflow Scenario: TSA workflow - Successfully signs document with timestamp Given run the command "config:app:set libresign signing_mode --value=sync --type=string" with result code 0 - And run the command "config:app:set libresign tsa_url --value=https://freetsa.org/tsr --type=string" with result code 0 - And run the command "config:app:set libresign tsa_auth_type --value=none --type=string" with result code 0 + And sending "post" to ocs "/apps/libresign/api/v1/admin/tsa" + | tsa_url | | + | tsa_policy_oid | 1.2.3.4.1 | + | tsa_auth_type | none | + And the response should have a status code 200 And sending "post" to ocs "/apps/provisioning_api/api/v1/config/apps/libresign/identify_methods" | value | (string)[{"name":"account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":true}},"signatureMethodEnabled":"clickToSign"}] | And the response should have a status code 200 @@ -49,12 +52,8 @@ Feature: TSA Integration - End-to-End Workflow | key | value | | (jq).ocs.data.signers[0].timestamp.serialNumber \|test("^[0-9]+$") | true | And the response should be a JSON array with the following mandatory values - | key | value | - | (jq).ocs.data.signers[0].timestamp.genTime \|test("^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}") | true | - And the response should be a JSON array with the following mandatory values - | key | value | - | (jq).ocs.data.signers[0].timestamp.cnHints.commonName | www.freetsa.org | - | (jq).ocs.data.signers[0].timestamp.cnHints.countryName | DE | + | key | value | + | (jq).ocs.data.signers[0].timestamp.cnHints.commonName \|test("LibreSign Local TSA") | true | Scenario: TSA error handling - Invalid server Given run the command "config:app:set libresign tsa_url --value=https://invalid-tsa-server.example.com/tsr --type=string" with result code 0