Skip to content

Commit cac8018

Browse files
committed
feat: scaffold behat tsa extension package
Signed-off-by: Vitor Mattos <vitor@php.rio>
0 parents  commit cac8018

10 files changed

Lines changed: 1263 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Setup PHP
16+
uses: shivammathur/setup-php@v2
17+
with:
18+
php-version: '8.2'
19+
coverage: none
20+
21+
- name: Validate composer
22+
run: composer validate --no-check-publish
23+
24+
- name: Install dependencies
25+
run: composer install --no-interaction --no-progress
26+
27+
- name: Lint
28+
run: find src tests -name '*.php' -print0 | xargs -0 -n1 php -l
29+
30+
- name: Run tests
31+
run: composer test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor/
2+
/.phpunit.cache/
3+
/composer.lock

LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# behat-tsa-extension
2+
3+
Behat extension that starts a local RFC3161 TSA server for deterministic integration tests.
4+
5+
## Why
6+
7+
Public TSA providers can introduce flaky CI runs because of network and availability variance.
8+
This extension boots a local TSA responder during Behat execution and exposes its URL through an environment variable.
9+
10+
## Installation
11+
12+
composer require --dev libresign/behat-tsa-extension
13+
14+
## Configuration
15+
16+
default:
17+
extensions:
18+
LibreSign\Behat\TsaExtension\ServiceContainer\TsaExtension:
19+
enabled: true
20+
host: 127.0.0.1
21+
port: 0
22+
path: /tsr
23+
policy_oid: 1.2.3.4.1
24+
env_var: LIBRESIGN_TSA_URL
25+
verbose: false
26+
27+
## How it works
28+
29+
- On suite start, it creates a temporary local TSA setup (CA, TSA cert, OpenSSL config).
30+
- It starts a local HTTP server that replies with a valid RFC3161 response using OpenSSL.
31+
- It exports the final endpoint in the configured environment variable.
32+
- On suite finish, it stops the server and cleans temporary files.
33+
34+
## Requirements
35+
36+
- PHP 8.2+
37+
- OpenSSL with openssl ts support
38+
- Behat 3.13+
39+
40+
## License
41+
42+
AGPL-3.0-or-later

composer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "libresign/behat-tsa-extension",
3+
"description": "Behat extension that boots a local RFC3161 TSA server for deterministic integration tests",
4+
"type": "library",
5+
"license": "AGPL-3.0-or-later",
6+
"keywords": [
7+
"behat",
8+
"rfc3161",
9+
"tsa",
10+
"libresign",
11+
"nextcloud"
12+
],
13+
"authors": [
14+
{
15+
"name": "LibreSign Team",
16+
"email": "hello@libresign.coop"
17+
}
18+
],
19+
"autoload": {
20+
"psr-4": {
21+
"LibreSign\\Behat\\TsaExtension\\": "src/"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"LibreSign\\Behat\\TsaExtension\\Tests\\": "tests/"
27+
}
28+
},
29+
"minimum-stability": "stable",
30+
"require": {
31+
"php": "^8.2",
32+
"behat/behat": "^3.13",
33+
"symfony/config": "^7.0",
34+
"symfony/dependency-injection": "^7.0",
35+
"symfony/event-dispatcher": "^7.0"
36+
},
37+
"require-dev": {
38+
"phpunit/phpunit": "^10.5"
39+
},
40+
"scripts": {
41+
"test": "phpunit -c phpunit.xml.dist --colors=always"
42+
},
43+
"config": {
44+
"optimize-autoloader": true,
45+
"classmap-authoritative": true,
46+
"sort-packages": true
47+
}
48+
}

phpunit.xml.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
3+
<testsuites>
4+
<testsuite name="unit">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
</phpunit>

0 commit comments

Comments
 (0)